Class WalkForwardAnalyzer
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic final class -
Method Summary
Modifier and TypeMethodDescriptionanalyze(BarSeries series, ParameterGrid grid, StrategyFactory factory, BacktestConfig config, int trainBars, int testBars, ToDoubleFunction<PerformanceMetrics> objective) Runs a walk-forward optimisation over the parameter grid.
-
Method Details
-
analyze
public static WalkForwardAnalyzer.WalkForwardResult analyze(BarSeries series, ParameterGrid grid, StrategyFactory factory, BacktestConfig config, int trainBars, int testBars, ToDoubleFunction<PerformanceMetrics> objective) Runs a walk-forward optimisation over the parameter grid.- Parameters:
trainBars- bars in each optimisation windowtestBars- bars in each out-of-sample window; the window rolls forward by this amount per fold
-