Backtest._window_at#

Backtest._window_at(origin)[source]#

The estimation sample at one origin, in the shape fit expects.

Rows 0 .. origin - 1 under the expanding scheme, the last window of them under the rolling one; a single series is handed back as (m,), the way it arrived. A view of the stored sample, not a copy.

Parameters:

origin (int) – Observations available, one of origins.

Return type:

NDArray[double]

Returns:

The (m, k) or (m,) window.

Example

>>> import numpy as np
>>> y = np.random.default_rng(0).standard_normal((130, 2))
>>> Backtest(y, lambda w: w, start=100)._window_at(110).shape
(110, 2)
>>> rolling = Backtest(y, lambda w: w, start=100, scheme="rolling", window=60)
>>> rolling._window_at(110).shape, bool(np.all(rolling._window_at(110) == y[50:110]))
((60, 2), True)
>>> Backtest(y[:, 0], lambda w: w, start=100)._window_at(100).shape
(100,)