QuantJourney Backtester

QuantJourney Backtester

Share product feedback

✓

Thank you.

Your note is now in the QuantJourney inbox.

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.

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.

UniverseXLB · XLE · XLF · XLI · XLK · XLP · XLU · XLV · XLY
Configured period2000-01-03 → 2026-01-01
BenchmarkSPY · SPDR S&P 500 ETF Trust
Initial capitalSee source
Data sourceyfinance
Engine / snapshotPublic engine
Walk-forward / OptimizationMode
workflowGranularity
9Instruments
0Published plots
passedRun status

Dashboard

Compact evidence view built from the same run packet: metrics, plots and run metadata.

9 combinations Evaluated
fast=20, slow=200 Best parameters
0.6744 Observed Sharpe

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