SEN Sensitivity Analysis
How fragile is your strategy? Parameter perturbation testing
Learning Objectives
- •Understand sensitivity analysis and why it matters for strategy resilience
- •Learn how to perturb parameters systematically
- •Interpret sensitivity results for strategy confidence
Explain Like I'm 5
Sensitivity analysis asks: "If my parameters are slightly wrong, does everything fall apart?" If changing max_depth from 6 to 5 or 7 destroys your strategy, it's fragile and probably overfit. If it barely matters, the strategy is robust. You want insensitivity to small parameter changes.
Think of It This Way
Sensitivity analysis is like testing a recipe. If the cake is ruined by adding one extra gram of sugar, that's a fragile recipe. If it tastes great whether you use 95g or 105g, it's forgiving. Good strategies, like good recipes, aren't finicky about exact parameters.
1Parameter Sensitivity
2Multi-Parameter Sensitivity
3Sensitivity Heatmaps in Practice
Parameter Sensitivity: Win Rate vs Max Depth
4When Sensitivity Analysis Saves You
Key Formulas
Sensitivity Coefficient
Normalized sensitivity: percentage change in performance per percentage change in parameter θᵢ. SC close to 0 = insensitive (good). SC ≫ 1 = highly sensitive (concerning).
Hands-On Code
Parameter Sensitivity Analysis
import numpy as np
def sensitivity_analysis(base_params, param_name, test_values,
run_backtest_fn):
"""Test strategy sensitivity to one parameter."""
results = []
for value in test_values:
params = base_params.copy()
params[param_name] = value
perf = run_backtest_fn(params)
results.append({'value': value, **perf})
perfs = [r['win_rate'] for r in results]
base_idx = len(test_values) // 2
base_perf = perfs[base_idx]
max_deviation = max(abs(p - base_perf) for p in perfs)
print(f"=== SENSITIVITY: {param_name} ===")
for r in results:
bar = "█" * int(r['win_rate'] * 100)
marker = " ← base" if r['value'] == base_params[param_name] else ""
print(f" {r['value']:>8}: {r['win_rate']:.1%} {bar}{marker}")
print(f"Max deviation: {max_deviation:.2%}")
print(f" {'[PASS] Stable' if max_deviation < 0.02 else '[WARN] Sensitive'}")
return resultsTest each parameter at multiple values around the base. If performance barely changes, the strategy is resilient. Sharp changes indicate fragility — proceed with extreme caution.
Knowledge Check
Q1.Your strategy shows a broad performance plateau when varying max_depth from 4 to 8. What does this mean?
Assignment
Run sensitivity analysis for 3 key parameters of your strategy. Create heatmaps for 2-parameter combinations. Identify any fragile parameters and assess whether the strategy is stable enough for live deployment.