quantlab.runs.backtest_report.ReportExtras#

class quantlab.runs.backtest_report.ReportExtras(attribution=None, factor_attribution=None, tables=None, setup=None, names=None, prices=None)[source]#

Bases: object

What only some runs put on their page: the one optional slot of write_backtest_report.

Attributes:
attributionxarray.Dataset or None

The attribution curves of a model run (universe_value, gross_value, group_value; quantlab.runs.backtest_attribution). With them and an attribution block in the metrics the page gets an Attribution section: the excess split into its parts, the cumulative log growth of the strategy, before costs, the universe and the benchmark, and each score group’s annualised return.

factor_attributionxarray.Dataset or None

The per-bar factor attribution of a run with a risk model (factor_attribution.zarr). With it and a factor_attribution block in the metrics the page gets a Factor attribution section (quantlab.runs.factor_attribution_report), summarizing the out-of-sample segment when the run has an in-sample part.

tablesMapping or None

More tables after the metric tables: heading -> ordered mapping of row label to value, each value shown as an unknown metric is (a number by its magnitude, a percent when the label ends in [%], a string as it is). For statistics only an executor has, such as an event-driven replay’s commissions.

setupMapping or None

Setup lines applied after the standard ones: a label the page already has is replaced in place (an executor states its own fee model under Fees), a new one is appended.

namescallable or None

names(symbols, day) returns a (ticker, company) pair for each of symbols as of the date day, the company None when unknown; the Holdings section shows symbols by them, a new span wherever a name changes. Without it a symbol is shown by its id.

pricesxarray.DataArray or None

The valuation prices on (timestamp, symbol) the engine marks the book with. With them the Holdings section shows each holding period’s return (the symbol’s price at the period’s last close over its price at the signal bar’s close, less one, carried forward over a bar without one) and the contributions by position size.

Examples

>>> extras = ReportExtras(tables={"Execution": {"Commissions": 12.5}}, setup={"Fees": "IBKR tiered"})
>>> extras.setup["Fees"], extras.attribution is None
('IBKR tiered', True)