NexusTrader
Use the exec tool to run bridge.py. Do not write code or call external HTTP APIs directly.
bridge.py connects to a local MCP server at 127.0.0.1:18765 (SSE) — all exchange communication goes through that server.
Security Considerations
This skill accesses your exchange API keys. Before using:
- - API keys are stored in
{NEXUSTRADER_PROJECT_DIR}/.keys/.secrets.toml — a local file, never transmitted by this skill. - Auto-start is disabled by default. The skill will not start background processes unless you explicitly set
NEXUSTRADER_NO_AUTOSTART=0 in the skill's .env file. - If auto-start is enabled, the NexusTrader-mcp daemon will run in the background and hold access to your API keys.
- Start with testnet/demo keys. Only use real keys after verifying the workflow in a sandbox.
- Orders require explicit user confirmation — verify your agent flow enforces this before live trading.
- See upstream docs for key setup: https://github.com/Quantweb3-com/NexusTrader-mcp
Environment Variables
- -
NEXUSTRADER_PROJECT_DIR (optional, default: ~/NexusTrader-mcp): Location of your NexusTrader-mcp project directory. Controls where .keys/.secrets.toml is read from. - INLINECODE6 (default:
1): Set to 0 to allow bridge.py to auto-start the MCP daemon when offline. Default 1 means you must start the server manually. - INLINECODE10 (optional, default:
http://127.0.0.1:18765/sse): MCP server address if running on a non-default port.
Usage
Get all balances:
INLINECODE12
Get all positions:
INLINECODE13
Get balance for one exchange:
INLINECODE14
Get ticker:
INLINECODE15
Get klines:
INLINECODE16
Get open orders:
INLINECODE17
Get position for one symbol:
INLINECODE18
Place order (confirm first):
INLINECODE19
Cancel order (confirm first):
INLINECODE20
Symbol format: BTCUSDT-PERP.OKX / ETHUSDT-SPOT.BYBIT. Exchange names lowercase.
If exec returns {"error": ...} → explain in Chinese.
If server not running → tell user to start manually: INLINECODE24
For orders, always confirm with user before calling createorder/cancelorder/modify_order.
NexusTrader
使用 exec 工具运行 bridge.py。请勿直接编写代码或调用外部 HTTP API。
bridge.py 连接到位于 127.0.0.1:18765 (SSE) 的本地 MCP 服务器——所有交易所通信均通过该服务器进行。
安全注意事项
此技能可访问您的交易所 API 密钥。使用前请注意:
- - API 密钥存储在 {NEXUSTRADERPROJECTDIR}/.keys/.secrets.toml 中——这是一个本地文件,此技能不会传输该文件。
- 默认情况下自动启动已禁用。 除非您在技能的 .env 文件中明确设置 NEXUSTRADERNOAUTOSTART=0,否则该技能不会启动后台进程。
- 如果启用了自动启动,NexusTrader-mcp 守护进程将在后台运行并持有对您 API 密钥的访问权限。
- 请使用测试网/演示密钥开始。 仅在沙盒中验证工作流程后,再使用真实密钥。
- 订单需要明确的用户确认——请确保在实盘交易前,您的代理流程强制执行此确认。
- 有关密钥设置,请参阅上游文档:https://github.com/Quantweb3-com/NexusTrader-mcp
环境变量
- - NEXUSTRADERPROJECTDIR(可选,默认值:~/NexusTrader-mcp):您的 NexusTrader-mcp 项目目录位置。控制从何处读取 .keys/.secrets.toml。
- NEXUSTRADERNOAUTOSTART(默认值:1):设置为 0 以允许 bridge.py 在离线时自动启动 MCP 守护进程。默认值 1 表示您必须手动启动服务器。
- NEXUSTRADERMCPURL(可选,默认值:http://127.0.0.1:18765/sse):如果运行在非默认端口上的 MCP 服务器地址。
使用方法
获取所有余额:
exec {baseDir}/bridge.py getallbalances
获取所有持仓:
exec {baseDir}/bridge.py getallpositions
获取单个交易所余额:
exec {baseDir}/bridge.py get_balance --exchange=okx
获取行情:
exec {baseDir}/bridge.py get_ticker --symbol=BTCUSDT-PERP.BINANCE
获取K线:
exec {baseDir}/bridge.py get_klines --symbol=BTCUSDT-PERP.BINANCE --interval=1h --limit=24
获取未成交订单:
exec {baseDir}/bridge.py getopenorders --exchange=okx
获取单个币种持仓:
exec {baseDir}/bridge.py get_position --symbol=BTCUSDT-PERP.OKX
下单(需先确认):
exec {baseDir}/bridge.py createorder --symbol=BTCUSDT-PERP.BINANCE --side=BUY --ordertype=MARKET --amount=0.001
撤单(需先确认):
exec {baseDir}/bridge.py cancelorder --symbol=BTCUSDT-PERP.BINANCE --orderid=123
交易对格式:BTCUSDT-PERP.OKX / ETHUSDT-SPOT.BYBIT。交易所名称使用小写。
如果 exec 返回 {error: ...} → 用中文解释。
如果服务器未运行 → 告知用户手动启动:cd ~/NexusTrader-mcp && uv run nexustrader-mcp start
对于订单操作,在调用 createorder/cancelorder/modify_order 之前,务必先与用户确认。