longbridge

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Longbridge Developers Platform

Longbridge开发者平台

Full-stack financial data and trading platform: CLI, Python/Rust SDK, MCP, and LLM integration.
全栈金融数据与交易平台:包含CLI、Python/Rust SDK、MCP及LLM集成功能。

First-Time Setup

首次设置

Before using any Longbridge feature, check which tools are available:
CLI — run
longbridge --version
to check. If not installed:
bash
undefined
在使用Longbridge的任何功能前,请确认可用工具:
CLI — 运行
longbridge --version
检查是否已安装。若未安装:
bash
undefined

macOS

macOS

brew install --cask longbridge/tap/longbridge-terminal
brew install --cask longbridge/tap/longbridge-terminal

Any platform

任意平台


Then authenticate:

```bash
longbridge login
MCP (for AI tools) — if the user wants to query data or trade directly inside the AI chat (without writing code), add the hosted MCP server:
bash
undefined

然后进行身份验证:

```bash
longbridge login
MCP(适用于AI工具) — 如果用户想在AI聊天界面内直接查询数据或进行交易(无需编写代码),请添加托管的MCP服务器:
bash
undefined

Claude Code

Claude Code

claude mcp add longbridge https://openapi.longbridge.com/mcp

First tool call triggers an OAuth browser flow. See [references/mcp.md](references/mcp.md) for other clients (Cursor, ChatGPT, Zed).

---
claude mcp add longbridge https://openapi.longbridge.com/mcp

首次工具调用会触发OAuth浏览器授权流程。其他客户端(Cursor、ChatGPT、Zed)的设置请参考[references/mcp.md]。

---

Choose the Right Tool

选择合适的工具

User wants to...                         → Use
─────────────────────────────────────────────────────────────────
Quick quote / one-off data lookup        CLI
Interactive terminal workflows           CLI
Script market data, save to file         CLI + jq  (or Python SDK)
Loops, conditions, transformations       Python SDK (sync)
Async pipelines, concurrent fetches      Python SDK (async)
Production service, high throughput      Rust SDK
Real-time WebSocket subscription loop    SDK (Python or Rust)
Programmatic order strategy              SDK
Talk to AI about stocks (no code)        MCP (hosted or self-hosted)
Use Cursor/Claude for trading analysis   MCP
Add Longbridge API docs to IDE/RAG       LLMs.txt / Markdown API
用户需求...                         → 对应工具
─────────────────────────────────────────────────────────────────
快速报价/一次性数据查询        → CLI
交互式终端工作流           → CLI
编写脚本获取市场数据并保存到文件 → CLI + jq (或Python SDK)
循环、条件判断、数据转换       → Python SDK(同步)
异步流水线、并发获取数据      → Python SDK(异步)
生产环境服务、高吞吐量      → Rust SDK
实时WebSocket订阅循环    → SDK(Python或Rust)
程序化交易策略              → SDK
无需代码即可通过AI查询股票信息        → MCP(托管或自托管)
使用Cursor/Claude进行交易分析   → MCP
将Longbridge API文档集成到IDE/RAG系统       → LLMs.txt / Markdown API

Symbol Format

代码格式

<CODE>.<MARKET>
— applies to all tools.
MarketSuffixExamples
Hong Kong
HK
700.HK
,
9988.HK
,
2318.HK
United States
US
TSLA.US
,
AAPL.US
,
NVDA.US
China Shanghai
SH
600519.SH
,
000001.SH
China Shenzhen
SZ
000568.SZ
,
300750.SZ
Singapore
SG
D05.SG
,
U11.SG
Crypto
HAS
BTCUSD.HAS
,
ETHUSD.HAS
<代码>.<市场后缀>
— 适用于所有工具。
市场后缀示例
香港
HK
700.HK
,
9988.HK
,
2318.HK
美国
US
TSLA.US
,
AAPL.US
,
NVDA.US
中国上海
SH
600519.SH
,
000001.SH
中国深圳
SZ
000568.SZ
,
300750.SZ
新加坡
SG
D05.SG
,
U11.SG
加密货币
HAS
BTCUSD.HAS
,
ETHUSD.HAS

Authentication Overview

身份验证概述

