跳到主要内容

策略模块快速开始

五条 curl 走完完整生命周期,无需鉴权头。

1. 创建

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

响应包含分配到的整数 id。重复使用同一 name 会返回 400 {"detail": "策略 btc-momentum-1h 已存在"}

2. 列出

curl -s "https://api.pipai.org/strategies"

返回数组,无分页,按 created_at 倒序。

3. 查询单条

curl -s "https://api.pipai.org/strategies/1"

1 替换为第 1 步返回的 id

4. 更新

name 不可编辑。请求体中省略的字段保持不变。

curl -X PUT "https://api.pipai.org/strategies/1" \
-H "Content-Type: application/json" \
-d '{
"description": "BTC momentum on 1h — tightened RSI thresholds",
"entry_condition": "close > ema(50) AND rsi(14) > 60"
}'

5. 删除

curl -X DELETE "https://api.pipai.org/strategies/1"

返回 {"message": "删除成功", "id": 1}