longbridge

v1.0.2

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

2· 608·2 current·2 all-time
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
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.
Assessment
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.

Like a lobster shell, security has layers — review code before you run it.

Runtime requirements

📊 Clawdis
OSmacOS · Linux
Binspython3, uv
EnvLONGBRIDGE_APP_KEY, LONGBRIDGE_APP_SECRET, LONGBRIDGE_ACCESS_TOKEN
latestvk977v9crcq5s1t9ynqctnzq7nx83vpns
608downloads
2stars
3versions
Updated 3w ago
v1.0.2
MIT-0
macOS, Linux

长桥 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 <名称> 加载 .<名称>.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 异常会输出友好提示,不暴露原始堆栈

Comments

Loading comments...