更新策略
修改一个或多个可编辑字段。name 不可编辑。
接口
PUT /strategies/{strategy_id}
鉴权: 公开。
路径参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
strategy_id | integer | 是 | 数据库自增 id。 |
请求体
所有字段可选。省略或传 null 的字段保持不变。
| 字段 | 类型 | 说明 |
|---|---|---|
author | string | |
description | string | |
entry_condition | string | |
exit_condition | string | |
bot_name | string |
updated_at 由服务端在每次成功 PUT 时自动刷新。
响应 — 200 OK
更新后的完整策略对象:
{
"id": 1,
"name": "btc-momentum-1h",
"author": "alice",
"description": "BTC momentum on 1h — tightened RSI",
"entry_condition": "close > ema(50) AND rsi(14) > 60",
"exit_condition": "close < ema(50) OR rsi(14) < 45",
"bot_name": "executor-momentum-v1",
"created_at": "2026-05-03T10:00:00",
"updated_at": "2026-05-03T12:00:00"
}
错误
| HTTP | 后端 detail | 英文对照 |
|---|---|---|
404 | 策略不存在 | Strategy not found |
422 | (FastAPI validation) | Body field has wrong type |
示例
curl -X PUT "https://api.pipai.org/strategies/1" \
-H "Content-Type: application/json" \
-d '{
"description": "BTC momentum on 1h — tightened RSI",
"entry_condition": "close > ema(50) AND rsi(14) > 60"
}'