创建策略
登记一条新策略。平台只存储元数据,不会产生执行副作用。
接口
POST /strategies
鉴权: 公开。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 是 | 平台内唯一标签。 |
author | string | 否 | 自由文本。 |
description | string | 否 | 自由文本。 |
entry_condition | string | 否 | 自由文本。以不透明字符串存储。 |
exit_condition | string | 否 | 自由文本。 |
bot_name | string | 否 | 执行器引用键。 |
响应 — 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"
}'