WF04 · example_wf_04_grid_search_optimization.py WF04 Grid Search Parameter Optimization
Find the best SMA fast/slow window pair for a trend strategy with an exhaustive GRID SEARCH. Each candidate is scored by running a real backtest and reading its annualized Sharpe.
Review the source on GitHub or return to all strategies.
What this example shows
This example shows how to build a workflow-level grid-search optimization research example with fold construction, parameter selection, diagnostics, logging and evidence capture.
The goal is educational: to demonstrate the full workflow for validation setup, search space definition, fold diagnostics, objective tracking and reproducible run logging.
Optimization workflow. Parameter-search workflow over 9 combinations; the best observed setting was fast=20, slow=200 · observed in-sample Sharpe 0.6744. This is optimization output, not an investable or independently validated result.
Run setup
The ordinary configuration used by the published run—kept visible here and in the Python source.
Dashboard
Compact evidence view built from the same run packet: metrics, plots and run metadata.
Metrics
This workflow emits diagnostics rather than a standard performance table.
Optimization workflow. Parameter-search workflow over 9 combinations; the best observed setting was fast=20, slow=200 · observed in-sample Sharpe 0.6744. This is optimization output, not an investable or independently validated result.
Artifacts
Stable links that can be referenced from GitHub README files or external docs.
Run log
Tail of the execution log for this packet.
Running strategy: example_wf_04_grid_search_optimization
File: <QJ_BACKTESTER_REPO>/strategies/example_wf_04_grid_search_optimization.py
Python: <QJ_BACKTESTER_REPO>/.venv/bin/python
Backtester: v0.10.0
Theme: quantjourney
Plot DPI: 300
Log Level: ERROR
Output: reports/canonical-suite-20260711
Grid search results
best params: {'fast': 20, 'slow': 200}
best Sharpe: 0.6744
evaluated: 9 combinations