When to Use
Invoke this skill after optimizing strategy parameters. A strategy whose Sharpe jumps from 0.5 to 3.0 with a $\pm 1%$ parameter tweak is overfit. This skill systematically perturbs parameters across a grid and measures the gradient of Sharpe ratio to distinguish fragile peaks from robust plateaus.
It is a screen, not a certificate. A plateau verdict says the optimum survives a one-step parameter perturbation. It says nothing about out-of-sample performance, regime stability, or whether the Sharpe is real.
When NOT to Use
- Not a Sharpe deflation.
best_sharpe is the maximum over N grid points and is upward-biased by selection even when true skill is zero — it is a maximum of N noisy estimates. Correcting it needs the trial count and the return distribution's higher moments. total_grid_points is reported so you can do that downstream; see factor-research-multiple-testing-correction and the Deflated Sharpe Ratio reference in references/standards.md.
- Not a multi-parameter analysis. The implementation sweeps one parameter at a time and cannot see interaction effects. A pair of parameters can each look like a plateau in isolation while the joint surface is a knife edge. Sweep a full grid and inspect the surface for that.
- Not a substitute for out-of-sample testing. Plateau stability is measured entirely in-sample. Use
walk-forward-validation-setup and multi-year-regime-coverage-requirement for the out-of-sample question.
- Not meaningful on a near-zero Sharpe. A flat grid at Sharpe 0.01 is perfectly stable and worthless. Set
min_viable_sharpe to your actual deployment hurdle; the 0.0 default only rules out strategies that lose money everywhere.
- Not usable with a noisy backtest you have not characterised. If re-running the same configuration moves Sharpe by 20%, a 15% degradation threshold measures your simulator's noise, not the strategy's fragility.
Prerequisites
- Strategy with tunable parameters (e.g., lookback window, entry threshold).
- Backtest engine that accepts parameter overrides and returns performance metrics.
- A deterministic backtest, or a known run-to-run Sharpe dispersion to calibrate the degradation threshold against (see
backtest-determinism-and-reproducibility).
- A parameter range wide enough to bracket the optimum on both sides.
Workflow
- Define Parameter Grid: Specify parameter ranges and step sizes. Range matters more than resolution: if the best value lands on the first or last point, the optimum is not bracketed and the analyzer returns
EDGE_OPTIMUM rather than a verdict.
- Run Grid Sweep: Execute backtest for each parameter combination. A non-finite Sharpe (zero return volatility, empty trade log) is rejected rather than swept in — every comparison against NaN is False, so an unguarded NaN silently produces a "robust" result.
- Compute Neighbourhood Degradation: Order the grid by parameter value, locate the best point, and measure the relative Sharpe drop to its worst immediate neighbour:
$$\text{degradation} = \frac{S_{\text{best}} - \min(S_{\text{left}}, S_{\text{right}})}{S_{\text{best}}}$$
This is a dimensionless ratio, not $\Delta\text{Sharpe}/\Delta\text{Param}$. A raw derivative is not thresholdable across parameters, because 0.2 Sharpe per lookback-day and 0.2 Sharpe per threshold-unit are not comparable quantities.
- Classify: The verdict ladder runs viability → coverage → bracketing → degradation, and stops at the first failure:
NOT_VIABLE — best Sharpe at or below min_viable_sharpe. A flat grid of losses is stable, not robust.
INSUFFICIENT_GRID — fewer than 3 points; a plateau needs a neighbour on each side.
EDGE_OPTIMUM — best point is at the boundary, so half its neighbourhood was never observed.
FRAGILE_PEAK / ROBUST_PLATEAU — degradation above or within max_neighborhood_degradation_pct.
- Deflate Before Believing the Number: Carry
total_grid_points forward as the trial count and correct best_sharpe for selection bias before treating it as an expectation.
Full procedure: see references/workflows.md.
Standards reference: see references/standards.md.
Printable pre-flight checklist: see assets/checklist.md.
Common Pitfalls
- Single-Parameter Analysis Only: Ignoring interaction effects between correlated parameters. This tool is itself single-parameter — see "When NOT to Use".
- Too Fine Grid: Overfitting the grid search itself. Every extra grid point is another trial inflating the maximum.
- Unordered Grid: Neighbours must be taken in parameter order. Indexing into the caller's list order lets the same set of results be classified either way depending on how it was assembled — this analyzer sorts by parameter value to prevent it.
- Unbracketed Optimum: A monotonically improving parameter puts the best value at the edge of whatever range you happened to sweep. That is a statement about your grid, not about a plateau. Widen the range.
- A Stable Loser Reported as Robust: If degradation is only computed when the best Sharpe is positive, a grid where every configuration loses money scores zero degradation and passes the plateau test.
- Treating a Plateau as Permission to Deploy: The verdict covers one parameter, in-sample, at one grid resolution. It is one input to a deployment decision, not the decision.
- Threshold Below Simulator Noise: A degradation threshold tighter than your backtest's own run-to-run dispersion flags noise as fragility.
Verification
- Run a monotonically increasing Sharpe curve and confirm the verdict is
EDGE_OPTIMUM, not a plateau.
- Run a grid where every Sharpe is negative and confirm the verdict is
NOT_VIABLE.
- Shuffle a grid's list order and confirm the verdict, degradation and best parameters are unchanged.
- Assert the hand-computed boundary: best 4.0 against worst neighbour 3.0 is exactly $(4-3)/4 = 0.25$ degradation, which is robust at a 0.25 threshold and fragile at anything tighter.
- Confirm a single grid point returns
INSUFFICIENT_GRID rather than a robustness verdict.
- Run
python -m unittest discover -s skills/backtest-parameter-sensitivity-analysis/scripts — 100% pass rate.
Related Skills
walk-forward-validation-setup
multi-year-regime-coverage-requirement
factor-research-multiple-testing-correction
monte-carlo-strategy-robustness-testing
backtest-determinism-and-reproducibility
1---2name: backtest-parameter-sensitivity-analysis3description: >-4 Use after optimising strategy parameters, to perturb them across a grid and measure5 how fast Sharpe decays; separates a fragile overfit peak from a genuine plateau. It6 does not deflate the selected Sharpe for trial count.7license: Apache-2.08metadata:9 source: https://skillmd.com/skills/himanshuj16/backtest-parameter-sensitivity-analysis10 domain: algorithmic-trading11 subdomain: backtesting-methodology12 tags: backtesting-methodology, parameter-sensitivity, overfitting-detection, grid-search, robustness, sharpe-surface13 brokers_frameworks: "Parameter Sensitivity Analyzer; Python"14 version: "2.0.0"15 author: algo-trading-skills-contributors16---1718## When to Use1920Invoke this skill after optimizing strategy parameters. A strategy whose Sharpe jumps from 0.5 to 3.0 with a $\pm 1\%$ parameter tweak is overfit. This skill systematically perturbs parameters across a grid and measures the gradient of Sharpe ratio to distinguish fragile peaks from robust plateaus.2122It is a **screen, not a certificate**. A plateau verdict says the optimum survives a one-step parameter perturbation. It says nothing about out-of-sample performance, regime stability, or whether the Sharpe is real.2324## When NOT to Use2526- **Not a Sharpe deflation.** `best_sharpe` is the maximum over N grid points and is upward-biased by selection even when true skill is zero — it is a maximum of N noisy estimates. Correcting it needs the trial count and the return distribution's higher moments. `total_grid_points` is reported so you can do that downstream; see `factor-research-multiple-testing-correction` and the Deflated Sharpe Ratio reference in `references/standards.md`.27- **Not a multi-parameter analysis.** The implementation sweeps one parameter at a time and cannot see interaction effects. A pair of parameters can each look like a plateau in isolation while the joint surface is a knife edge. Sweep a full grid and inspect the surface for that.28- **Not a substitute for out-of-sample testing.** Plateau stability is measured entirely in-sample. Use `walk-forward-validation-setup` and `multi-year-regime-coverage-requirement` for the out-of-sample question.29- **Not meaningful on a near-zero Sharpe.** A flat grid at Sharpe 0.01 is perfectly stable and worthless. Set `min_viable_sharpe` to your actual deployment hurdle; the 0.0 default only rules out strategies that lose money everywhere.30- **Not usable with a noisy backtest you have not characterised.** If re-running the same configuration moves Sharpe by 20%, a 15% degradation threshold measures your simulator's noise, not the strategy's fragility.3132## Prerequisites3334- Strategy with tunable parameters (e.g., lookback window, entry threshold).35- Backtest engine that accepts parameter overrides and returns performance metrics.36- A deterministic backtest, or a known run-to-run Sharpe dispersion to calibrate the degradation threshold against (see `backtest-determinism-and-reproducibility`).37- A parameter range wide enough to **bracket** the optimum on both sides.3839## Workflow40411. **Define Parameter Grid**: Specify parameter ranges and step sizes. Range matters more than resolution: if the best value lands on the first or last point, the optimum is not bracketed and the analyzer returns `EDGE_OPTIMUM` rather than a verdict.422. **Run Grid Sweep**: Execute backtest for each parameter combination. A non-finite Sharpe (zero return volatility, empty trade log) is rejected rather than swept in — every comparison against NaN is False, so an unguarded NaN silently produces a "robust" result.433. **Compute Neighbourhood Degradation**: Order the grid **by parameter value**, locate the best point, and measure the relative Sharpe drop to its worst immediate neighbour:44 $$\text{degradation} = \frac{S_{\text{best}} - \min(S_{\text{left}}, S_{\text{right}})}{S_{\text{best}}}$$45 This is a dimensionless ratio, not $\Delta\text{Sharpe}/\Delta\text{Param}$. A raw derivative is not thresholdable across parameters, because 0.2 Sharpe per lookback-day and 0.2 Sharpe per threshold-unit are not comparable quantities.464. **Classify**: The verdict ladder runs viability → coverage → bracketing → degradation, and stops at the first failure:47 - `NOT_VIABLE` — best Sharpe at or below `min_viable_sharpe`. A flat grid of losses is stable, not robust.48 - `INSUFFICIENT_GRID` — fewer than 3 points; a plateau needs a neighbour on each side.49 - `EDGE_OPTIMUM` — best point is at the boundary, so half its neighbourhood was never observed.50 - `FRAGILE_PEAK` / `ROBUST_PLATEAU` — degradation above or within `max_neighborhood_degradation_pct`.515. **Deflate Before Believing the Number**: Carry `total_grid_points` forward as the trial count and correct `best_sharpe` for selection bias before treating it as an expectation.5253> Full procedure: see `references/workflows.md`.54> Standards reference: see `references/standards.md`.55> Printable pre-flight checklist: see `assets/checklist.md`.5657## Common Pitfalls5859- **Single-Parameter Analysis Only**: Ignoring interaction effects between correlated parameters. This tool is itself single-parameter — see "When NOT to Use".60- **Too Fine Grid**: Overfitting the grid search itself. Every extra grid point is another trial inflating the maximum.61- **Unordered Grid**: Neighbours must be taken in parameter order. Indexing into the caller's list order lets the same set of results be classified either way depending on how it was assembled — this analyzer sorts by parameter value to prevent it.62- **Unbracketed Optimum**: A monotonically improving parameter puts the best value at the edge of whatever range you happened to sweep. That is a statement about your grid, not about a plateau. Widen the range.63- **A Stable Loser Reported as Robust**: If degradation is only computed when the best Sharpe is positive, a grid where every configuration loses money scores zero degradation and passes the plateau test.64- **Treating a Plateau as Permission to Deploy**: The verdict covers one parameter, in-sample, at one grid resolution. It is one input to a deployment decision, not the decision.65- **Threshold Below Simulator Noise**: A degradation threshold tighter than your backtest's own run-to-run dispersion flags noise as fragility.6667## Verification6869- Run a monotonically increasing Sharpe curve and confirm the verdict is `EDGE_OPTIMUM`, not a plateau.70- Run a grid where every Sharpe is negative and confirm the verdict is `NOT_VIABLE`.71- Shuffle a grid's list order and confirm the verdict, degradation and best parameters are unchanged.72- Assert the hand-computed boundary: best 4.0 against worst neighbour 3.0 is exactly $(4-3)/4 = 0.25$ degradation, which is robust at a 0.25 threshold and fragile at anything tighter.73- Confirm a single grid point returns `INSUFFICIENT_GRID` rather than a robustness verdict.74- Run `python -m unittest discover -s skills/backtest-parameter-sensitivity-analysis/scripts` — 100% pass rate.7576## Related Skills7778- `walk-forward-validation-setup`79- `multi-year-regime-coverage-requirement`80- `factor-research-multiple-testing-correction`81- `monte-carlo-strategy-robustness-testing`82- `backtest-determinism-and-reproducibility`83---