跳到主要内容

更新策略

修改一个或多个可编辑字段。name 不可编辑。

接口

PUT /strategies/{strategy_id}

鉴权: 公开。

路径参数

名称类型必填说明
strategy_idinteger数据库自增 id。

请求体

所有字段可选。省略或传 null 的字段保持不变。

字段类型说明
authorstring
descriptionstring
entry_conditionstring
exit_conditionstring
bot_namestring

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"
}'