run_backtest
Run a historical backtest to evaluate trading strategies using OHLCV data or signal series, with configurable execution settings and detailed performance metrics.
Instructions
Run a historical backtest against the engine.
Quota-counted and compute-bound. Validate the strategy first (validate_strategy is far cheaper). On a 504 compute timeout, do NOT retry the same request — reduce the date range, use a coarser frequency, or simplify the strategy. On 429/503, wait for the advertised Retry-After before retrying.
Args: data_source: Either inline OHLCV ({"ohlcv": {dates, open, high, low, close, volume?}} as parallel arrays, ISO-8601 dates) or a server-side fetch ({"symbol", "start", "end", "frequency"} — requires a paid plan). strategy: Strategy document (indicators[] + condition_tree). Mutually exclusive with signals. signals: Precomputed signal series ({"dates": [...], "values": [-1|0|1, ...]}). Mutually exclusive with strategy. execution: Execution/cost/risk/sizing settings. Use values from get_catalog('execution-modes'/'stop-types'/'sizing-methods'); omit for engine defaults. benchmark: Optional benchmark data source (same shape as data_source) — adds benchmark-relative metrics. data_inputs: Optional custom time-series the strategy references (name -> {dates, values}). response_detail: 'summary' (default — headline metrics, smallest), 'stats' (every metric), 'full' (plus trades and series downsampled to a fixed, server-controlled number of points). include: Optional add-on blocks at summary/stats detail: 'trades', 'equity_curve', 'monthly_returns', 'yearly_returns'. trades_limit: Max trades returned when trades are included.
Returns:
The shaped result at the requested detail; an oversized result is
thinned and marked truncated_by_mcp. If the engine rejects the
request as invalid (400/422), returns {"accepted": false,
"error": ...} so you can fix the named field(s) and retry. Capacity,
timeout, and permission failures (e.g. 429/503/504/401/403) raise a
tool error carrying explicit recovery guidance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| include | No | ||
| signals | No | ||
| strategy | No | ||
| benchmark | No | ||
| execution | No | ||
| data_inputs | No | ||
| data_source | Yes | ||
| trades_limit | No | ||
| response_detail | No | summary |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||