Strategies API
The Strategies API provides CRUD operations for managing trading strategies. Strategies are persisted in PostgreSQL and associated with specific users and organizations.
Base URL
http://localhost:5001/api/v1/strategies
Authentication
All endpoints require authentication. Include your JWT token or API key in the request headers:
Authorization: Bearer YOUR_JWT_TOKEN
Each strategy’s rules field contains entry and exit rule arrays. Each rule object has:
| Field | Type | Required | Description |
|---|
name | string | yes | Signal function name from the signal registry (e.g., "rsi_oversold") |
signal_type | string | yes | "TRIGGER" (event-based) or "FILTER" (state-based) |
timeframe | string | yes | Candle interval: 5m, 15m, 30m, 1h, 4h, 1D |
params | object | yes | Signal-specific parameters |
Signal Composition Constraints
Entry rules require exactly 2 signals:
- Exactly 1 TRIGGER signal — event-based signal that fires when a specific condition occurs
- Exactly 1 FILTER signal — state-based signal that validates current market conditions
Both must evaluate to True for an entry to occur.
Exit rules:
- Exactly 1 TRIGGER signal
- Optional: 0 or 1 FILTER signal
Stop loss and take profit are NOT signal rules. They are managed by the execution engine via ATR-based risk management configured in execution_config.
Endpoints
List Strategies
GET /api/v1/strategies
List all strategies for the authenticated user and organization.
Query Parameters:
skip (optional, integer): Number to skip for pagination. Default: 0
limit (optional, integer): Maximum to return. Default: 100
curl -H "Authorization: Bearer $TOKEN" \
"http://localhost:5001/api/v1/strategies?skip=0&limit=10"
Response (200 OK):
{
"success": true,
"strategies": [
{
"id": "5089b9a8-f375-4813-8ed0-d7175368a11e",
"name": "eth_strategy_20260124_220416",
"asset": "ETH",
"status": "inactive",
"created_at": "2026-01-24T22:01:51Z"
}
],
"total": 1,
"skip": 0,
"limit": 10
}
Create Strategy
POST /api/v1/strategies
Create a new trading strategy.
Required Fields:
name (string): Strategy name
asset (string): Asset symbol (e.g., "BTC", "ETH")
entry (array): Entry rules (1 TRIGGER + 1 FILTER)
Optional Fields:
exit (array): Exit rules (default: [])
reward_factor (number): Risk/reward ratio (default: 2.0)
execution_config (object): Execution parameters (defaults from trading_defaults.json)
curl -X POST "http://localhost:5001/api/v1/strategies" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "BTC RSI Strategy",
"asset": "BTC",
"entry": [
{
"name": "rsi_oversold",
"signal_type": "TRIGGER",
"timeframe": "1h",
"params": {"window": 14, "threshold": 30}
},
{
"name": "is_above_sma",
"signal_type": "FILTER",
"timeframe": "1h",
"params": {"window": 50}
}
],
"exit": [],
"reward_factor": 2.0
}'
Response (201 Created):
The response includes execution_config and execution_state, populated with defaults from trading_defaults.json if not provided.
{
"success": true,
"strategy": {
"id": "278bba9d-7f4c-476c-9dea-a1a44f1fcfba",
"name": "BTC RSI Strategy",
"asset": "BTC",
"status": "inactive",
"rules": {
"name": "btc_rsi_strategy",
"asset": "BTC",
"entry": [
{"name": "rsi_oversold", "signal_type": "TRIGGER", "timeframe": "1h", "params": {"window": 14, "threshold": 30}},
{"name": "is_above_sma", "signal_type": "FILTER", "timeframe": "1h", "params": {"window": 50}}
],
"exit": [],
"reward_factor": 2.0
},
"execution_config": {
"max_risk_per_trade": 0.01,
"reward_factor": 2,
"stop_loss_calculation": "dynamic_atr",
"atr_period": 14,
"atr_volatility_factor": 2.0
},
"execution_state": {
"cash_balance": 10000.0,
"account_value": 10000.0,
"total_trades": 0,
"num_open_positions": 0
},
"created_at": "2026-02-10T16:21:59Z"
}
}
Get Strategy
GET /api/v1/strategies/{strategy_id}
Retrieve a specific strategy by ID with full details including rules, execution_config, and execution_state.
curl -H "Authorization: Bearer $TOKEN" \
"http://localhost:5001/api/v1/strategies/278bba9d-7f4c-476c-9dea-a1a44f1fcfba"
Delete Strategy
DELETE /api/v1/strategies/{strategy_id}
Delete a strategy by ID. Only the strategy owner can delete it.
curl -X DELETE "http://localhost:5001/api/v1/strategies/278bba9d-7f4c-476c-9dea-a1a44f1fcfba" \
-H "Authorization: Bearer $TOKEN"
Update Strategy Status
PATCH /api/v1/strategies/{strategy_id}/status
Update a strategy’s deployment status. Valid values: draft, inactive, paper, live, archived.
curl -X PATCH "http://localhost:5001/api/v1/strategies/278bba9d-7f4c-476c-9dea-a1a44f1fcfba/status" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"status": "paper"}'
Execution Configuration
Each strategy includes execution_config for risk management:
| Field | Type | Description |
|---|
max_risk_per_trade | number | Maximum risk per trade as decimal (0.01 = 1%) |
reward_factor | number | Risk/reward ratio target |
stop_loss_calculation | string | "dynamic_atr" or "fixed" |
atr_period | integer | ATR lookback period in bars (default: 14) |
atr_volatility_factor | number | ATR multiplier for stop loss distance |
max_open_positions | integer | Maximum concurrent open positions |
max_trades_per_day | integer | Daily trade limit |
cooldown_bars | integer | Bars to wait between trades |
max_hold_bars | integer | Maximum bars to hold any position |
Error Codes
| Code | HTTP Status | Description |
|---|
AUTH_REQUIRED | 401 | Authentication required |
PERMISSION_DENIED | 403 | User lacks permission |
RESOURCE_NOT_FOUND | 404 | Strategy not found |
MISSING_FIELD | 400 | Required field missing |
VALIDATION_ERROR | 400 | Invalid request data |