Skip to main content

Create Strategy

Register a new strategy. The platform stores metadata only — no execution side effects.

Endpoint

POST /strategies

Authentication: Public.

Request body

FieldTypeRequiredNotes
namestringYesUnique label across the platform.
authorstringNoFree-form.
descriptionstringNoFree-form.
entry_conditionstringNoFree-form. Stored as an opaque string.
exit_conditionstringNoFree-form.
bot_namestringNoExecutor reference key.

Response — 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"
}

Errors

HTTPBackend detailEnglish equivalent
400策略 <name> 已存在Strategy <name> already exists
422(FastAPI validation)Missing or wrong-typed name
500(varies)Unhandled server error

Example

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