quantlab.model.split.in_sample_window#
- quantlab.model.split.in_sample_window(calendar, train_start, train_end, lookahead)[source]#
Return the first and last bar a fitted model has seen.
The model fitted labels on the bars of
[train_start, train_end], and the label of the last one readslookaheadbars further, so those bars are in-sample too.- Parameters:
- calendarnp.ndarray
The sorted bar axis the backtest trades on.
- train_start, train_end
The fitted training window, both ends inclusive, resolved as
purge_segmentsresolves segment bounds.train_endis the last bar fitted, after any purge.- lookaheadint
L, the largest
lookahead_bars()among the model’s labels.
- Returns:
- tuple of np.datetime64 or None
The first training bar and the bar
lookaheadbars after the last one, clamped to the calendar’s last bar;Nonewhen the window holds no bar of the calendar.
Examples
>>> days = pd.bdate_range("2024-01-01", periods=10).values >>> in_sample_window(days, "2024-01-01", "2024-01-05", 2) (np.datetime64('2024-01-01T00:00:00.000000000'), np.datetime64('2024-01-09T00:00:00.000000000'))