获取策略
按 ID 获取单个策略,包括其当前参数、状态以及运行时统计。
端点
GET /v1/strategies/{id}
权重: 1 鉴权: 必填(需签名)—— 参见 鉴权。
请求
路径参数:id —— 策略标识符(例如 strat_8f2a1b)。
无查询参数或请求体。
响应
{
"id": "strat_8f2a1b",
"name": "BTC grid 1h",
"template_id": "tpl_grid",
"params": {
"grid_levels": 8,
"upper_price": "72000",
"lower_price": "60000",
"rebalance_threshold": "0.02"
},
"symbols": ["BTCUSDT"],
"timeframe": "1h",
"capital": "10000.00",
"leverage": 3,
"status": "deployed",
"deployed_at": "2026-04-29T08:00:00Z",
"created_at": "2026-04-28T15:30:00Z",
"updated_at": "2026-04-29T08:00:00Z",
"stats": {
"open_positions": 2,
"total_pnl": "184.32",
"total_trades": 47,
"win_rate": "0.638"
}
}
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 策略标识符,格式为 strat_<6-8 位十六进制>。 |
name | string | 人类可读的名称。 |
template_id | string | 模板 slug,例如 tpl_grid。 |
params | object | 模板特定参数,schema 取决于具体模板。 |
symbols | array<string> | 策略交易的交易对。 |
timeframe | string | K 线周期,例如 1m、1h、1d。 |
capital | string | 计价币种名义资金,十进制字符串。 |
leverage | integer | 杠杆倍数,1–20。 |
status | enum | 取值之一:draft、deployed、paused、stopped、error。 |
deployed_at | string|null | 最近一次部署的 ISO 8601 UTC 时间戳,从未部署时为 null。 |
created_at | string | ISO 8601 UTC 创建时间。 |
updated_at | string | ISO 8601 UTC 最近修改时间。 |
stats | object | 累计运行时统计。 |
stats.open_positions | integer | 当前未平仓持仓数量。 |
stats.total_pnl | string | 计价币种的已实现 + 未实现盈亏,十进制字符串。 |
stats.total_trades | integer | 整个生命周期内已平仓的交易数量。 |
stats.win_rate | string | 盈利交易占比,区间为 [0, 1] 的十进制字符串。 |
错误
404 NOT_FOUND—— 策略不存在或不属于调用者。
完整列表参见 错误。
示例
curl "https://api.pipai.example/v1/strategies/strat_8f2a1b" \
-H "X-PipAI-API-Key: $API_KEY" \
-H "X-PipAI-Timestamp: $TS" \
-H "X-PipAI-Signature: $SIG"