quantlab.runs.run_metrics.BenchmarkRecord#

class quantlab.runs.run_metrics.BenchmarkRecord(returns, symbol=None, axis_symbol=None, value=None, source=None)[source]#

Bases: object

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

Attributes:
returnsxarray.DataArray

The benchmark’s per-bar returns on the account’s timestamp axis.

symbolstr or None

Its readable name (a ticker), as metrics.json shows it.

axis_symbolstr or None

Its label on the price dataset’s symbol axis.

valuexarray.DataArray or None

Its value on the same bars when the engine simulated it (bought at the account’s capital, fees included); the report draws it, and without it draws init_cash * cumprod(1 + returns). Not read by run_metrics.

sourcestr or None

Where it was read from, shown after its name on the report’s Setup lines. Not read by run_metrics.

Examples

>>> bars = pd.bdate_range("2024-01-01", periods=2)
>>> spy = BenchmarkRecord(
...     returns=xr.DataArray([0.0, 0.01], dims="timestamp", coords={"timestamp": bars}),
...     symbol="SPY", axis_symbol="84398",
... )
>>> spy.symbol
'SPY'