Monte Carlo Simulation
Monte Carlo simulation generates thousands of possible outcomes to show the range of results. Learn trade resampling, drawdown estimates and the limits.
A backtest shows one path through history: one particular order of wins and losses. But the future could unfold in countless other ways. Monte Carlo simulation generates thousands of plausible alternative paths by resampling or randomly generating returns, then measures the distribution of outcomes. It answers questions a single backtest cannot: how bad could the drawdown get, how likely is a losing year, what are the odds of ruin? For option pricing applications, see Monte Carlo Option Pricing.
Common approaches#
| Method | How it works | Captures |
|---|---|---|
| Trade resampling | Shuffle or resample historical trades with replacement | Different orderings of wins and losses |
| Return bootstrapping | Resample daily or monthly returns, often in blocks | Return distribution and some clustering. See Bootstrap and Permutation Tests |
| Parametric simulation | Generate returns from a fitted distribution (normal, Student t, GARCH) | Assumed distribution and volatility dynamics |
| Parameter perturbation | Randomly vary strategy parameters | Sensitivity to settings. See Robustness and Stress Testing |
| Synthetic price paths | Simulate prices and re run the strategy | Behaviour on unseen patterns |
Drawdown analysis#
Risk of ruin and probability estimates#
Monte Carlo makes it easy to estimate:
- Probability of a losing year or losing month.
- Probability of hitting a drawdown limit such as 20%.
- Probability of ruin at different position sizes. See Risk of Ruin.
- Range of final account values after a set number of trades.
- Time to recover from drawdowns.
A simple trade resampling procedure#
- Collect the list of trade returns from the backtest (after costs).
- Draw a random sample of the same size with replacement.
- Compound them into an equity curve using your sizing rules.
- Record statistics: final return, maximum drawdown, longest losing streak.
- Repeat 5,000 to 10,000 times.
- Analyse the distribution of each statistic.
import numpy as np
trades = np.array([...]) # trade returns as fractions, e.g. 0.012
rng = np.random.default_rng(0)
dd = []
for _ in range(10_000):
path = np.cumprod(1 + rng.choice(trades, size=len(trades), replace=True))
peak = np.maximum.accumulate(path)
dd.append(((path - peak) / peak).min())
print(np.percentile(dd, [50, 5, 1]))
Limits#
| Limitation | Explanation |
|---|---|
| Garbage in, garbage out | If the backtest is overfit or biased, simulations inherit the problem |
| Independence assumption | Simple resampling ignores clustering of losses; block methods help |
| No new regimes | Resampling cannot create market conditions absent from history. See Structural Breaks and Regime Changes |
| Fat tails | Parametric normal simulations understate extremes. See Fat Tails |
| False precision | Thousands of simulations can look authoritative while resting on shaky inputs |
Monte Carlo vs stress testing#
Monte Carlo explores the range of outcomes implied by your data or assumptions. Stress testing deliberately imposes extreme scenarios, such as a 2008 style crash or a sudden volatility spike, that may not appear in your sample. Use both. See Stress Testing and Scenario Analysis.
Using results for sizing#
A practical approach is to choose position size so that the 95th percentile simulated drawdown stays within the largest drawdown you could tolerate without abandoning the strategy. If simulations show a 1 in 20 chance of a 30% drawdown and your limit is 20%, cut risk per trade by roughly a third and rerun the simulation. See Maximum Drawdown.
Frequently asked questions#
What is Monte Carlo simulation in trading?#
A method that generates many alternative sequences of returns or trades to estimate the range of possible outcomes, such as drawdowns and final returns.
How many Monte Carlo runs do I need?#
Typically several thousand, such as 5,000 to 10,000, which gives stable estimates of most percentiles.
Can Monte Carlo prove a strategy will work?#
No. It shows the range of outcomes implied by past data and assumptions, but cannot fix biases in the backtest or predict new market regimes.
Next, learn to choose parameters without overfitting in Parameter Optimization.
3 quick questions on this lesson. Get them all right to finish it.
Turn on JavaScript to take the quiz.
Mentioned in
- Backtesting MethodologyResearch and Backtesting
- P-Hacking and Multiple TestingResearch and Backtesting
- Quant Trading Learning PathStart Here
- Random VariablesMath and Statistics
- Student's t-DistributionMath and Statistics
- Empirical and Mixture DistributionsMath and Statistics