quantlab.runs.run_metrics#

The metric blocks of a run’s metrics.json, assembled once from an account record.

A backtest run’s metrics.json holds the same blocks whatever simulated it: whole, execution, the in_sample and out_of_sample slices, benchmark and relative, and the split keys. run_metrics builds them from an AccountRecord, what one account did over its bars in a form every engine produces, so the vectorbt backtester (quantlab.backtest) and an event-driven executor of a quantlab run (quantlab-ibkr) report the same rows under the same names by construction. The only engine-specific input is the engine’s own whole-window rows (engine_rows: vectorbt’s portfolio statistics, or rows a trader builds from its fills), which open whole.

Every row comes from quantlab.runs.backtest_stats; this module decides which series, ranges, rebalances and year each row is computed on, and the order of the rows and blocks. It imports numpy, pandas, xarray and the runs layer’s statistics only: no model, dataset or backtest layer and no vectorbt (ADR 0034).

Classes

AccountRecord

What one account did over its bars, in the form every engine produces.

BenchmarkRecord

The benchmark an account is measured against, on the account's bars.

Functions

decided_bars

Return the bars of the decided rebalances of a rebalance record.

run_metrics

Return the metric blocks of an account, in metrics.json's layout.

slice_ranges

Return the ranges of the in_sample and out_of_sample slices of a split.