train_test_splitΒΆ

Defined in fynance.data

train_test_split(n, test_size, gap=0)[source]

Time-ordered train/test index split.

Parameters:
nint

Number of observations.

test_sizefloat or int

Fraction (0 < x < 1) or absolute count of the trailing test set.

gapint

Embargo: observations dropped between train end and test start.

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

test_idx is strictly after train_idx (no leakage).