1. Trading Strategy Optimization Overview

Optimization searches the parameter space for combinations that improve the objective function (e.g., maximizing Sharpe ratio). In essence, it is repeated backtesting plus objective-function comparison.

1.1. Overview

  • Purpose: Within the strategy’s tunable parameter ranges, use search or optimization algorithms to find better-performing parameters (such as moving-average periods or thresholds).

  • Relation to backtesting: Optimization = many backtests (one parameter set each) + compare and rank by the objective function (e.g., Sharpe ratio or drawdown), then pick the best or Top-K sets.

1.2. Optimization Workflow Overview

  1. Set parameter space and objective: The strategy’s Parameter objects and par_range define the search space; the objective function is set in configuration (e.g., maximize Sharpe ratio).

  2. Choose an optimization algorithm: opti_method can be grid, montecarlo, GA, SA, PSO, bayesian, and others.

  3. qt.run(mode=2): Run strategy optimization.

  4. Read results and best parameters: Extract the best parameter combination and Top-K results from the returned object.

1.3. Chapter Guide in This Section

  • 2. How to Run Strategy Optimization — Entry point, optimization algorithms and run-parameter lists, parameter space, and a minimal example.

  • 3. Optimization Algorithms: Differences and Use Cases — Algorithm comparison and selection advice.

  • 4. Optimization Result Structure and Access — Return values, result fields, and reading best and Top-K results.

  • 5. Analyzing and Using Optimization Results — Result analysis, objectives and constraints, applying best parameters to the strategy, and caveats.

For more algorithm details, see the optimization references (e.g., references/5-optimize-strategy.md).