Backtest
Run a strategy against the resolved-market set and get back per-market outcomes, an equity curve, and aggregate stats. Server-side execution — no need to pull every tick yourself.
Run a backtest
POST/v1/backtest
Body
| Field | Type | Description |
|---|---|---|
| assetrequired | string | One of BTC, ETH, SOL,XRP, DOGE, BNB, HYPE. |
| timeframerequired | string | Market timeframe: 5m, 15m, 1h, 4h, daily. |
| fromrequired | ISO 8601 | First market to include. |
| torequired | ISO 8601 | Last market to include. |
| strategyrequired | object | Strategy spec. The simplest form is a price-threshold rule — see the example below. |
| stake | number | Constant USDC stake per trade. Defaults to 100. |
Example request
terminal
curl https://api.tradrr.dev/v1/backtest \
-H "Authorization: Bearer $TRADRR_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"asset": "BTC",
"timeframe": "1h",
"from": "2025-01-01",
"to": "2025-03-31",
"strategy": {
"rule": "buy_when",
"outcome": "Up",
"price_above": 0.80,
"entry": "first_cross"
},
"stake": 100
}'Response
200 OK
{
"summary": {
"markets": 1240,
"trades": 412,
"win_rate": 0.582,
"pnl_usdc": 3184.55,
"max_dd": -412.20,
"sharpe": 1.41
},
"equity_curve": [
{ "ts": "2025-01-01T00:00:00Z", "equity": 10000.0 },
{ "ts": "2025-01-01T01:00:00Z", "equity": 10082.4 }
],
"trades": [
{
"market_id": "0xabc123...",
"entry_ts": "2025-01-01T00:14:00Z",
"entry_px": 0.81,
"exit_px": 1.00,
"outcome": "Up",
"pnl": 23.46
}
]
}Note
Strategies more complex than threshold rules are easier to write against the raw order book and trades endpoints — or wait for the Python SDK.