跳到主要内容

导入策略

POST/research/strategy-imports在线调试
POST https://api.shengkezhi.com/open/v1/research/strategy-imports
等效 curl
curl "https://api.shengkezhi.com/open/v1/research/strategy-imports" \
  -H "Authorization: Bearer sk_xxx" \
  -H "Content-Type: application/json" \
  --data '{"tomls":["示例Tomls"]}'

POST /research/strategy-imports — 导入策略。

上传完整、自包含的策略 TOML 并登记到当前用户的实盘策略库。每批最多 100 条,单条解码后最多 1 MiB、合计最多 10 MiB;已存在的同名策略不会重复写入,结果顺序与 tomls 一致。

需在请求头携带 Authorization: Bearer sk_xxx。

请求体​

字段类型必填说明
tomlsstring[]是完整、自包含的 UTF-8 策略 TOML 文本;每批最多 100 条。

响应 data​

字段类型必填说明
existinginteger是已存在、未重复登记的策略数。
insertedinteger是本次新登记的策略数。
itemsStrategyImportItem[]是与请求 tomls 顺序一致的逐项结果。
totalinteger是请求中的策略总数。

StrategyImportItem 字段​

字段类型必填说明
strategy_codestring是TOML 内声明的策略编号。
insertedboolean是本次是否新写入 strategies.duckdb;同名已存在时为 false。
lifecyclestring是登记后的生命周期状态;新策略固定为“暂停”,已有策略返回其当前状态。
toml_sha256string是上传内容的 SHA-256,供审计和客户端去重显示。

HTTP 状态​

状态码说明
200批量登记完成
400请求体 JSON 格式错误或策略配置无效
409策略库写锁被其他操作占用
413HTTP 请求体、单条 TOML 或 TOML 总大小超过限制
422列表为空、超过 100 条、含空 TOML 或请求字段不合法
503策略库写锁暂时不可用

调用示例​

curl -X POST "https://api.shengkezhi.com/open/v1/research/strategy-imports" \
-H "Authorization: Bearer sk_xxx" \
-H "Content-Type: application/json" \
-d '{"tomls":["示例Tomls"]}'
{
"code": 0,
"msg": "ok",
"data": {
"existing": 1,
"inserted": 1,
"items": [
{
"strategy_code": "STRAT_MOMENTUM_001",
"inserted": false,
"lifecycle": "示例Lifecycle",
"toml_sha256": "示例Toml sha256"
}
],
"total": 1
}
}