← Back to Skills Marketplace
frankxiong

longbridge

by FrankXiong · GitHub ↗ · v1.0.2 · MIT-0
darwinlinux ✓ Security Clean
652
Downloads
2
Stars
2
Active Installs
3
Versions
Install in OpenClaw
/install longbridge-kit
Description
长桥 LongPort OpenAPI CLI 工具,提供股票行情查询、账户持仓、订单管理、市场数据四大功能。 当用户提到"长桥"、"LongPort"、"longbridge",或要求查看股票报价、实时行情、K线、盘口、 逐笔成交、账户余额、持仓、基金持仓、下单、买入、卖出、撤单、今日订单、历史订单、 资金流向...
README (SKILL.md)

长桥 OpenAPI CLI 工具

通过 longbridge CLI 命令调用长桥 OpenAPI,覆盖行情查询、账户持仓、订单管理、市场数据四大模块。

前置条件

环境变量

需设置以下环境变量(可在 ~/.zshrc~/.bashrc 中配置):

export LONGBRIDGE_APP_KEY="your_app_key"
export LONGBRIDGE_APP_SECRET="your_app_secret"
export LONGBRIDGE_ACCESS_TOKEN="your_access_token"

# 可选:开启交易权限(默认只读,禁止 buy/sell/cancel)
# export LONGBRIDGE_TRADE_ENABLED=false

也可以在当前目录或主目录创建 .env 文件(系统环境变量优先级更高,不会被 .env 覆盖)。

多账户切换:使用 --profile \x3C名称> 加载 .\x3C名称>.env 文件,例如:

longbridge --profile paper balance   # 加载 .paper.env
longbridge --profile live positions  # 加载 .live.env

安装

先检测是否已安装:

which longbridge
  • 若输出路径(如 /Users/xxx/.local/bin/longbridge),说明已安装,跳过安装步骤。
  • 若未找到,从本 skill 目录安装(SKILL_DIR 为本文件所在目录):
uv tool install "$SKILL_DIR"

验证安装:

longbridge --help

使用方式

所有命令均支持 --json 选项输出 JSON 格式。

行情模块

# 实时报价(支持多个标的)
longbridge quote AAPL.US 700.HK
longbridge quote AAPL.US --json

# 盘口(买5卖5)
longbridge depth 700.HK

# 逐笔成交
longbridge trades 700.HK --count 20

# K 线(period 可选:1m 5m 15m 30m 60m day week month quarter year)
longbridge candlesticks AAPL.US day --count 30
longbridge candlesticks 700.HK 60m --count 100

# 标的静态信息
longbridge info 700.HK AAPL.US

账户模块

# 账户余额与净资产
longbridge balance

# 股票持仓
longbridge positions
longbridge positions --json

# 基金持仓
longbridge funds

订单模块

# 今日订单(只读,无需交易权限)
longbridge orders

# 历史订单(只读,无需交易权限)
longbridge history-orders --start 2026-01-01 --end 2026-03-14

# 以下命令需设置 LONGBRIDGE_TRADE_ENABLED=true

# 限价买入(会有确认提示,防止误操作)
longbridge buy AAPL.US --qty 100 --price 180.0

# 限价卖出(会有确认提示)
longbridge sell 700.HK --qty 500 --price 320.0

# 撤销订单(会有确认提示)
longbridge cancel 701234567890

# 跳过确认提示(AI Agent 程序化调用时推荐加 --yes)
longbridge buy AAPL.US --qty 100 --price 180.0 --yes
longbridge sell 700.HK --qty 500 --price 320.0 -y

市场数据模块

# 市场温度(US/HK/CN/SG)
longbridge temperature US
longbridge temperature HK

# 资金流向
longbridge capital-flow 700.HK

# 资金分布(大单/中单/小单)
longbridge capital-dist 700.HK

# 期权链到期日列表
longbridge option-chain AAPL.US

注意事项

  • 下单/撤单命令buysellcancel 均有确认提示,确认后才会执行,防止误操作。AI Agent 程序化调用时请加 --yes-y 跳过确认
  • 港股代码格式:使用 4 位 + .HK 后缀,如 0700.HK9988.HK
  • 美股代码格式:使用股票代码 + .US 后缀,如 AAPL.USNVDA.US
  • JSON 输出:所有命令加 --json 可输出机器可读的 JSON 格式,便于 AI 解析
  • 错误处理:SDK 异常会输出友好提示,不暴露原始堆栈
