跳到主要内容

创建策略

登记一条新策略。平台只存储元数据,不会产生执行副作用。

接口

POST /strategies

鉴权: 公开。

请求体

字段类型必填说明
namestring平台内唯一标签。
authorstring自由文本。
descriptionstring自由文本。
entry_conditionstring自由文本。以不透明字符串存储。
exit_conditionstring自由文本。
bot_namestring执行器引用键。

响应 — 200 OK

{
"id": 1,
"name": "btc-momentum-1h",
"author": "alice",
"description": "BTC momentum on 1h candles",
"entry_condition": "close > ema(50) AND rsi(14) > 55",
"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-03T10:00:00"
}

错误

HTTP后端 detail英文对照
400策略 <name> 已存在Strategy <name> already exists
422(FastAPI validation)Missing or wrong-typed name
500(varies)Unhandled server error

示例

curl -X POST "https://api.pipai.org/strategies" \
-H "Content-Type: application/json" \
-d '{
"name": "btc-momentum-1h",
"author": "alice",
"description": "BTC momentum on 1h candles",
"entry_condition": "close > ema(50) AND rsi(14) > 55",
"exit_condition": "close < ema(50) OR rsi(14) < 45",
"bot_name": "executor-momentum-v1"
}'