简介
通过本地代理安全连接cTrader,无需传递凭证即可执行交易、查看持仓、获取实时行情与历史K线数据
原始描述
Place and manage cTrader orders (market, limit, stop), check open positions, fetch live quotes and OHLC candles, and query account balance and equity via a l...
通过你的 Agent 添加
安装目录:ctrader-commander/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
cTrader Commander 是一个将 cTrader OpenAPI Protobuf 协议封装为 REST API 的本地代理工具,运行在 localhost:9009。用户无需在每次调用时传递凭证,账号信息由服务器端 .env 文件管理,降低了凭证泄露风险。
主要功能
功能
端点
说明
市价/限价/止损订单
POST /api/market-order
支持 BUY/SELL,volume 以 units 计(1000 = 0.01 lot)
获取K线数据
POST /api/trendbars
支持 M1 到 MN1 多周期
实时报价
POST /api/live-quote
BID/ASK 快照数据
持仓与订单查询
GET /get-data?command=ProtoOAReconcileReq
返回当前 positions 和 pending orders
平仓/撤单
GET /get-data?command=ClosePosition/CancelOrder
按 positionId/orderId 操作
账户信息
GET /get-data?command=ProtoOATraderReq
余额、净值、杠杆等
使用前必须步骤
- 克隆并启动代理:
cd ~/ctrader-openapi-proxy && make run
- 查询 symbol ID(券商特定):
ProtoOASymbolsListReq
显著优点
- 凭证隔离:交易凭证仅存于服务器
.env,调用方零接触
- 零配置调用:HTTP + JSON 接口,无需处理 Protobuf 复杂性
- 多周期数据:内置 OHLC 历史数据与实时 tick 数据
- 轻量部署:单一代码库,Makefile 一键启动
潜在缺点与局限性
- 本地依赖:必须预先部署并维护代理进程,进程宕机则全部中断
- 无内置重连:网络波动可能导致连接中断需手动重启
- Symbol ID 碎片化:同一品种在不同券商/账户间 ID 不同,需动态查询
- volume 单位易混淆:使用 units 而非标准 lots,新手易下错单量
- 无内置风控:止损止盈仅支持相对点数,无保证金检查或爆仓预警
适合人群
- 已有 cTrader 账户,希望用脚本/自动化工具管理交易的量化交易者
- 需要历史数据回测或实时数据接入的开发者
- 熟悉 Docker/本地服务部署的技术用户
常规风险
- 代理单点故障:本地进程 crash 会导致交易指令丢失或状态不一致
- 误操作风险:市价单立即成交,volume 单位错误可能导致超量开仓
- 网络延迟:本地代理到 cTrader 服务器的延迟仍受网络环境影响
- 无审计日志:需自行在代理层或应用层实现交易记录持久化
- 券商限制:频繁 API 调用可能触发券商 rate limit 或风控规则
| 功能 | 端点 | 说明 |
|---|---|---|
| 市价/限价/止损订单 | POST /api/market-order |
支持 BUY/SELL,volume 以 units 计(1000 = 0.01 lot) |
| 获取K线数据 | POST /api/trendbars |
支持 M1 到 MN1 多周期 |
| 实时报价 | POST /api/live-quote |
BID/ASK 快照数据 |
| 持仓与订单查询 | GET /get-data?command=ProtoOAReconcileReq |
返回当前 positions 和 pending orders |
| 平仓/撤单 | GET /get-data?command=ClosePosition/CancelOrder |
按 positionId/orderId 操作 |
| 账户信息 | GET /get-data?command=ProtoOATraderReq |
余额、净值、杠杆等 |
- 克隆并启动代理:
cd ~/ctrader-openapi-proxy && make run - 查询 symbol ID(券商特定):
ProtoOASymbolsListReq
显著优点
- 凭证隔离:交易凭证仅存于服务器
.env,调用方零接触
- 零配置调用:HTTP + JSON 接口,无需处理 Protobuf 复杂性
- 多周期数据:内置 OHLC 历史数据与实时 tick 数据
- 轻量部署:单一代码库,Makefile 一键启动
潜在缺点与局限性
- 本地依赖:必须预先部署并维护代理进程,进程宕机则全部中断
- 无内置重连:网络波动可能导致连接中断需手动重启
- Symbol ID 碎片化:同一品种在不同券商/账户间 ID 不同,需动态查询
- volume 单位易混淆:使用 units 而非标准 lots,新手易下错单量
- 无内置风控:止损止盈仅支持相对点数,无保证金检查或爆仓预警
适合人群
- 已有 cTrader 账户,希望用脚本/自动化工具管理交易的量化交易者
- 需要历史数据回测或实时数据接入的开发者
- 熟悉 Docker/本地服务部署的技术用户
常规风险
- 代理单点故障:本地进程 crash 会导致交易指令丢失或状态不一致
- 误操作风险:市价单立即成交,volume 单位错误可能导致超量开仓
- 网络延迟:本地代理到 cTrader 服务器的延迟仍受网络环境影响
- 无审计日志:需自行在代理层或应用层实现交易记录持久化
- 券商限制:频繁 API 调用可能触发券商 rate limit 或风控规则
.env,调用方零接触- 本地依赖:必须预先部署并维护代理进程,进程宕机则全部中断
- 无内置重连:网络波动可能导致连接中断需手动重启
- Symbol ID 碎片化:同一品种在不同券商/账户间 ID 不同,需动态查询
- volume 单位易混淆:使用 units 而非标准 lots,新手易下错单量
- 无内置风控:止损止盈仅支持相对点数,无保证金检查或爆仓预警
适合人群
- 已有 cTrader 账户,希望用脚本/自动化工具管理交易的量化交易者
- 需要历史数据回测或实时数据接入的开发者
- 熟悉 Docker/本地服务部署的技术用户
常规风险
- 代理单点故障:本地进程 crash 会导致交易指令丢失或状态不一致
- 误操作风险:市价单立即成交,volume 单位错误可能导致超量开仓
- 网络延迟:本地代理到 cTrader 服务器的延迟仍受网络环境影响
- 无审计日志:需自行在代理层或应用层实现交易记录持久化
- 券商限制:频繁 API 调用可能触发券商 rate limit 或风控规则
- 代理单点故障:本地进程 crash 会导致交易指令丢失或状态不一致
- 误操作风险:市价单立即成交,volume 单位错误可能导致超量开仓
- 网络延迟:本地代理到 cTrader 服务器的延迟仍受网络环境影响
- 无审计日志:需自行在代理层或应用层实现交易记录持久化
- 券商限制:频繁 API 调用可能触发券商 rate limit 或风控规则
技能正文
name: ctrader-commander
description: Place and manage cTrader orders (market, limit, stop), check open positions, fetch live quotes and OHLC candles, and query account balance and equity via a local HTTP proxy. No credentials or token required at call time.
homepage: https://github.com/LogicalSapien/ctrader-openapi-proxy
metadata: {"openclaw": {"emoji": "\ud83d\udcc8", "requires": {"bins": ["curl"]}, "homepage": "https://github.com/LogicalSapien/ctrader-openapi-proxy"}}
cTrader Commander
Use when the user wants to place trades, check positions or balance, get live prices, fetch candles, or manage orders on a cTrader account.
All calls go to http://localhost:9009 — credentials live in .env on the server, never passed by callers.
Proxy repo: https://github.com/LogicalSapien/ctrader-openapi-proxy Clone it, add your
.env, and runmake runto start the proxy before using this skill.
Full reference: {baseDir}/endpoints.md
Check proxy is running
curl -s "http://localhost:9009/get-data?command=ProtoOAVersionReq"
curl -s "http://localhost:9009/get-data?command=ProtoOAVersionReq"
If it fails, start the proxy: cd ~/ctrader-openapi-proxy && make run
Find symbol IDs (do this first)
Symbol IDs are broker-specific — look them up before placing orders or fetching data:
curl -s "http://localhost:9009/get-data?command=ProtoOASymbolsListReq"
Returns symbol[] with symbolId and symbolName. Note the ID for your instrument.
Place a market order
curl -s -X POST http://localhost:9009/api/market-order \
-H "Content-Type: application/json" \
-d '{"symbolId": 158, "orderType": "MARKET", "tradeSide": "BUY", "volume": 1000}'
curl -s -X POST http://localhost:9009/api/market-order \
-H "Content-Type: application/json" \
-d '{"symbolId": 158, "orderType": "MARKET", "tradeSide": "BUY", "volume": 1000}'
Volume is in units: 1000 = 0.01 lot · 10000 = 0.1 lot · 100000 = 1 lot.
Add "relativeStopLoss": 200, "relativeTakeProfit": 350 (pips, market orders only).
Place a limit or stop order
curl -s -X POST http://localhost:9009/api/market-order \
-H "Content-Type: application/json" \
-d '{"symbolId": 158, "orderType": "LIMIT", "tradeSide": "BUY", "volume": 1000, "price": 0.62500}'
curl -s -X POST http://localhost:9009/api/market-order \
-H "Content-Type: application/json" \
-d '{"symbolId": 158, "orderType": "LIMIT", "tradeSide": "BUY", "volume": 1000, "price": 0.62500}'
orderType: MARKET · LIMIT · STOP — tradeSide: BUY · SELL
Get OHLC candles
NOW_MS=$(python3 -c "import time; print(int(time.time()*1000))")
FROM_MS=$(python3 -c "import time; print(int(time.time()*1000) - 3600000)")
curl -s -X POST http://localhost:9009/api/trendbars \
-H "Content-Type: application/json" \
-d "{\"fromTimestamp\": $FROM_MS, \"toTimestamp\": $NOW_MS, \"period\": \"M5\", \"symbolId\": 158}"
NOW_MS=$(python3 -c "import time; print(int(time.time()*1000))")
FROM_MS=$(python3 -c "import time; print(int(time.time()*1000) - 3600000)")
curl -s -X POST http://localhost:9009/api/trendbars \
-H "Content-Type: application/json" \
-d "{\"fromTimestamp\": $FROM_MS, \"toTimestamp\": $NOW_MS, \"period\": \"M5\", \"symbolId\": 158}"
Periods: M1 M2 M3 M4 M5 M10 M15 M30 H1 H4 H12 D1 W1 MN1
Get live quote (tick data)
curl -s -X POST http://localhost:9009/api/live-quote \
-H "Content-Type: application/json" \
-d '{"symbolId": 158, "quoteType": "BID", "timeDeltaInSeconds": 60}'
curl -s -X POST http://localhost:9009/api/live-quote \
-H "Content-Type: application/json" \
-d '{"symbolId": 158, "quoteType": "BID", "timeDeltaInSeconds": 60}'
quoteType: BID or ASK
Open positions and pending orders
curl -s "http://localhost:9009/get-data?command=ProtoOAReconcileReq"
Close a position
curl -s "http://localhost:9009/get-data?command=ClosePosition%20123456%201000"
# ClosePosition <positionId> <volumeInUnits>
Cancel a pending order
curl -s "http://localhost:9009/get-data?command=CancelOrder%20789"
Account info (balance, equity, leverage)
curl -s "http://localhost:9009/get-data?command=ProtoOATraderReq"
curl -s "http://localhost:9009/get-data?command=ProtoOAReconcileReq"
curl -s "http://localhost:9009/get-data?command=ClosePosition%20123456%201000"
# ClosePosition <positionId> <volumeInUnits>
Cancel a pending order
curl -s "http://localhost:9009/get-data?command=CancelOrder%20789"
Account info (balance, equity, leverage)
curl -s "http://localhost:9009/get-data?command=ProtoOATraderReq"
curl -s "http://localhost:9009/get-data?command=CancelOrder%20789"
curl -s "http://localhost:9009/get-data?command=ProtoOATraderReq"
A local HTTP proxy (localhost:9009) that wraps the cTrader OpenAPI Protobuf connection and exposes it as a REST API. No credentials are passed at call time — they are loaded from .env on the server.
Full endpoint reference: {baseDir}/endpoints.md
Python usage examples: {baseDir}/examples.md
Prerequisites
The proxy must be running before any call. If unsure, check:
curl -s "http://localhost:9009/get-data?command=ProtoOAVersionReq"
If it returns JSON, the proxy is up. If it fails, start it:
cd ~/ctrader-openapi-proxy && make run
IMPORTANT: Symbol IDs are broker-specific
Always look up the symbol ID before placing orders or fetching candle/tick data. Symbol IDs differ between brokers and between demo and live accounts.
curl -s "http://localhost:9009/get-data?command=ProtoOASymbolsListReq"
Response contains symbol[] with symbolId and symbolName. Find your instrument and note its symbolId.
Endpoints
Get OHLC Candles
POST /api/trendbars
{
"fromTimestamp": 1700000000000,
"toTimestamp": 1700086400000,
"period": "M5",
"symbolId": 158
}
period options: M1 M2 M3 M4 M5 M10 M15 M30 H1 H4 H12 D1 W1 MN1
For current time in ms (macOS):
NOW_MS=$(python3 -c "import time; print(int(time.time()*1000))")
FROM_MS=$(python3 -c "import time; print(int(time.time()*1000) - 3600000)")
Get Live Quote / Tick Data
POST /api/live-quote
{
"symbolId": 158,
"quoteType": "BID",
"timeDeltaInSeconds": 60
}
POST /api/live-quote
{
"symbolId": 158,
"quoteType": "BID",
"timeDeltaInSeconds": 60
}
quoteType: "BID" or "ASK"
Place a Market / Limit / Stop Order
POST /api/market-order
{
"symbolId": 158,
"orderType": "MARKET",
"tradeSide": "BUY",
"volume": 1000,
"comment": "my trade",
"relativeStopLoss": 200,
"relativeTakeProfit": 350
}
POST /api/market-order
{
"symbolId": 158,
"orderType": "MARKET",
"tradeSide": "BUY",
"volume": 1000,
"comment": "my trade",
"relativeStopLoss": 200,
"relativeTakeProfit": 350
}
orderType values: "MARKET" "LIMIT" "STOP"
tradeSide values: "BUY" "SELL"
For LIMIT and STOP orders, include "price": 0.62500.
relativeStopLoss / relativeTakeProfit are in pips and apply to MARKET orders only.
Volume units (NOT lots):
volume |
Lots | Notes |
|---|---|---|
1000 |
0.01 | Micro lot — typical minimum |
10000 |
0.1 | Mini lot |
100000 |
1 | Standard lot |
Get Open Positions and Pending Orders
GET /get-data?command=ProtoOAReconcileReq
GET /get-data?command=ProtoOAReconcileReq
Returns position[] and order[]. Each position has positionId, symbolId, tradeSide, volume, price.
Close an Open Position
GET /get-data?command=ClosePosition <positionId> <volumeInUnits>
GET /get-data?command=ClosePosition <positionId> <volumeInUnits>
Example — close position 123456 with 1000 units (0.01 lot):
curl -s "http://localhost:9009/get-data?command=ClosePosition%20123456%201000"
Cancel a Pending Order
GET /get-data?command=CancelOrder <orderId>
curl -s "http://localhost:9009/get-data?command=CancelOrder%20789"
Set Active Account (optional)
GET /get-data?command=CancelOrder <orderId>
curl -s "http://localhost:9009/get-data?command=CancelOrder%20789"
Account is auto-authorised from .env on startup. Only call this to switch accounts at runtime:
curl -s -X POST http://localhost:9009/api/set-account
To switch to a different account pass {"accountId": 12345678} as JSON body.
Generic Command Passthrough
Any cTrader API command can be called via:
GET /get-data?command=COMMAND_NAME arg1 arg2
No token required — credentials are read from .env on the server.
Full list of supported commands: {baseDir}/endpoints.md
Workflow: first trade
- Look up your symbol ID:
curl -s "http://localhost:9009/get-data?command=ProtoOASymbolsListReq" | python3 -c "
import sys, json
data = json.load(sys.stdin)
[print(s['symbolId'], s['symbolName']) for s in data.get('symbol', []) if 'EURUSD' in s['symbolName']]
"
- Check your account details:
curl -s "http://localhost:9009/get-data?command=ProtoOATraderReq"
- Place a market buy:
curl -s -X POST http://localhost:9009/api/market-order \
-H "Content-Type: application/json" \
-d '{"symbolId": 1, "orderType": "MARKET", "tradeSide": "BUY", "volume": 1000}'
- Check open positions:
curl -s "http://localhost:9009/get-data?command=ProtoOAReconcileReq"
curl -s "http://localhost:9009/get-data?command=ProtoOASymbolsListReq" | python3 -c "
import sys, json
data = json.load(sys.stdin)
[print(s['symbolId'], s['symbolName']) for s in data.get('symbol', []) if 'EURUSD' in s['symbolName']]
"
curl -s "http://localhost:9009/get-data?command=ProtoOATraderReq"
curl -s -X POST http://localhost:9009/api/market-order \
-H "Content-Type: application/json" \
-d '{"symbolId": 1, "orderType": "MARKET", "tradeSide": "BUY", "volume": 1000}'
curl -s "http://localhost:9009/get-data?command=ProtoOAReconcileReq"
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。