闲社服务运行正常AI智能体自动化平台
c

cTrader指令管理

技能标识:ctrader-commander

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.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.0
检测标记
后台标记通过
免费
免费获取
2
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

cTrader指令管理

cTrader Commander

当用户希望在cTrader账户上执行交易、查看持仓或余额、获取实时价格、获取K线数据或管理订单时使用。

所有请求发送至 http://localhost:9009 — 凭证存储在服务器的 .env 文件中,调用方无需传递。

代理仓库: https://github.com/LogicalSapien/ctrader-openapi-proxy
克隆仓库,添加您的 .env 文件,运行 make run 启动代理后再使用此技能。

完整参考文档:{baseDir}/endpoints.md

检查代理是否运行

bash
curl -s http://localhost:9009/get-data?command=ProtoOAVersionReq

如果失败,启动代理:cd ~/ctrader-openapi-proxy && make run

查找品种ID(请先执行此步骤)

品种ID因经纪商而异 — 在下单或获取数据前请先查询:

bash
curl -s http://localhost:9009/get-data?command=ProtoOASymbolsListReq

返回包含 symbolId 和 symbolName 的 symbol[] 数组。记录您所需品种的ID。

市价单

bash
curl -s -X POST http://localhost:9009/api/market-order \
-H Content-Type: application/json \
-d {symbolId: 158, orderType: MARKET, tradeSide: BUY, volume: 1000}

交易量单位为单位:1000 = 0.01手 · 10000 = 0.1手 · 100000 = 1手。
可添加 relativeStopLoss: 200, relativeTakeProfit: 350(点数,仅限市价单)。

限价单或止损单

bash
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

获取OHLC K线数据

bash
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\: $FROMMS, \toTimestamp\: $NOWMS, \period\: \M5\, \symbolId\: 158}

周期:M1 M2 M3 M4 M5 M10 M15 M30 H1 H4 H12 D1 W1 MN1

获取实时报价(Tick数据)

bash
curl -s -X POST http://localhost:9009/api/live-quote \
-H Content-Type: application/json \
-d {symbolId: 158, quoteType: BID, timeDeltaInSeconds: 60}

quoteType:BID 或 ASK

查看持仓和挂单

bash
curl -s http://localhost:9009/get-data?command=ProtoOAReconcileReq

平仓

bash
curl -s http://localhost:9009/get-data?command=ClosePosition%20123456%201000

ClosePosition

取消挂单

bash
curl -s http://localhost:9009/get-data?command=CancelOrder%20789

账户信息(余额、净值、杠杆)

bash
curl -s http://localhost:9009/get-data?command=ProtoOATraderReq

一个本地HTTP代理(localhost:9009),封装了cTrader OpenAPI Protobuf连接,并以REST API形式暴露。调用时无需传递凭证 — 凭证从服务器的 .env 文件中加载。

完整端点参考:{baseDir}/endpoints.md
Python使用示例:{baseDir}/examples.md



前置条件

代理必须在所有调用前运行。如不确定,请检查:
bash
curl -s http://localhost:9009/get-data?command=ProtoOAVersionReq

如果返回JSON,则代理已运行。如果失败,请启动代理:
bash
cd ~/ctrader-openapi-proxy && make run



重要提示:品种ID因经纪商而异

在下单或获取K线/Tick数据前,请务必查询品种ID。
不同经纪商之间以及模拟账户和真实账户之间的品种ID均不相同。

bash
curl -s http://localhost:9009/get-data?command=ProtoOASymbolsListReq

响应包含带有 symbolId 和 symbolName 的 symbol[] 数组。找到您的品种并记录其 symbolId。



端点

获取OHLC K线数据

POST /api/trendbars

json
{
fromTimestamp: 1700000000000,
toTimestamp: 1700086400000,
period: M5,
symbolId: 158
}

period 选项:M1 M2 M3 M4 M5 M10 M15 M30 H1 H4 H12 D1 W1 MN1

获取当前时间毫秒数(macOS):
bash
NOW_MS=$(python3 -c import time; print(int(time.time()*1000)))
FROM_MS=$(python3 -c import time; print(int(time.time()*1000) - 3600000))



获取实时报价 / Tick数据

POST /api/live-quote

json
{
symbolId: 158,
quoteType: BID,
timeDeltaInSeconds: 60
}

quoteType:BID 或 ASK



下市价单 / 限价单 / 止损单

POST /api/market-order

json
{
symbolId: 158,
orderType: MARKET,
tradeSide: BUY,
volume: 1000,
comment: my trade,
relativeStopLoss: 200,
relativeTakeProfit: 350
}

orderType 值:MARKET LIMIT STOP
tradeSide 值:BUY SELL

对于 LIMIT 和 STOP 订单,需包含 price: 0.62500。
relativeStopLoss / relativeTakeProfit 以点数为单位,仅适用于 MARKET 订单。

交易量单位(非手数):

volume手数说明
10000.01微型手 — 典型最小单位
10000
0.1 | 迷你手 |
| 100000 | 1 | 标准手 |


获取持仓和挂单

GET /get-data?command=ProtoOAReconcileReq

返回 position[] 和 order[]。每个持仓包含 positionId、symbolId、tradeSide、volume、price。



平仓

GET /get-data?command=ClosePosition

示例 — 平仓123456,1000单位(0.01手):
bash
curl -s http://localhost:9009/get-data?command=ClosePosition%20123456%201000



取消挂单

GET /get-data?command=CancelOrder

bash
curl -s http://localhost:9009/get-data?command=CancelOrder%20789



设置活动账户 (可选)


启动时从 .env 自动授权账户。仅在运行时切换账户时调用:
bash
curl -s -X POST http://localhost:9009/api/set-account

要切换到其他账户,请传递 {accountId: 12345678} 作为JSON请求体。



通用命令透传


任何cTrader API命令均可通过以下方式调用:

GET /get-data?command=COMMAND_NAME arg1 arg2

无需令牌 — 凭证从服务器的 .env 文件中读取。

支持的命令完整列表:

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 ctrader-commander-1776300097 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 ctrader-commander-1776300097 技能

通过命令行安装

skillhub install ctrader-commander-1776300097

下载

⬇ 下载 ctrader-commander v1.0.0(免费)

文件大小: 5.21 KB | 发布时间: 2026-4-16 17:24

v1.0.0 最新 2026-4-16 17:24
Initial release. Place market, limit, and stop orders on cTrader via a local HTTP proxy. Supports live quotes, OHLC candles, open positions, close position, cancel order, and account info. No credentials passed at call time — all auth from server .env.
返回顶部