MethodCredentialBest for
OAuth 2.0 ⭐
client_id
only, no secret
CLI, SDK scripts, MCP
API Key
APP_KEY
+
APP_SECRET
+
ACCESS_TOKEN
Legacy / server-side
OAuth token cache:
~/.longbridge/openapi/tokens/<client_id>
Register OAuth client: POST
https://openapi.longbridge.com/oauth2/register
方式凭证适用场景
OAuth 2.0 ⭐仅需
client_id
,无需密钥
CLI、SDK脚本、MCP
API密钥
APP_KEY
+
APP_SECRET
+
ACCESS_TOKEN
旧版 / 服务器端
OAuth令牌缓存路径:
~/.longbridge/openapi/tokens/<client_id>
注册OAuth客户端: POST
https://openapi.longbridge.com/oauth2/register

Rate Limits

速率限制

  • REST API: max 10 calls/second
  • SDK auto-refreshes OAuth tokens
  • WebSocket subscriptions: subject to quote package limits
  • REST API: 最大10次调用/秒
  • SDK会自动刷新OAuth令牌
  • WebSocket订阅:受行情套餐限制

Reference Files

参考文档

CLI (Terminal)

CLI(终端)

  • Overview — install, auth, output formats, patterns: references/cli/overview.md
Always use
longbridge --help
to list available commands, and
longbridge <command> --help
for specific options and flags.
Do not rely on hardcoded documentation — the CLI's built-in help is always up-to-date.
  • 概述 — 安装、身份验证、输出格式、使用模式:[references/cli/overview.md]
请始终使用
longbridge --help
查看可用命令,使用
longbridge <command> --help
获取特定选项和参数的详细信息。不要依赖硬编码的文档——CLI的内置帮助始终是最新的。

Python SDK

Python SDK

  • Overview — install, Config, auth, HttpClient: references/python-sdk/overview.md
  • QuoteContext — all quote methods + subscriptions: references/python-sdk/quote-context.md
  • TradeContext — orders, account, executions: references/python-sdk/trade-context.md
  • Types & Enums — Period, OrderType, SubType, push types: references/python-sdk/types.md
  • 概述 — 安装、配置、身份验证、HttpClient:[references/python-sdk/overview.md]
  • QuoteContext — 所有行情方法 + 订阅功能:[references/python-sdk/quote-context.md]
  • TradeContext — 订单、账户、成交记录:[references/python-sdk/trade-context.md]
  • 类型与枚举 — Period、OrderType、SubType、推送类型:[references/python-sdk/types.md]

Rust SDK

Rust SDK

  • Overview — Cargo.toml, Config, auth, error handling: references/rust-sdk/overview.md
  • QuoteContext — all methods, SubFlags, PushEvent: references/rust-sdk/quote-context.md
  • TradeContext — orders, SubmitOrderOptions builder, account: references/rust-sdk/trade-context.md
  • Content — news, filings, topics (ContentContext + Python fallback): references/rust-sdk/content.md
  • Types & Enums — all Rust enums and structs: references/rust-sdk/types.md
  • 概述 — Cargo.toml配置、配置项、身份验证、错误处理:[references/rust-sdk/overview.md]
  • QuoteContext — 所有方法、SubFlags、PushEvent:[references/rust-sdk/quote-context.md]
  • TradeContext — 订单、SubmitOrderOptions构建器、账户:[references/rust-sdk/trade-context.md]
  • 内容服务 — 新闻、公告、专题(ContentContext + Python回退方案):[references/rust-sdk/content.md]
  • 类型与枚举 — 所有Rust枚举和结构体:[references/rust-sdk/types.md]

AI Integration

AI集成

  • MCP — hosted service, self-hosted server, setup & auth: references/mcp.md
  • LLMs & Markdown — llms.txt,
    open.longbridge.com
    doc Markdown,
    longbridge.com
    live news/quote pages (
    .md
    suffix + Accept header), Cursor/IDE integration: references/llm.md
Load specific reference files on demand — do not load all at once.
  • MCP — 托管服务、自托管服务器、设置与身份验证:[references/mcp.md]
  • LLM与Markdown — llms.txt、
    open.longbridge.com
    文档Markdown格式、
    longbridge.com
    实时新闻/行情页面(添加
    .md
    后缀 + Accept请求头)、Cursor/IDE集成:[references/llm.md]
按需加载特定参考文档——请勿一次性加载全部文档。