Skip to content
Skillv1.0.0

longbridge

Longbridge / LongPort (长桥证券) — US/HK/A-share stocks. Account, positions, orders, quotes, history, and order placement. Use when the user wants to check or trade a Longbridge / 长桥 account (e.g. "Longbr

by starchild-ai-agent(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from starchild-ai-agent/official-skills (longbridge/SKILL.md). Install upstream with npx skills add starchild-ai-agent/official-skills --skill longbridge. Copyright stays with the author.

What this is

☁️ Cloud broker — runs directly in the container via the official longport SDK (formerly longbridge). Covers US, HK, and A-share markets.

Auth is static key: App Key + App Secret + Access Token. These use the SDK's own env var names so they're picked up automatically.

⚠️ No paper/live discriminator exists in the API. Paper vs live is determined only by which Access Token you loaded — there is no field, account prefix, or host that distinguishes them. So --profile here is trust-declared (echoed back as paper_guard: config_declared); it does not verify anything on the server. Live placement still requires --confirm-live. Treat the token you configure as authoritative for which environment you're in.

Get your credentials

  1. Open a Longbridge account, then go to the LongPort OpenAPI console (开放平台).
  2. Apply for / enable OpenAPI access. The console issues three values:
    • App Key
    • App Secret
    • Access Token (has an expiry — regenerate when it lapses)
  3. For paper trading, generate the token while your account/environment is in the paper/模拟 mode the platform offers; for live, use the live token. (Same three field names either way.)

Configure (.env)

Request via secure input — never paste keys in chat. These are the SDK's standard names:

Variable Required Notes
LONGPORT_APP_KEY yes App Key
LONGPORT_APP_SECRET yes App Secret
LONGPORT_ACCESS_TOKEN yes Access Token (expires — refresh when needed)

Usage

pip install longport (first run). JSON output. Default profile paper (label only).

python skills/longbridge/scripts/longbridge_cli.py status
python skills/longbridge/scripts/longbridge_cli.py account
python skills/longbridge/scripts/longbridge_cli.py positions
python skills/longbridge/scripts/longbridge_cli.py orders [--executions]
python skills/longbridge/scripts/longbridge_cli.py quote --symbol 700.HK
python skills/longbridge/scripts/longbridge_cli.py history --symbol AAPL.US --period 1d --limit 90
# place: qty in shares only; market or limit
python skills/longbridge/scripts/longbridge_cli.py place --symbol 700.HK --side buy --qty 100 --type limit --limit-price 350
python skills/longbridge/scripts/longbridge_cli.py cancel --order-id <id>
# live (real money): add --confirm-live (profile is label-only)
python skills/longbridge/scripts/longbridge_cli.py --confirm-live place --symbol AAPL.US --side buy --qty 1

Symbol format is mandatory: <ticker>.<market>700.HK, AAPL.US, 000001.SZ, 600519.SH. Periods: 1m 5m 15m 30m 1h 1d 1w 1M.

Gotchas

  • Longbridge has no notional path — always --qty (shares).
  • The Access Token expires; if calls start failing auth, regenerate it in the console and update .env.
  • Because there's no server-side paper/live check, double-check which token you loaded before any live order — the CLI can't catch a mislabeled environment for you.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/starchild-ai-agent-official-skills-longbridge/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

starchild-ai-agent-official-skills-longbridge.ocm.jsonjson
{
  "ocm": "1",
  "id": "starchild-ai-agent-official-skills-longbridge",
  "kind": "skill",
  "name": "longbridge",
  "description": "Longbridge / LongPort (长桥证券) — US/HK/A-share stocks. Account, positions, orders, quotes, history, and order placement. Use when the user wants to check or trade a Longbridge / 长桥 account (e.g. \"Longbridge balance\", \"buy 100 700.HK on Longbridge\", \"my 长桥 positions\"). Cloud API via the official longport SDK, runs in the container.",
  "publisher": "starchild-ai-agent",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "longbridge",
      "longport",
      "broker",
      "us-stocks",
      "hk-stocks",
      "trading",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Longbridge / LongPort (长桥证券) — US/HK/A-share stocks. Account, positions, orders, quotes, history, and order placement. Use when the user wants to check or trade a Longbridge / 长桥 account (e.g. \"Longbridge balance\", \"buy 100 700.HK on Longbridge\", \"my 长桥 positions\"). Cloud API via the official longport SDK, runs in the container."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/starchild-ai-agent/official-skills",
      "path": "longbridge/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/starchild-ai-agent/official-skills/blob/HEAD/longbridge/SKILL.md",
      "key": "starchild-ai-agent/official-skills/longbridge/SKILL.md"
    }
  },
  "instructions": "## What this is\n\n☁️ **Cloud broker** — runs **directly in the container** via the official `longport` SDK (formerly `longbridge`). Covers US, HK, and A-share markets.\n\nAuth is **static key**: App Key + App Secret + Access Token. These use the SDK's own env var names so they're picked up automatically.\n\n⚠️ **No paper/live discriminator exists in the API.** Paper vs live is determined *only* by which Access Token you loaded — there is no field, account prefix, or host that distinguishes them. So `--profile` here is **trust-declared** (echoed back as `paper_guard: config_declared`); it does not v",
  "cost": {
    "context_tokens": 754
  }
}

Fetch it by URL: GET /api/v1/registry/starchild-ai-agent-official-skills-longbridge/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.