Run Backtest
run_backtestStart a background backtest of a strategy over a daily-bar date window, then poll the run status until results or an error are available.
Instructions
Start a backtest of a strategy over a daily-bar window.
The backtest runs in the background; poll get_strategy_run(run_id) until status is COMPLETED (stats + equity curve) or FAILED (error message).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"strategy_id": "<strategy_id>",
"start": "<start>",
"end": "<end>"
},
"name": "run_backtest"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end | Yes | Window end date, ISO format | |
| risk | No | Optional run-level risk overlay — ``stop_loss_pct`` / ``trailing_stop_pct`` (fractions in (0,1)) and ``cooldown_bars`` (int). Honoured on **both tracks** with the same semantics: the check runs on every trading day (not only on rebalance dates), a trigger closes that symbol at the worse of the stop level and that bar's open (gap-conservative), and the symbol's *effective* target weight is 0 for ``cooldown_bars`` rebalances while the snapshot keeps the strategy's own ``target_weights`` beside ``effective_weights`` so the zero is attributable. Omitted = no overlay at all (the absent/disabled distinction is preserved on purpose: the API stores a snapshot only when the field is sent). | |
| start | Yes | Window start date, ISO format (e.g. "2025-01-01") | |
| sort_by | No | Ranking key for ``param_grid``'s matrix (default ``sharpe``). Ignored when ``param_grid`` is absent, exactly as on REST. | |
| benchmarks | No | Optional benchmark symbols (e.g. ``["000300.SS"]``). When given, the run attaches each benchmark's curve and the relative metrics (excess return / tracking error / information ratio); unavailable benchmarks are reported as missing, never fabricated. | |
| cost_model | No | Optional cost model — ``enabled`` plus ``commission_rate`` / ``stamp_tax_rate`` / ``slippage_bps`` (A-share defaults). Defaults to disabled, so a call that omits it prices the backtest at zero cost. It applies on both tracks (single-symbol and weight/multi-symbol). | |
| param_grid | No | Optional parameter grid — ``{param: [values...]}``. When given, every combination is scanned and the ranked matrix lands in the run's ``scan_results``. | |
| strategy_id | Yes | UUID of the strategy | |
| initial_cash | No | Starting cash for the simulated portfolio | 100000 |
| walk_forward | No | Optional walk-forward split — ``train_window`` / ``test_window`` / ``step`` (all ints, bars). All three or none: the API refuses a partial triple rather than guessing the missing one. When given, the OOS segments are attached to the run's ``walkforward_windows``. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||