walk_forwardΒΆ

Defined in fynance.data

walk_forward(n, train, test, step=None, purge=0)[source]

Generate purged walk-forward windows.

Each window trains on [t-train : t-purge] and tests on [t : t+test].

Parameters:
nint

Number of observations.

train, testint

Train and test window lengths.

stepint, optional

Roll step (defaults to test, i.e. non-overlapping test windows).

purgeint

Observations removed at the train/test boundary (embargo).

Yields:
(train_idx, test_idx)tuple of numpy.ndarray

Index arrays with test_idx strictly after train_idx.