Backtesting API
The Backtesting API runs historical strategy testing with performance metrics and trade-by-trade analysis.Endpoints
| Method | Endpoint | Description |
|---|---|---|
POST | /api/v1/backtests | Run a new backtest |
POST | /api/v1/backtests/bulk | Run backtests for multiple strategies |
GET | /api/v1/backtests/{id} | Retrieve a historical backtest result |
GET | /api/v1/backtests/{id}/trades | Retrieve a run’s trade history |
POST | /api/v1/backtests/{id}/archive | Archive a run (hide from the default view) |
POST | /api/v1/backtests/{id}/unarchive | Unarchive a run (restore to the default view) |
Backtests are never deleted. A backtest is an immutable historical record;
there is no delete endpoint. To remove a run from your default history view, use
POST /api/v1/backtests/{id}/archive (reversible via unarchive). See
Archive a backtest.Path.
/api/v1/backtests is the canonical path (mirroring the async
/api/v2/backtests/). The older /api/v1/backtesting/backtest* paths still work
as a deprecated alias and dispatch to the identical handlers, but new
integrations should use /api/v1/backtests.Run a Backtest
POST /api/v1/backtests
Runs a synchronous backtest and returns metrics and trade history. Loads market data from CoinAPI for the specified asset and date range.
One backtest at a time. The engine processes a single synchronous backtest per worker. If another backtest is already running, this endpoint returns
503 Service Unavailable with a Retry-After header instead of blocking until the gateway times out (504). Honor Retry-After and retry, run requests sequentially, or use the bulk endpoint to evaluate many strategies in one request. See the Running a Backtest guide.Date Range Modes
| Mode | Parameters | Behavior |
|---|---|---|
| Explicit Range | start_date + end_date | Exact date window |
| From Date to Now | start_date only | Start date to current time |
| Lookback from End | end_date + lookback_months | N months back from end date |
| Recent History | lookback_months only | N months from current time |
Example: Historical Lookback
Response
Required Parameters
| Parameter | Type | Description |
|---|---|---|
asset | string | Asset symbol (e.g., “BTC”, “ETH”). Optional when strategy_id is supplied (defaults from the saved strategy). |
interval | string | Time interval (“1h”, “4h”, “1d”) |
initial_balance | number | Starting account balance |
strategy_json | string | Stringified JSON strategy configuration. Provide this or strategy_id. |
Strategy Source: strategy_json or strategy_id
Provide exactly one of:
strategy_json(string) — the stringified strategy configuration shown below.strategy_id(string) — the UUID of a strategy you already created. The API loads its definition and defaultsassetandexecution_configfrom the saved strategy when you omit them.
400; an unknown or inaccessible strategy_id returns 404. The same strategy_id option is accepted by the async endpoint POST /api/v2/backtests/.
Strategy JSON Format
Entry rules require exactly 1 TRIGGER + 1 FILTER signal:Do NOT include
atr_period or atr_multiplier in strategy_json. These belong in execution_config and are injected at runtime.Retrieve Backtest Result
GET /api/v1/backtests/{backtest_id}
Retrieves a previously executed backtest including full trade history.
Archive a Backtest
Backtests are immutable and cannot be deleted. Archiving a run hides it from your default history view; it remains stored and can be restored at any time.POST /api/v1/backtests/{backtest_id}/archive
POST /api/v1/backtests/{backtest_id}/unarchive
404.
Listing archived runs
Your backtest history (GET /api/v1/users/me/backtests) excludes archived runs
by default. Pass include_archived=true to include them; each item carries an
archived boolean and an archived_at timestamp (null when active).
Bulk Backtest
POST /api/v1/backtests/bulk
Evaluates multiple strategies over a shared date range. Market data is fetched once per unique (asset, timeframe) pair.
Provide either strategy_ids (UUIDs from database) or strategy_configs (inline strategy objects).
data_fetches field shows how many unique API calls were made.
Cooldown Parameters
Passcooldown_config as a top-level key in the backtest request body to control loss-streak limits and cooldown durations. The engine selects the entry keyed to the interval value of the request.
| Key | Description |
|---|---|
short_loss_limit | Losses in short_window_bars that trip the short-tier cooldown |
long_loss_limit | Losses in long_window_bars that trip the long-tier cooldown |
short_window_bars | Rolling lookback AND cooldown duration (bars) for the short tier |
long_window_bars | Rolling lookback AND cooldown duration (bars) for the long tier |
execution_config.max_hold_bars, not by cooldown_config.
See the Risk Management guide for full cooldown tuning details.