quantlab.label.predefined.fret.Return#

class quantlab.label.predefined.fret.Return(factor_config)[source]#

Bases: _OpenToOpenLabel

Forward n-bar open-to-open return label.

At signal timestamp t the label is adjOpen[t + n + 1] / adjOpen[t + 1] - 1: the position is entered at the next bar’s adjusted open and exited n bars later at the adjusted open. It is a Forward label with span = n and delay = 1, so lookahead_bars() is n + 1. The label is NaN where either open is missing and at timestamps without n + 1 later bars in the dataset.

The output column is ret_{n}.

Parameters:
factor_configFactorConfig

The KunQuant factor config of the trailing return. Set data_columns to ["adjOpen"] and kwargs["n_forward_periods"] to the horizon n; file_path is where build writes the trailing return.

Examples

>>> label = Return(FactorConfig(
...     warmup_bars=5, dataset=dataset, mode="batch",
...     data_columns=["adjOpen"], kwargs={"n_forward_periods": 5},
...     file_path="ret.zarr",
... ))
>>> label.lookahead_bars(), label.span_bars(), label.get_factor_names()
(6, 5, ('ret_5',))