longbridge
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLongbridge Developers Platform
Longbridge开发者平台
Full-stack financial data and trading platform: CLI, Python/Rust SDK, MCP, and LLM integration.
Official docs: https://open.longbridge.com
llms.txt: https://open.longbridge.com/llms.txt
全栈金融数据与交易平台:包含CLI、Python/Rust SDK、MCP及LLM集成功能。
官方文档: https://open.longbridge.com
llms.txt: https://open.longbridge.com/llms.txt
First-Time Setup
首次设置
Before using any Longbridge feature, check which tools are available:
CLI — run to check. If not installed:
longbridge --versionbash
undefined在使用Longbridge的任何功能前,请确认可用工具:
CLI — 运行检查是否已安装。若未安装:
longbridge --versionbash
undefinedmacOS
macOS
brew install --cask longbridge/tap/longbridge-terminal
brew install --cask longbridge/tap/longbridge-terminal
Any platform
任意平台
Then authenticate:
```bash
longbridge loginMCP (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 loginMCP(适用于AI工具) — 如果用户想在AI聊天界面内直接查询数据或进行交易(无需编写代码),请添加托管的MCP服务器:
bash
undefinedClaude 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 APISymbol Format
代码格式
<CODE>.<MARKET>| Market | Suffix | Examples |
|---|---|---|
| Hong Kong | | |
| United States | | |
| China Shanghai | | |
| China Shenzhen | | |
| Singapore | | |
| Crypto | | |
<代码>.<市场后缀>| 市场 | 后缀 | 示例 |
|---|---|---|
| 香港 | | |
| 美国 | | |
| 中国上海 | | |
| 中国深圳 | | |
| 新加坡 | | |
| 加密货币 | | |
Authentication Overview
身份验证概述
| Method | Credential | Best for |
|---|---|---|
| OAuth 2.0 ⭐ | | CLI, SDK scripts, MCP |
| API Key | | Legacy / server-side |
OAuth token cache:
Register OAuth client: POST
~/.longbridge/openapi/tokens/<client_id>https://openapi.longbridge.com/oauth2/register| 方式 | 凭证 | 适用场景 |
|---|---|---|
| OAuth 2.0 ⭐ | 仅需 | CLI、SDK脚本、MCP |
| API密钥 | | 旧版 / 服务器端 |
OAuth令牌缓存路径:
注册OAuth客户端: POST
~/.longbridge/openapi/tokens/<client_id>https://openapi.longbridge.com/oauth2/registerRate 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 to list available commands, and for specific options and flags. Do not rely on hardcoded documentation — the CLI's built-in help is always up-to-date.
longbridge --helplongbridge <command> --help- 概述 — 安装、身份验证、输出格式、使用模式:[references/cli/overview.md]
请始终使用查看可用命令,使用获取特定选项和参数的详细信息。不要依赖硬编码的文档——CLI的内置帮助始终是最新的。
longbridge --helplongbridge <command> --helpPython 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, doc Markdown,
open.longbridge.comlive news/quote pages (longbridge.comsuffix + Accept header), Cursor/IDE integration: references/llm.md.md
Load specific reference files on demand — do not load all at once.
- MCP — 托管服务、自托管服务器、设置与身份验证:[references/mcp.md]
- LLM与Markdown — llms.txt、文档Markdown格式、
open.longbridge.com实时新闻/行情页面(添加longbridge.com后缀 + Accept请求头)、Cursor/IDE集成:[references/llm.md].md
按需加载特定参考文档——请勿一次性加载全部文档。