quantlab.backtest.base.CVBacktestResult#

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

Bases: object

Return value of BaseBacktester.run_cv().

run_dir is None when config.output_dir is None. folds holds one record per replayed fold: the fold’s index fold, its fitted training and test dates and checkpoint, the predictions of its checkpoint over its test segment, its metrics and data_fingerprint (what its prediction read). weights are built in one pass over the concatenated fold predictions, as one account whose holdings carry across fold boundaries, and simulation is the single continuous simulation of them; a fold’s metrics are that account over its test segment (ADR 0033). metrics mirrors metrics.json with the keys stitched, folds and notes. benchmark is the buy-and-hold benchmark simulated over the stitched span, or None without a benchmark.

Examples

>>> cv = backtester.run_cv()
>>> len(cv.folds), sorted(cv.metrics)
(8, ['folds', 'notes', 'stitched'])
>>> sorted(cv.metrics["stitched"])
['in_sample', 'in_sample_ranges', 'out_of_sample', 'out_of_sample_ranges',
 'training_windows', 'whole']