quantlab.backtest.base.BacktestResult#

class quantlab.backtest.base.BacktestResult(run_dir, predictions, weights, simulation, metrics=<factory>, benchmark=None)[source]#

Bases: object

Return value of BaseBacktester.run() and BaseBacktester.run_weights().

run_dir is the directory this run wrote its artifacts to, or None when config.output_dir is None and nothing was written. predictions and weights are panels on (timestamp, symbol) covering exactly the backtest window; predictions is None for a run_weights() run, which has no model. metrics is the same mapping written to metrics.json. benchmark is the buy-and-hold simulation of config.benchmark_dataset on the same bars, or None when no benchmark is configured.

Examples

>>> result = backtester.run()
>>> BacktestRun.open(result.run_dir).metrics() == to_jsonable(result.metrics)
True
>>> sorted(result.metrics)
['execution', 'in_sample', 'in_sample_range', 'notes', 'out_of_sample',
 'out_of_sample_ranges', 'portfolio_construction', 'training_window', 'whole']