Learn Monte Carlo simulation of returns
6.2.10· Stock-Market › Backtesting Frameworks
Core Concept
Yeh approach kyun?
- Reality check: Historical backtest = sample size of 1. Monte Carlo = sample size of 10,000.
- Tail risk: Un worst 5% scenarios ko reveal karta hai jo aapke data window mein nahi dikh sakte.
- Robustness: Agar aapki strategy 40% simulations mein fail karti hai, toh woh fragile hai—chahe historical backtest achha dikhta ho.
Mathematical Foundation
Geometric Brownian Motion (GBM)
Zyada tar Monte Carlo return simulations Geometric Brownian Motion use karte hain, jo stock prices ka standard model hai:
Har term ko decode karo:
- = time par stock price
- = drift (expected annualized return, e.g., 0.08 for 8%)
- = volatility (returns ka annualized standard deviation, e.g., 0.20 for 20%)
- = Wiener process increment (normal distribution se random shock)
- = tiny time step
Yeh form kyun? multiplier returns ko proportional banata hai: $100 ke stock par 10% move = $10, lekin $200 ke stock par = $20. Yeh reality se match karta hai—stocks percentages mein move karte hain, fixed dollars mein nahi.
Discrete-Time Solution
Hum continuous simulate nahi kar sakte, isliye hum discretize karte hain. Ek time step par analytical solution hai:
jahan ek standard normal random variable hai.
Scratch se derivation:
-
Itô's lemma apply karo par:
-
GBM equation substitute karo:
term kyun? Yeh Itô correction hai. Variance khud drift mein contribute karta hai kyunki (quadratic variation). Iske bina, hum growth overestimate kar lete.
-
se tak integrate karo:
-
Random walk property: , isliye:
-
Dono sides ko exponentiate karo:
Units check:
- aur annualized hain, years mein hai (e.g., daily ke liye 1/252).
- ki units hain (dimensionless).
Data se Parameters Estimate Karna
Given historical daily returns :
-
Sample mean (annualized):
-
Sample volatility (annualized):
252 se multiply kyun karte hain? Returns time ke saath linearly scale hote hain (independent increments add hote hain), lekin volatility ke saath scale hoti hai (variance add hota hai, SD variance ka square root hai).
Volatility ke liye kyun? Unbiased sample variance ke liye Bessel's correction.
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
Yeh step kyun? Har path ek independent "what-if" scenario hai. Collection dikhata hai ki aapki strategy kis range of outcomes ka saamna kar sakti hai.
Given:
- , ,
- Random draws: ,
Day 1:
Negative exponent kyun? Negative ka matlab hai is din below-average return (bad luck).
Day 2:
252 days × 10,000 paths ke liye repeat karo.
Results Interpret Karna
-
Expected terminal value: Saare final prices ka mean
-
Value at Risk (95% VaR): 5th percentile loss
- Agar 5th percentile $380 hai, VaR = $450 - $380 = $70
-
Probability of profit: Un paths ka fraction jahan
-
Maximum drawdown distribution: Saare paths mein worst peak-to-trough decline ke percentiles
Yeh kyun matter karte hain?
- Mean average outcome batata hai (lekin averages jhooth bolte hain—aap EK path experience karte hain, average nahi).
- VaR downside quantify karta hai: "20 mein se 19 scenarios mein, main itne se zyada nahi khounga."
- Profit probability decision-makers ke liye intuitive hai.
Scenario: Aapke paas ek momentum strategy hai: "50-day MA > 200-day MA hone par Buy karo."
Historical backtest (2015–2023): 12% annual return, max drawdown 18%.
Monte Carlo validation:
- Estimate karo , historical returns se.
- Simulate karo 10,000 price paths.
- Apply karo apne strategy rules har path par.
- Record karo return aur max drawdown har simulation ke liye.
Results:
- Median return: 9% (historical 12% se kharab—overfitting alert!)
- 5th percentile return: -15% (aapki strategy badly blow up kar sakti hai)
- 2,300 paths (23%) mein, max drawdown 30% se zyada tha
Yeh step kyun important hai: Historical backtest lucky tha. Monte Carlo reveal karta hai ki aapki strategy usse zyada risky hai jitni dikhti thi. Ab aap position sizing adjust kar sakte hain ya stop-losses add kar sakte hain.
Common Mistakes
Kyun sahi lagta hai: Simple multiplication, "average" ke baare mein intuition se match karta hai.
Kyun galat hai: Returns multiplicatively compound hote hain, additively nahi. Geometric mean volatility drag account karta hai. Agar aap 50% gain karo phir 50% lose karo, aap 25% down hain, flat nahi.
Fix:
ya directly GBM se log-returns formula use karo.
Kyun sahi lagta hai: "Bas drift plus random shock add karo."
Kyun galat hai: Yeh systematically price growth overestimate karta hai. Missing term yeh account karta hai ki variance khud ek drag ki tarah kaam karta hai (exponentials ke liye Jensen's inequality).
Result: Aapke simulated returns annually ~ zyada honge. ke liye, yeh 2% annual overestimation hai—time ke saath bahut bada!
Standard GBM kyun fail karta hai: 2008 crash normal assumptions ke under ek "20-sigma event" tha—universe ke lifetime mein ek baar hona chahiye. Lekin hua.
Fix: ke liye Student's t-distribution use karo (heavier tails), ya jump-diffusion models jo sudden crash components add karte hain:
jahan ek Poisson jump process hai (rare, large shocks).
Recall Feynman: 12-Saal ke Bacche Ko Samjhao
Socho tum ek video game khel rahe ho jahan tumhare character ki health bar randomly upar-neeche jaati hai. Monte Carlo simulation aise hai jaise woh game 10,000 baar khelo yeh dekhne ke liye: "Main kitni baar end tak survive karta hoon? Meri health usually kitni hoti hai? Sabse bura kya hua?"
Stocks ke liye, hum EXACT future nahi jaante, lekin hum history se "game rules" jaante hain: stocks average par lagbhag 8% per year upar jaate hain, lekin raaste mein lagbhag 20% upar-neeche hilte hain (ise volatility kehte hain). Toh hum ek computer use karte hain 10,000 "pretend futures" khelne ke liye jo same rules follow karte hain—same average, same hilaavahat—lekin har baar random wiggles alag hoti hain.
Kyun? Kyunki agar aap sirf woh dekho jo ACTUALLY hua (ek game), toh shayad aap lucky rahe ho. Shayad tumhara stock 20% upar gaya lekin 10 mein se 8 alternate universes mein woh crash ho jaata. Monte Carlo tumhe saare woh alternate universes dikhata hai taaki tum jaan sako ki tumhari strategy SACH MEIN achhi hai ya bas lucky rahi.
Active Recall Flashcards
#flashcards/stock-market
Backtesting mein Monte Carlo simulation ka purpose kya hai? :: Hazaaron plausible alternate price paths generate karna jo historical data ke same statistical properties (mean, volatility) rakhte hain, taaki ek single historical backtest par rely karne ki bajay outcomes ki distribution pata chale.
Geometric Brownian Motion (GBM) kya hai?
Agli price simulate karne ke liye discrete-time GBM formula likho.
GBM drift mein term kyun zaroori hai?
Daily volatility ko annualize kaise karte hain?
95% confidence par Value at Risk (VaR) kya hai?
Ek strategy jo backtest mein achhi lagti hai, Monte Carlo validation mein kyun fail ho sakti hai?
Stock simulation ke liye GBM ki main limitation kya hai?
Monte Carlo mein fat-tails problem kaise fix karo?
Geometric mean return kya hai, aur yeh arithmetic mean se kyun alag hai?
Connections
- 6.2.1-Walk-forward-analysis: Walk-forward testing ke liye future out-of-sample periods simulate karne ke liye Monte Carlo use karo.
- 6.2.8-Sharpe-ratio-calculation: Consistency assess karne ke liye Monte Carlo paths mein Sharpe ratio distribution calculate karo.
- 6.1.4-Maximum-drawdown-analysis: Monte Carlo sirf historical max ki jagah full drawdown distribution generate karta hai.
- 5.3.5-Value-at-Risk-VaR: VaR directly Monte Carlo percentiles se compute hoti hai.
- 4.2.3-Volatility-clusteringGARCH: Advanced models simulations mein time-varying ke liye GARCH use karte hain.
- 7.1.2-Position-sizing-Kelly-criterion: Monte Carlo Kelly fraction optimize karne ke liye bahut saare paths mein position sizes test karta hai.
- 2.1.6-Log-returns-vs-simple-returns: GBM naturally log-returns ke saath kaam karta hai; ensure karo ki data preprocessing match kare.
"Bhagwan par bharosa. Baaki sab Monte Carlo simulations laayein." — W. Edwards Deming se adapted