20 — Backtest & Validate

Monte Carlo Simulation#

Simulation✓ Mathematical
◆ The PatternSimulating thousands of paths — confidence bands on strategy performance

Monte Carlo generates thousands of possible equity paths by resampling or simulating returns. Instead of one backtest (which is one path through history), you get a distribution of outcomes. The 5th percentile shows your realistic worst case.

Pathᵢ(t) = Πd=1t (1 + rd(i))
Each path is a product of randomly sampled daily returns. N paths give a fan of possible outcomes.
// Interactive — simulated equity paths with confidence bands
Paths100
5th %ile
# Python — Monte Carlo equity simulation
import numpy as np

daily_returns = df['returns'].values
n_sims, n_days = 1000, 252

# Resample with replacement
paths = np.zeros((n_sims, n_days))
for i in range(n_sims):
    sampled = np.random.choice(daily_returns, size=n_days)
    paths[i] = np.cumprod(1 + sampled)

# Confidence bands
p5  = np.percentile(paths, 5, axis=0)
p95 = np.percentile(paths, 95, axis=0)
Limitation: Monte Carlo assumes returns are i.i.d. Real markets have autocorrelation, volatility clustering, and regime changes. Use block bootstrap to preserve some time structure.
← Previous
Walk-Forward Validation
Open in the full reader, with the topic sidebar →