Class Backtester
java.lang.Object
com.quantfinlib.backtest.Backtester
Event-driven, single-instrument, long-only backtesting engine.
Execution model: signals fill at the bar close (adjusted for slippage); stop-loss / take-profit levels are evaluated intrabar against the bar's low/high on bars after entry, with gap-aware fills (a gap through the level fills at the open). Commission is charged on both entry and exit notional.
-
Method Summary
Modifier and TypeMethodDescriptionstatic BacktestResultrun(TradingStrategy strategy, BarSeries series, BacktestConfig config) static BacktestResultrun(TradingStrategy strategy, BarSeries series, BacktestConfig config, int tradeFrom) Variant with a WARM-UP prefix: indicators are initialized over the whole series, but no signal is acted on (and no equity recorded) beforetradeFrom.
-
Method Details
-
run
-
run
public static BacktestResult run(TradingStrategy strategy, BarSeries series, BacktestConfig config, int tradeFrom) Variant with a WARM-UP prefix: indicators are initialized over the whole series, but no signal is acted on (and no equity recorded) beforetradeFrom. This is how walk-forward analysis avoids the cold-start bias — evaluating a fold on a bare test slice re-computes every indicator from scratch, silently forcing HOLD through the firstlookbackbars of every fold; feeding the preceding bars as warm-up (they are the past — no look-ahead) lets the strategy enter the test window with warm indicators, the way it would trade live. The returned equity curve covers[tradeFrom, n)only.Scope of the warm-up: it warms whatever
TradingStrategy.init(com.quantfinlib.core.BarSeries)precomputes over the series (all shipped strategies).onBaris NOT called for warm-up bars, so a strategy that accumulates state insideonBarstill starts cold attradeFrom.
-