Skip to main content

Strategies Quick Start

Five curl calls, no auth header, walk the full lifecycle.

1. Create

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

Response includes the assigned integer id. Re-using the same name returns 400 {"detail": "策略 btc-momentum-1h 已存在"}.

2. List

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

Returns an array. No pagination; ordered by created_at descending.

3. Get one

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

Replace 1 with the id returned by step 1.

4. Update

name is not editable. Any field omitted is left unchanged.

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. Delete

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

Returns {"message": "删除成功", "id": 1}.