Class WalkForwardAnalyzer

java.lang.Object
com.quantfinlib.backtest.validation.WalkForwardAnalyzer

public final class WalkForwardAnalyzer extends Object
Walk-forward analysis. The series is split into rolling train/test windows; on each fold the parameter grid is optimised on the train window only and the winner trades the following test window. Test segments are stitched into one continuous out-of-sample equity curve.

Continuity across folds. The book is carried from one test window into the next (Backtester.runSegment(TradingStrategy, BarSeries, BacktestConfig, int, Backtester.State, int, boolean)): a position open at a fold boundary stays open and is managed by the next fold's strategy, as it would be live. Only the last fold liquidates at the end of the data. Trade indices are absolute indices into series.

Warm indicators. Each test window is run on the slice [trainFrom, testTo) with trading starting at the test boundary, so indicators enter the test window warm and nothing after testTo is visible to the strategy's init.

Efficiency is objective(stitched OOS curve) / objective(stitched IS curve), where the IS curve chains each fold winner's in-sample per-bar returns. A ratio of whole-curve objectives, rather than a sum of per-fold objectives (which for a Sharpe is not a Sharpe, and is dominated by short noisy windows). NaN when the IS objective is not positive: a ratio of two failures is not a pass. The IS runs are cold (they start on the train window's first bar) while OOS runs are warm; IS and OOS trade counts are reported so the asymmetry is visible.