mit einem Klick
openclaw-jin-ce-zhi-suan-orchestrator
// 通过金策智算HTTP接口执行回测/实盘编排与监控。用户要求启动任务、查进度、停止任务、切换策略/数据源、查询报告时必须调用。
// 通过金策智算HTTP接口执行回测/实盘编排与监控。用户要求启动任务、查进度、停止任务、切换策略/数据源、查询报告时必须调用。
| name | openclaw-jin-ce-zhi-suan-orchestrator |
| description | 通过金策智算HTTP接口执行回测/实盘编排与监控。用户要求启动任务、查进度、停止任务、切换策略/数据源、查询报告时必须调用。 |
本技能用于编排 http://127.0.0.1:8000 的金策智算服务,统一完成:
当用户提出以上任何需求时,必须使用本技能,不要直接调用未登记接口。
金策智算项目具备以下核心能力:
report_id 精确获取、历史列表、最新结果progress.progress、progress.current_date 监控回测推进注意:回测耗时会明显受以下因素影响,时长波动属于正常现象:
http://127.0.0.1:8000Content-Type: application/jsonYYYY-MM-DDreport_id 全链路必须按字符串处理GET /api/status用途:查询当前任务状态与进度。
关键字段:
is_runningprogress.progressprogress.current_datecurrent_report_idcurrent_report_statuscurrent_report_errorprovider_sourcelive_enabled示例:
curl -s http://127.0.0.1:8000/api/status
POST /api/control/start_backtest用途:启动回测任务。
请求体:
stock_code:string,例 301227.SZstrategy_id:string,all 或单策略strategy_ids:string[],可选strategy_mode:string,可选start:string,可选,YYYY-MM-DDend:string,可选,YYYY-MM-DDcapital:number,可选示例:
curl -s -X POST http://127.0.0.1:8000/api/control/start_backtest \
-H "Content-Type: application/json" \
-d "{\"stock_code\":\"301227.SZ\",\"strategy_id\":\"all\",\"start\":\"2025-03-20\",\"end\":\"2026-03-20\",\"capital\":1000000}"
POST /api/control/start_live用途:启动实盘监控任务。
示例:
curl -s -X POST http://127.0.0.1:8000/api/control/start_live \
-H "Content-Type: application/json" \
-d "{\"stock_code\":\"301227.SZ\"}"
POST /api/control/stop用途:停止当前运行任务(回测或实盘)。
示例:
curl -s -X POST http://127.0.0.1:8000/api/control/stop
POST /api/control/switch_strategy用途:运行时切换策略。
示例(单策略):
curl -s -X POST http://127.0.0.1:8000/api/control/switch_strategy \
-H "Content-Type: application/json" \
-d "{\"strategy_id\":\"01\"}"
示例(多策略):
curl -s -X POST http://127.0.0.1:8000/api/control/switch_strategy \
-H "Content-Type: application/json" \
-d "{\"strategy_ids\":[\"01\",\"05\",\"09\"]}"
POST /api/control/set_source用途:切换数据源(default / tushare / akshare)。
示例:
curl -s -X POST http://127.0.0.1:8000/api/control/set_source \
-H "Content-Type: application/json" \
-d "{\"source\":\"tushare\"}"
POST /api/control/reload_strategies用途:热重载策略实现。
示例:
curl -s -X POST http://127.0.0.1:8000/api/control/reload_strategies
GET /api/report/{report_id}用途:查询指定报告详情。
示例:
curl -s http://127.0.0.1:8000/api/report/1742400000000-ab12
GET /api/report/history用途:查询历史报告列表。
示例:
curl -s http://127.0.0.1:8000/api/report/history
GET /api/report/latest用途:查询最新报告。
示例:
curl -s http://127.0.0.1:8000/api/report/latest
POST /api/report/{report_id}/ai_review用途:触发指定报告的 AI 复盘。
示例:
curl -s -X POST http://127.0.0.1:8000/api/report/1742400000000-ab12/ai_review
GET /api/strategies用途:获取当前可加载策略的基础列表(策略ID、策略名)。
适用场景:
示例:
curl -s http://127.0.0.1:8000/api/strategies
GET /api/strategy_manager/list用途:获取策略管理器明细列表(含策略元信息、启用状态、来源、K线周期、评分字段)。
关键返回(示例字段):
id、name、enabled、source、kline_typeanalysis_text、template_textscore_total、rating、score_total_adjustedscore_confidence、score_backtest_countscore_annualized_roi_avg、score_max_dd_avg、score_trades_avg适用场景:
示例:
curl -s http://127.0.0.1:8000/api/strategy_manager/list
GET /api/strategy_manager/detail?strategy_id=01用途:直接获取单个策略详情(含策略元信息与评分字段),用于策略介绍、策略单卡详情、策略定位排障。
请求参数:
strategy_id:必填,策略ID示例:
curl -s "http://127.0.0.1:8000/api/strategy_manager/detail?strategy_id=01"
POST /api/strategy_manager/analyze:基于自然语言需求生成策略介绍、意图解释与代码POST /api/strategy_manager/analyze_market:基于市场状态生成策略介绍、意图解释与代码示例(自然语言):
curl -s -X POST http://127.0.0.1:8000/api/strategy_manager/analyze \
-H "Content-Type: application/json" \
-d "{\"template_text\":\"趋势+回撤控制,偏稳健\",\"strategy_name\":\"稳健趋势策略\"}"
POST /api/strategy_manager/add:新增策略(通常接 analyze 结果后落库)POST /api/strategy_manager/update:修改策略名称/代码/说明/来源/周期等POST /api/strategy_manager/delete:删除策略POST /api/strategy_manager/toggle:启用或禁用策略示例(新增策略):
curl -s -X POST http://127.0.0.1:8000/api/strategy_manager/add \
-H "Content-Type: application/json" \
-d "{\"strategy_id\":\"98\",\"strategy_name\":\"稳健趋势策略\",\"class_name\":\"Strategy98\",\"code\":\"class Strategy98: pass\",\"analysis_text\":\"测试策略\"}"
示例(修改策略):
curl -s -X POST http://127.0.0.1:8000/api/strategy_manager/update \
-H "Content-Type: application/json" \
-d "{\"strategy_id\":\"98\",\"strategy_name\":\"稳健趋势策略V2\",\"analysis_text\":\"更新止损规则\"}"
示例(启停策略):
curl -s -X POST http://127.0.0.1:8000/api/strategy_manager/toggle \
-H "Content-Type: application/json" \
-d "{\"strategy_id\":\"98\",\"enabled\":true}"
示例(删除策略):
curl -s -X POST http://127.0.0.1:8000/api/strategy_manager/delete \
-H "Content-Type: application/json" \
-d "{\"strategy_id\":\"98\"}"
以下为建议新增接口,写入技能用于后续版本规划,不代表当前可调用:
GET /api/strategy_manager/summary
GET /api/strategy_manager/compare?ids=01,02,03
GET /api/strategy_manager/score_trend?strategy_id=01
POST /api/control/start_backteststatus=success,并记录 report_id(字符串)GET /api/statuscurrent_report_status == "failed":立即失败返回is_running == true:继续轮询is_running == false:进入报告查询GET /api/report/{report_id}GET /api/report/historyGET /api/report/latest当用户请求“策略列表、策略管理器明细、单策略详情、策略说明”时,编排步骤如下:
GET /api/strategiesGET /api/strategy_manager/listGET /api/strategy_manager/detail?strategy_id=xxnot_found,明确告知用户策略不存在POST /api/strategy_manager/analyze 或 analyze_marketPOST /api/strategy_manager/updatePOST /api/strategy_manager/togglePOST /api/strategy_manager/delete为了防止用户等待过久,必须执行双层节奏:
/api/status30 秒播报内容建议包含:
progress.progressprogress.current_datecurrent_report_status即使进度值不变,也要每 90 秒向用户输出“仍在执行中”的进展说明。
progress.progress 连续 90 秒无变化,返回 TASK_STALLEDcurrent_report_status=failed,立即终止轮询并返回错误POST /api/control/stop,再重试一次PARTIAL_SUCCESS,附带状态快照与完整日志trace_id、operation、status、error_msg、latest_status_snapshot、logs{
"trace_id": "oc-20260320-001",
"step": 1,
"timestamp": "2026-03-20T10:00:00Z",
"method": "POST",
"path": "/api/control/start_backtest",
"query": {},
"request_body": {
"stock_code": "301227.SZ",
"strategy_id": "all",
"start": "2025-03-20",
"end": "2026-03-20"
},
"http_status": 200,
"duration_ms": 128,
"response_preview": {
"status": "success",
"report_id": "1742400000000-ab12"
},
"error": null
}
日志要求:
trace_id 必须一致response_preview 仅保留关键字段,避免塞入超大 payloadhttp_status、response_preview、errorerror 且可直接用于向用户解释失败原因最终结果必须符合以下结构:
Final result must conform to this schema:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "OpenClawJinCeZhiSuanResult",
"type": "object",
"required": ["trace_id", "operation", "status", "meta", "summary", "ranking", "strategy_reports", "logs"],
"properties": {
"trace_id": { "type": "string" },
"operation": { "type": "string", "enum": ["start_backtest", "start_live", "stop_task", "fetch_report", "list_strategies", "get_strategy_detail", "analyze_strategy", "add_strategy", "update_strategy", "toggle_strategy", "delete_strategy"] },
"status": { "type": "string", "enum": ["SUCCESS", "FAILED", "TASK_STALLED", "PARTIAL_SUCCESS"] },
"meta": {
"type": "object",
"required": ["report_id", "report_status", "error_msg", "stock", "period"],
"properties": {
"report_id": { "type": ["string", "null"] },
"report_status": { "type": ["string", "null"] },
"error_msg": { "type": ["string", "null"] },
"stock": { "type": ["string", "null"] },
"period": { "type": ["string", "null"] }
},
"additionalProperties": true
},
"summary": {
"type": "object",
"required": ["total_trades"],
"properties": {
"total_trades": { "type": ["number", "null"] },
"total_return": { "type": ["number", "null"] },
"annualized_return": { "type": ["number", "null"] },
"max_drawdown": { "type": ["number", "null"] }
},
"additionalProperties": true
},
"ranking": {
"type": "array",
"items": {
"type": "object",
"properties": {
"strategy_id": { "type": ["string", "null"] },
"rating": { "type": ["string", "null"] },
"annualized_roi": { "type": ["number", "null"] },
"max_dd": { "type": ["number", "null"] },
"win_rate": { "type": ["number", "null"] },
"calmar": { "type": ["number", "null"] }
},
"additionalProperties": true
}
},
"strategy_reports": {
"type": "array",
"items": { "type": "object", "additionalProperties": true }
},
"logs": {
"type": "array",
"items": {
"type": "object",
"required": ["step", "timestamp", "method", "path", "http_status", "duration_ms"],
"properties": {
"step": { "type": "integer" },
"timestamp": { "type": "string" },
"method": { "type": "string" },
"path": { "type": "string" },
"http_status": { "type": ["integer", "null"] },
"duration_ms": { "type": ["number", "null"] },
"response_preview": { "type": ["object", "null"] },
"error": { "type": ["string", "null"] }
},
"additionalProperties": true
}
}
},
"additionalProperties": false
}
/api//reports/api/report/list