Class GridSearchOptimizer
java.lang.Object
com.quantfinlib.backtest.validation.GridSearchOptimizer
Exhaustive strategy parameter search: backtests every grid combination and
ranks by an objective (e.g.
PerformanceMetrics::sharpeRatio).
Non-finite objectives rank last. Feed the resulting in-sample winners into
WalkForwardAnalyzer — never trust them raw.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbest(ParameterGrid grid, StrategyFactory factory, BarSeries series, BacktestConfig config, ToDoubleFunction<PerformanceMetrics> objective) The winning parameter set only.static doubledeflatedSharpeOfWinner(List<GridSearchOptimizer.Candidate> ranked, double[] winnerReturns, int periodsPerYear) The MULTIPLE-TESTING HAIRCUT for the grid's winner: the probability that the top-ranked candidate's Sharpe beats what the best ofranked.size()zero-skill trials would have scored anyway (SharpeValidation.deflatedSharpe(double, double[], int, double, double)).static List<GridSearchOptimizer.Candidate> search(ParameterGrid grid, StrategyFactory factory, BarSeries series, BacktestConfig config, ToDoubleFunction<PerformanceMetrics> objective)
-
Method Details
-
search
public static List<GridSearchOptimizer.Candidate> search(ParameterGrid grid, StrategyFactory factory, BarSeries series, BacktestConfig config, ToDoubleFunction<PerformanceMetrics> objective) -
best
public static GridSearchOptimizer.Candidate best(ParameterGrid grid, StrategyFactory factory, BarSeries series, BacktestConfig config, ToDoubleFunction<PerformanceMetrics> objective) The winning parameter set only. -
deflatedSharpeOfWinner
public static double deflatedSharpeOfWinner(List<GridSearchOptimizer.Candidate> ranked, double[] winnerReturns, int periodsPerYear) The MULTIPLE-TESTING HAIRCUT for the grid's winner: the probability that the top-ranked candidate's Sharpe beats what the best ofranked.size()zero-skill trials would have scored anyway (SharpeValidation.deflatedSharpe(double, double[], int, double, double)). A grid search computes a Sharpe for every trial and then quietly reports only the maximum — this is the one number that makes that selection honest. Values near 1 mean the winner survives its own search; below ~0.95 the "best" parameter set is indistinguishable from picking the luckiest of N random ones.- Parameters:
ranked- result ofsearch(com.quantfinlib.backtest.validation.ParameterGrid, com.quantfinlib.backtest.validation.StrategyFactory, com.quantfinlib.core.BarSeries, com.quantfinlib.backtest.BacktestConfig, java.util.function.ToDoubleFunction<com.quantfinlib.backtest.PerformanceMetrics>)(uses every trial's Sharpe as the null distribution), ≥ 2 trialswinnerReturns- the winner's per-period returns (derive from its equity curve), ≥ 4 observationsperiodsPerYear- the annualization used by the backtest metrics
-