4 · Optimization
Search the parameter space for a good configuration — without fooling yourself.
On the roadmap — not shipped yet
Optimization tunes your system's parameters (strategy, indicator and allocator knobs) toward objective metrics like CAGR or Sharpe. It is the stage where overfitting is most tempting and most dangerous: with enough knobs you can fit any past perfectly and predict nothing. The whole craft is optimizing in a way that generalises.
Optimize for the future, not the past
The core discipline is out-of-sample validation. Never trust a parameter set scored on the same data it was chosen on.
Walk-Forward (rolling)
Split history into consecutive folds. On each fold, optimize on an in-sample (IS) window, freeze the winner, then measure it on the next, unseen out-of-sample (OOS) window. Roll forward and repeat. Stitching the OOS segments gives an equity curve made only of decisions the optimizer never saw the answer to.
Walk-Forward Efficiency (WFE)
OOS performance ÷ IS performance. Near 1.0 means the edge generalises; far below means you fit noise. WFE is the number that tells you whether optimizing this system is even worth doing.
Final fit for deployment
Once WFO gives you confidence, re-optimize once over the full period to get the parameter set you actually deploy. WFO earns the trust; the final fit is what ships.
Single objective vs. multi-objective
Real systems trade off return against risk. Rather than collapsing everything into one weighted score (and arguing about weights), keep objectives separate and look at the Pareto front — the set of configurations where you can't improve one metric without hurting another. Then pick a point deliberately (often the "knee").
Search strategies
| Sampler | When | Cost | |---|---|---| | Grid | Few parameters, want full coverage | Explodes combinatorially | | Random | Many parameters, good coverage cheaply | Tunable budget | | NSGA-II (evolutionary) | Multi-objective, adaptive search | Efficient per objective |
Budget is a design decision
Runs ≈ folds × sampler-budget. Walk-forward multiplies your compute. Estimate the run count before you start — a careless grid over 6 knobs × 8 folds is tens of thousands of simulations.
The overfitting tells
- A spiky performance surface (great at one exact setting, poor next door) is overfit. You want a plateau — that's the next stage, Sensitivity.
- WFE far below 1.0.
- A parameter set that only works on one fold.
- More parameters than your data can justify.
In Malgot
documentation/optimization.md) reuses the existing simulation queue
(studies / sim_tasks, worker-parallelised) and the per-execution result pipeline:
- Grid + Random first (Phase 1), NSGA-II after (Phase 2).
- Metrics-only runs (no heavy archives) so sweeps stay cheap.
- Parameter values are overridden per candidate — your saved value tables are never mutated, and per-sleeve scoping keeps two sleeves of the same indicator independent.
- Result UI: a live run-count estimate, a status grid, per-fold breakdown, a final Pareto-front scatter, and click-through to the normal Trading-State Detail view for any run.
Practise it today, manually: duplicate a strategy with different parameter values, Quick-Sim each over an IS window, then re-run the best over a later window you never looked at. That's a one-fold walk-forward by hand — the same discipline, without the automation.
