quantlab.runs.prediction_panel.LabelSpec#

class quantlab.runs.prediction_panel.LabelSpec(name, scale, delay, span)[source]#

Bases: object

What a portfolio construction rule may know about one prediction variable.

A rule is bound to the specs of the labels it is handed predictions of (PortfolioConstructor.bind), never to the model that predicted them, so a rule can be rebuilt from a run directory without its model (quantlab.portfolio.decision_inputs.DecisionInputs.from_run). The backtester derives the specs of its predictor with quantlab.backtest.base.label_specs.

Parameters:
namestr

The label’s variable name, the prediction variable it scores.

scalestr

The prediction’s scale: "raw" in the label’s own units, "standardized" when it only ranks the cross-section.

delayint

Bars between the bar a signal forms on and the first bar the label counts.

spanint or None

Bars the label accumulates over, or None for a label that is not a Forward label.

Examples

>>> spec = LabelSpec(name="ret_5", scale="raw", delay=1, span=5)
>>> spec.span, dataclasses.asdict(spec)["scale"]
(5, 'raw')