Usage Guidance
This skill appears to be a legitimate LongPort (长桥) CLI wrapper: it needs your LongPort API credentials and will use them to call the LongPort Python SDK. Before installing, confirm you obtained those credentials from the official LongPort site. Note the SKILL.md tells you to run 'uv tool install "$SKILL_DIR"' to install the included Python package and dependencies from PyPI — verify you trust the 'uv' installer and that the PyPI package 'longbridge' is legitimate. Trading commands are disabled by default (LONGBRIDGE_TRADE_ENABLED must be set to true) and the CLI prompts for confirmation; when automating, be careful with the --yes flag because it will skip confirmations and submit real orders. Finally, there is a minor metadata inconsistency: the registry lists no install spec while the skill bundle contains code and packaging files — this is not a security red flag by itself but worth noting.
Capability Analysis
Type: OpenClaw Skill Name: longbridge-kit Version: 1.0.2 The longbridge-kit is a legitimate CLI tool and OpenClaw skill for interacting with the Longbridge OpenAPI. It provides comprehensive functionality for market data, account management, and trading, with clear documentation in SKILL.md and README.md. The implementation includes appropriate safety measures, such as a default read-only mode (requiring an explicit environment variable to enable trading) and interactive confirmation prompts for orders, which are standard for financial tools. No evidence of malicious intent, data exfiltration, or harmful prompt injection was found across the codebase (e.g., cli.py, config.py, order.py).
Capability Assessment
Purpose & Capability
Name/description (market quotes, account, orders, market data) align with the included Python CLI code and the LongPort SDK usage. Requested env vars (LONGBRIDGE_APP_KEY, LONGBRIDGE_APP_SECRET, LONGBRIDGE_ACCESS_TOKEN) match the documented API auth requirements.
Instruction Scope
SKILL.md instructs the agent to load .env files, set environment variables, install/run the CLI, and run specific longbridge commands. The instructions only access .env files in the current/home directory and the declared env vars; they do not instruct reading unrelated system files or sending data to unexpected external endpoints.
Install Mechanism
No formal install spec is declared in registry metadata, but SKILL.md instructs using the local 'uv tool install "$SKILL_DIR"' to install the package and the bundle includes pyproject/requirements. Dependencies (longbridge, click, rich) are standard PyPI packages. This is reasonable but the absence of a registry install spec while shipping package files is an inconsistency to be aware of.
Credentials
Only LongPort-related credentials and an optional LONGBRIDGE_TRADE_ENABLED flag are requested. The number and type of env vars are proportional to a trading/quote CLI. No unrelated secrets or cloud credentials are requested.
Persistence & Privilege
Skill is not marked always:true and does not request elevated system-wide privileges. It may be installed into the user's environment via the uv tool (per SKILL.md), which is expected for a CLI package; it does not modify other skills or global agent settings.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install longbridge-kit
  3. After installation, invoke the skill by name or use /longbridge-kit
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.2
- Added support for loading configuration from a .env file in the current or home directory (system environment variables take precedence). - Introduced multi-account switching via the --profile option to load different .env files (e.g., .paper.env, .live.env). - Added option to skip trade command confirmations with --yes or -y, enabling safer use for programmatic/AI agent workflows. - Maintenance: Removed requirements.txt file from package root and moved dependencies to standard requirements.txt location. - Updated documentation with usage details for new features and recommendations for programmatic access.
v1.0.1
- Initial public release of the longbridge CLI tool (v1.0.1) - Provides commands for real-time stock quotes, account balance, holdings, market data, and order management (including buy/sell/cancel with confirmation) - Supports output in both human-readable and JSON formats via the --json option - Requires setup of environment variables for API authentication - Installation guidance and enhanced skill matching for Chinese and English user intents (e.g. "长桥", "LongPort", "看看苹果股价", "我的持仓怎么样")
v1.0.0
Initial release of longbridge-cli, a CLI tool for Longbridge OpenAPI. - Provides command-line access to market data, account balance, positions, and order management. - Supports real-time quotes, order book, trades, candlestick charts, static symbol info, and market temperature. - Enables querying account balances, holdings (stock/fund), and order details. - Includes functions to place/cancel orders with safety confirmation and optional trading permission. - All commands support JSON output for easy integration and parsing. - Installation and environment setup instructions provided.
Metadata
Slug longbridge-kit
Version 1.0.2
License MIT-0
All-time Installs 2
Active Installs 2
Total Versions 3
Frequently Asked Questions

What is longbridge?

长桥 LongPort OpenAPI CLI 工具,提供股票行情查询、账户持仓、订单管理、市场数据四大功能。 当用户提到"长桥"、"LongPort"、"longbridge",或要求查看股票报价、实时行情、K线、盘口、 逐笔成交、账户余额、持仓、基金持仓、下单、买入、卖出、撤单、今日订单、历史订单、 资金流向... It is an AI Agent Skill for Claude Code / OpenClaw, with 652 downloads so far.

How do I install longbridge?

Run "/install longbridge-kit" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is longbridge free?

Yes, longbridge is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does longbridge support?

longbridge is cross-platform and runs anywhere OpenClaw / Claude Code is available (darwin, linux).

Who created longbridge?

It is built and maintained by FrankXiong (@frankxiong); the current version is v1.0.2.

💬 Comments