Learn Monte Carlo simulation of returns
Core Concept
Why this approach?
- Reality check: Historical backtest = sample size of 1. Monte Carlo = sample size of 10,000.
- Tail risk: Reveals the worst5% of scenarios that might not appear in your data window.
- Robustness: If your strategy fails in 40% of simulations, it's fragile—even if the historical backtest looked good.
Mathematical Foundation
Geometric Brownian Motion (GBM)
Most Monte Carlo return simulations use Geometric Brownian Motion, the standard model for stock prices:
Decode each term:
- = stock price at time
- = drift (expected annualized return, e.g., 0.08 for 8%)
- = volatility (annualized standard deviation of returns, e.g., 0.20 for 20%)
- = Wiener process increment (random shock from normal distribution)
- = tiny time step
Why this form? The multiplier makes returns proportional: a 10% move on a 10, but on a 20. This matches reality—stocks move in percentages, not fixed dollars.
Discrete-Time Solution
We can't simulate continuous , so we discretize. The analytical solution over one time step is:
where is a standard normal random variable.
Derivation from scratch:
-
Apply Itô's lema to :
-
Substitute the GBM equation:
Why the term? This is the Itô correction. Variance itself contributes to drift because (quadratic variation). Without it, we'd overestimate growth.
-
Integrate from to :
-
Random walk property: , so:
-
Exponentiate both sides:
Units check:
- and are annualized, is in years (e.g., 1/252 for daily).
- has units of (dimensionless).
Estimating Parameters from Data
Given historical daily returns :
-
Sample mean (annualized):
-
Sample volatility (annualized):
Why multiply by 252? Returns scale linearly with time (adding independent increments), but volatility scales with (variance adds, SD is square root of variance).
Why for volatility? Bessel's correction for unbiased sample variance.
Simulation Algorithm
Setup:
- Historical data: SPY daily returns, 2010–2023
- Estimated: ,
- Simulation horizon: 252 days (1 year)
- Number of paths: 10,000
Algorithm:
For each simulation path i = 1 to 10,000:
1. Set S[0] = current_price (e.g., $450)
2. For each day t = 0 to 251:
a. Draw Z ~ N(0, 1)
b. S[t+1] = S[t] * exp((μ - σ²/2)/252 + σ/√252 * Z)
3. Record final value S[252] and path statistics
Calculate percentiles of final values:5th, 50th, 95th
Why this step? Each path is an independent "what-if" scenario. The collection shows the range of outcomes your strategy might face.
Given:
- , ,
- Random draws: ,
Day 1:
Why the negative exponent? The negative means below-average return this day (bad luck).
Day 2:
Repeat for 252 days × 10,000 paths.
Interpreting Results
-
Expected terminal value: Mean of all final prices
-
Value at Risk (95% VaR): The 5th percentile loss
- If5th percentile is 70
-
Probability of profit: Fraction of paths where
-
Maximum drawdown distribution: Percentiles of worst peak-to-trough decline across paths
Why these matter?
- Mean tells you average outcome (but averages lie—you experience ONE path, not the average).
- VaR quantifies downside: "In 19out of 20 scenarios, I won't lose more than this."
- Profit probability is intuitive for decision-makers.
Scenario: You have a momentum strategy: "Buy when 50-day MA > 200-day MA."
Historical backtest (2015–2023): 12% annual return, max drawdown 18%.
Monte Carlo validation:
- Estimate , from historical returns.
- Simulate 10,000 price paths.
- Apply your strategy rules to each path.
- Record return and max drawdown for each simulation.
Results:
- Median return: 9% (worse than historical12%—overfitting alert!)
- 5th percentile return: -15% (your strategy can blow up badly)
- In 2,300 paths (23%), max drawdown exceeded 30%
Why this step matters: The historical backtest was lucky. Monte Carlo reveals your strategy is riskier than it appeared. Now you can adjust position sizing or add stop-losses.
Common Mistakes
Why it feels right: Simple multiplication, matches intuition about "average."
Why it's wrong: Returns compound multiplicatively, not additively. The geometric mean accounts for volatility drag. If you gain 50% then lose 50%, you're down 25%, not flat.
The fix:
or use the log-returns formula from GBM directly.
Why it feels right: "Just add drift plus random shock."
Why it's wrong: This systematically overestimates price growth. The missing term accounts for the fact that variance itself acts as a drag (Jensen's inequality for exponentials).
Result: Your simulated returns will be ~ too high annually. For , that's 2% annual overestimation—huge over time!
Why standard GBM fails: The2008 crash was a "20-sigma event" under normal assumptions—should happen once per universe lifetime. But it happened.
The fix: Use Student's t-distribution for (heavier tails), or jump-diffusion models that add sudden crash components:
where is a Poisson jump process (rare, large shocks).
Recall Feynman Explain-to-a-12-Year-Old
Imagine you're playing a video game where your character's health bar goes up and down randomly. Monte Carlo simulation is like playing that game 10,000 times to see: "How often do I survive to the end? What's my health usually at? What's the worst that happened?"
For stocks, we don't know the EXACT future, but we know the "game rules" from history: stocks tend to go up about 8% per year on average, but they wigle up and down about 20% along the way (that's called volatility). So we use a computer to play10,000 "pretend futures" that follow those same rules—same average, same wigliness—but each time the random wiggles are different.
Why? Because if you only look at what ACTUALLY happened (one game), you might've gotten lucky. Maybe your stock went up 20% but in8 out of 10 alternate universes it would've crashed. Monte Carlo shows you all those alternate universes so you know if your strategy is REALLY good or just got lucky.
Active Recall Flashcards
#flashcards/stock-market
What is the purpose of Monte Carlo simulation in backtesting? :: To generate thousands of plausible alternate price paths with the same statistical properties (mean, volatility) as historical data, revealing the distribution of outcomes instead of relying on a single historical backtest.
What is Geometric Brownian Motion (GBM)?
Write the discrete-time GBM formula for simulating the next price.
Why is the term necessary in the GBM drift?
How do you annualize daily volatility?
What is Value at Risk (VaR) at 95% confidence?
Why might a strategy that backtests well fail in Monte Carlo validation?
What is the main limitation of GBM for stock simulation?
How do you fix the fat-tails problem in Monte Carlo?
What is the geometric mean return, and why does it differ from arithmetic mean?
Connections
- 6.2.1-Walk-forward-analysis: Use Monte Carlo to simulate future out-of-sample periods for walk-forward testing.
- 6.2.8-Sharpe-ratio-calculation: Calculate Sharpe ratio distribution across Monte Carlo paths to assess consistency.
- 6.1.4-Maximum-drawdown-analysis: Monte Carlo generates the full drawdown distribution, not just historical max.
- 5.3.5-Value-at-Risk-VaR: VaR is directly computed from Monte Carlo percentiles.
- 4.2.3-Volatility-clusteringGARCH: Advanced models use GARCH for time-varying in simulations.
- 7.1.2-Position-sizing-Kelly-criterion: Monte Carlo tests position sizes across many paths to optimize Kelly fraction.
- 2.1.6-Log-returns-vs-simple-returns: GBM naturally works with log-returns; ensure data preprocessing matches.
"In God we trust. All others must bring Monte Carlo simulations." — Adapted from W. Edwards Deming
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Monte Carlo simulationek powerful technique hai jo tumhe yeh samajhne mein mad karta hai kiagar history thodi alag hoti, toh tumhara trading strategy kaisa perform karta. Socho tumne 2015 se 2023 tak apni strategy ka backtest kiya aur usme acha return mila—lekin kya yeh luck tha ya skill? Monte Carlo yeh answer deta hai.
Iska kaam simple hai: hum historical data se do chezein nikalte hain—average return (mu) aur volatility (sigma). Phir computer se 10,000 fake price paths generate karte hain jo same statistical properties follow karte hain. Matlab har path realistic hai, bas random wiggles alag hain. Har path par tumhari strategy chalao aur dekho kitne paths mein profit hua, kitne mein loss. Agar 30% paths mein tumhara strategy fail ho raha hai toh samajh jao ki backtest lucky tha, strategy weak hai.
GBM (Geometric Brownian Motion) formula use hota hai: price exponential grow karti hai with drift aur random shocks. Ek important term hai minus sigma-squared by 2—yeh volatility drag ko account karta hai.Agar yeh miss karo toh tumhare simulated returns artificially high ho jayenge aur tum overconfident feel karoge. Monte Carlo ka sabse bada fayda yeh hai ki tum worst-case scenarios dekh sakte ho (5th percentile), not just average. Risk management ke liye yeh gold hai—tumhe pata chal jayega ki maximum kitna loss ho sakta hai 95% confidence ke sath.
Real markets mein fat tails hote hain (extreme events zyada frequent hain normal distribution ke comparison mein), toh advanced simulations mein Student's t-distribution ya jump-diffusion models use karte hain. But basic GBM bhi kafi useful hai most strategies ke liye. Yad rakho: ek backtest = ek dice roll, Monte Carlo =10,000 dice rolls. Probability tumhare sath hai toh hi trade karo!