You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Date/Time Rules - When to run WFO / Month Start, Week Start etc.
Optimization Target - Select the winning set pf parameters.
The result would then set the algorithm parameters set.
Checklist
I have completely filled out this template
I have confirmed that this issue exists on the current master branch
I have confirmed that this is not a duplicate issue by searching issues
Reacted by Dylan, Sucali, Santiago Villalobos, carrytrader86, Khanin Chomphusri, Stefan Stoeckigt, ghtbldr, Marek Opęchowski, Netgrid, Sander van der Have and 85 more
Reacted by Mislav Sagovac, Seth, Dylan, Stefan Stoeckigt, Manuel Benz, tmills86, Henry Ennis-Thomas, d-e-solutions, floppydisk525, ZacharyLWH and 8 more
this would be interesting! Please allow to pass an objective function to "score" where one can use the runtime statistics of the backtest and not only point estimates of the score of the backtest.
Is there a way to run the backtest on the research.ipynb?
I would like to optimize parameters but would need to extract values from the run backtest (objective function). Is it possible to call on the backtest strategy within research Jupyter notebook?
For walk-forward parameter optimization, the key insight is optimizing for out-of-sample Sharpe, not in-sample — which changes the algorithm choice significantly.
Genetic Algorithms with NSGA-II selection give you the Pareto frontier of risk-adjusted return vs. parameter stability. This is more useful than a single 'best' parameter set because you can visualize the tradeoff: parameters that maximize return tend to be brittle, while robust parameters cluster in a different region of the search space.
The practical implementation that works well:
GA for global search — population of 50-100 parameter sets, tournament selection, 2-point crossover
Simulated Annealing for local refinement — take the top 5 GA candidates and search their neighborhoods with geometric cooling
Fitness = OOS Sharpe * stability_score — where stability_score penalizes parameters that are sensitive to small perturbations (compute by jittering each parameter ±5% and checking if performance drops >20%)
This hybrid converges 3-5x faster than either algorithm alone because GA finds the right neighborhood and SA finds the exact optimum within it.
One implementation detail that matters: the walk-forward window size should be chosen via cross-validation, not fixed. We've seen 6-month in-sample / 1-month OOS work well for daily strategies, but this varies by holding period.
Add scheduled walk-forward optimization support by @scarab-systems, branch scarab-systems:feature-7031-walk-forward-optimization, head 372b67d79.
PR: #9611
The PR is being closed to tidy up the queue; the proposed change is recorded here for review and can be reopened or re-submitted once the approach is agreed.
Issue #7031 requests walk-forward optimization support in LEAN. This PR adds a core API contract and provider routing so algorithms can trigger optimization over time and apply chosen parameters without hard-coding a single execution backend.
Requires Documentation Change
Yes. If accepted, documentation should describe the new Optimize(...) API and the walk-forward-optimization-* configuration keys for local and cloud execution.
How Has This Been Tested?
Local environment: macOS, .NET SDK in this checkout.
New feature (non-breaking change which adds functionality)
Disclosure: I used AI-assisted coding tools while preparing this PR. I reviewed the changes myself, tested them, and take responsibility for the implementation and any follow-up revisions needed.
Activity
algo-dude commentedon Jun 1, 2023
A simple idea of how I would expect to use this:
jaredbroad commentedon Aug 4, 2023
Parent and Child algorithms to avoid nested optimizations
KlausGlueckert commentedon May 5, 2024
this would be interesting! Please allow to pass an objective function to "score" where one can use the runtime statistics of the backtest and not only point estimates of the score of the backtest.
RooFernando commentedon Jul 5, 2024
Is there a way to run the backtest on the research.ipynb?
I would like to optimize parameters but would need to extract values from the run backtest (objective function). Is it possible to call on the backtest strategy within research Jupyter notebook?
Whatsonyourmind commentedon Apr 2, 2026
For walk-forward parameter optimization, the key insight is optimizing for out-of-sample Sharpe, not in-sample — which changes the algorithm choice significantly.
Genetic Algorithms with NSGA-II selection give you the Pareto frontier of risk-adjusted return vs. parameter stability. This is more useful than a single 'best' parameter set because you can visualize the tradeoff: parameters that maximize return tend to be brittle, while robust parameters cluster in a different region of the search space.
The practical implementation that works well:
This hybrid converges 3-5x faster than either algorithm alone because GA finds the right neighborhood and SA finds the exact optimum within it.
One implementation detail that matters: the walk-forward window size should be chosen via cross-validation, not fixed. We've seen 6-month in-sample / 1-month OOS work well for daily strategies, but this varies by holding period.
jaredbroad commentedon Oct 28, 2026
Work transferred from PR #9611
Add scheduled walk-forward optimization support by @scarab-systems, branch
scarab-systems:feature-7031-walk-forward-optimization, head372b67d79.PR: #9611
The PR is being closed to tidy up the queue; the proposed change is recorded here for review and can be reopened or re-submitted once the approach is agreed.
Changed files (22 files, +1720/-2):
Algorithm/QCAlgorithm.cs(+115/-0)AlgorithmFactory/Python/Wrappers/AlgorithmPythonWrapper.cs(+6/-0)Api/ApiWalkForwardOptimizationProvider.cs(+121/-0)Api/WalkForwardOptimizationBacktestSelector.cs(+118/-0)Api/WalkForwardOptimizationCloudSettings.cs(+112/-0)Common/AlgorithmImports.py(+3/-0)Common/Interfaces/IAlgorithm.cs(+6/-0)Common/Interfaces/IWalkForwardOptimizationProvider.cs(+34/-0)Common/Optimizer/NullWalkForwardOptimizationProvider.cs(+45/-0)Common/Optimizer/WalkForwardOptimizationRequest.cs(+102/-0)Common/Optimizer/WalkForwardOptimizationResult.cs(+70/-0)Engine/Server/LocalLeanManager.cs(+5/-0)Launcher/config.json(+4/-1)Optimizer.Launcher/LocalWalkForwardOptimizationProvider.cs(+133/-0)Optimizer/LeanOptimizer.cs(+55/-0)Optimizer/OptimizationResult.cs(+9/-1)Tests/Algorithm/AlgorithmWalkForwardOptimizationTests.cs(+175/-0)Tests/Api/ApiWalkForwardOptimizationProviderSelectionTests.cs(+121/-0)Tests/Api/ApiWalkForwardOptimizationProviderTestBase.cs(+123/-0)Tests/Api/ApiWalkForwardOptimizationProviderTests.cs(+104/-0)Tests/Engine/WalkForwardOptimizationProviderRoutingTests.cs(+78/-0)Tests/Optimizer/LocalWalkForwardOptimizationProviderTests.cs(+181/-0)PR description
Description
Adds scheduled walk-forward optimization support for algorithms:
QCAlgorithm.Optimize(...)overloads that schedule walk-forward optimization similarly toTrain(...).Related Issue
Addresses #7031
Motivation and Context
Issue #7031 requests walk-forward optimization support in LEAN. This PR adds a core API contract and provider routing so algorithms can trigger optimization over time and apply chosen parameters without hard-coding a single execution backend.
Requires Documentation Change
Yes. If accepted, documentation should describe the new
Optimize(...)API and thewalk-forward-optimization-*configuration keys for local and cloud execution.How Has This Been Tested?
Local environment: macOS, .NET SDK in this checkout.
dotnet build Tests/QuantConnect.Tests.csproj /p:Configuration=Debug /v:quietgit diff --check origin/master...HEADTypes of changes
Disclosure: I used AI-assisted coding tools while preparing this PR. I reviewed the changes myself, tested them, and take responsibility for the implementation and any follow-up revisions needed.