run_backtest
Backtest a strategy spec on daily bars over a date range with explicit costs, returning metrics summary plus equity curve and trade blotter links; cached identical runs return instantly.
Instructions
Run a backtest and return its metrics summary plus links to the equity curve and trade blotter. Identical configurations are cached and return instantly. Worked specs: {'primitive':'buy_and_hold','params':{}}; {'primitive':'sma_cross','params':{'fast':10,'slow':30}}; {'primitive':'threshold','params':{'lookback':15,'entry_pct':1.5,'exit_pct':0.25}}. A spec also carries optional top-level fields beside primitive and params, e.g. {'primitive':'sma_cross','params':{'fast':10,'slow':30},'warmup_bars':60,'rebalance':'weekly','sizing':'fixed_fraction','fraction':0.25}. Unknown fields are rejected rather than ignored. Costs have no default and must be stated: {'fee_bps':5,'slippage_bps':2} is a typical setting, {'fee_bps':0,'slippage_bps':0} is frictionless and has to be asked for. Examples: run_backtest(spec={'primitive':'sma_cross','params':{'fast':20,'slow':50}}, symbol='SYN-04', start='2019-01-01', end='2021-12-31', costs={'fee_bps':5,'slippage_bps':2}); run_backtest(spec={'primitive':'buy_and_hold','params':{},'sizing':'fixed_fraction','fraction':0.25}, symbol='SYN-02', start='2020-01-01', end='2020-12-31', costs={'fee_bps':0,'slippage_bps':0}); run_backtest(spec={'primitive':'threshold','params':{'lookback':15,'entry_pct':1.5,'exit_pct':0.25},'rebalance':'weekly'}, symbol='SYN-09', start='2019-01-01', end='2021-12-31', costs={'fee_bps':1,'slippage_bps':1}). This tool takes NO as_of argument. The cutoff is derived from end, so a run can never be pointed at data later than its own evaluation window. Do not ask for an as_of and do not try to pass one.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end | Yes | Last date of the evaluation window. | |
| spec | Yes | A strategy spec object. | |
| costs | Yes | Transaction costs. No defaults; state them explicitly. | |
| start | Yes | First date of the evaluation window. | |
| symbol | Yes | Symbol to run against. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||