quantlab.backtest.base.label_specs#

quantlab.backtest.base.label_specs(predictor)[source]#

Return the LabelSpec of every prediction variable of predictor.

One spec per variable name of each label, in the order of labels: the name, its scale from label_scales, the label’s delay from label_delays and its span_bars(), or None for a label without one (it is not a Forward label). These are what a portfolio construction rule is bound to and what a run’s predictions.zarr records.

Parameters:
predictorPredictor

The model or ensemble whose labels are described.

Returns:
tuple[LabelSpec, …]

The specs, in the order of the prediction variables.

Raises:
ValueError

If label_scales has no entry for a label variable.

Examples

With model a model predicting the 5-bar forward return ret_5:

>>> label_specs(model)
(LabelSpec(name='ret_5', scale='raw', delay=1, span=5),)