BacktestResult._horizon_index#
- BacktestResult._horizon_index(horizon)[source]#
The slab index of a one-based horizon, after checking it exists.
- Parameters:
horizon (
int) – A horizon in1 .. horizons.- Return type:
- Returns:
horizon - 1.- Raises:
SpecificationError – If the horizon is outside the record.
Example
>>> import numpy as np >>> from cultivars.multivariate.reduced_form.vector_autoregression import VAR >>> y = np.random.default_rng(0).standard_normal((130, 2)) >>> record = Backtest(y, lambda w: VAR(w, order=1).fit(), horizons=2, start=100).run() >>> record._horizon_index(2) 1 >>> record._horizon_index(3) Traceback (most recent call last): ... cultivars.exceptions.SpecificationError: horizon must lie in 1 .. 2; got 3.