Monte Carlo Simulation In Trading

Monte Carlo Simulation In Trading, Investing, and Backtesting Strategies

Monte Carlo simulation in trading and investing is a tool frequently used in blogs and backtests. Can Monte Carlo backtesting be used to measure risk and uncertainty? Yes, it turns out you can use it in the financial markets:

Monte Carlo simulation and backtesting in trading (and investing) is a statistical tool to measure uncertainty and how robust your strategy is for path sequences. The simulations can make a model of the different outcomes of your trades if they had taken a different path or sequence.

By Monte Carlo simulation in trading you get a better understanding of the risk and uncertainty of your trading strategy because Monte Carlo simulation lets you run your backtest thousands of times in different orders.

A backtest is at best a rough approximation of what you might expect in the future. If you do a Monte Carlo simulation you can redraw your equity curve thousands of times (in less than a second) and thus measure how likely you are to replicate your backtest in live trading (given the markets stay the same, which, of course, is highly uncertain because markets are non-stationary).

This article describes what a Monte Carlo simulation is and gives you a practical example from a trading program (Amibroker).

Monte Carlo Simulation for Traders

Trading is all about alternative histories

We can’t judge a result solely on the end result. A good decision can produce a terrible result, and a poor decision could lead to great results. A decision has to be evaluated on the alternative or the opportunity cost. Nassim Nicholas Taleb calls this the alternative histories in his thought-provoking book Fooled By Randomness.

Alternative histories are events that could have happened but didn’t, normally due to chance and randomness. How do we know if a result is due to chance, luck, or randomness? These possible but never realized invisible alternative histories that perhaps could have taken place need to be simulated. What if the past had been slightly different? How will this influence our result?

One way to find out is by using Monte Carlo simulation:

What is Monte Carlo simulation in trading and investing?

Monte Carlo simulation is a statistical technique used in trading to model and analyze the behavior of financial instruments, assets, trading strategies, or portfolios by simulating various random market scenarios to better grasp the performance of the asset or strategy.

Monte Carlo simulation and backtesting has, of course, derived its name from the famous city and casino in Monaco. Monte Carlo is famous for its games involving random events: roulette, craps, blackjack, etc. We can argue the latter is mostly a game of skills, but nevertheless exposed to random card dealings.

Nassim Nicholas Taleb is a strong proponent of Monte Carlo simulation. The reason is that the Monte Carlo simulation lets you get a better grasp of how these alternative histories could have played out and led to completely different results. It simply shows how liable to chance and randomness your trading strategy is. What might the future bring when you start trading live?

The trading strategy’s backtest takes the trades as they happened, but what would have happened if the trade order was reshuffled? What if you had 7 consecutive losers instead of 4? Is it possible that an alternative path had twice the drawdown as the backtest?

Monte Carlo simulation examines a set of alternative trading simulations that potentially could have happened if history might have unfolded slightly differently.

For example, let’s say you had a backtest of a trading strategy that returned these trades: +3%, -1%, +7%,-2%, and +2%. The Monte Carlo simulation then uses those trades and for example reshuffles the trade order to -1%, -2 %, +7%, +2%, and +3%. The latter has two losing trades to start with and thus a higher drawdown. Was your original backtest just luck? The point with a simulation is to detect possible outcomes of the original backtest.

When you see how these alternative histories (or paths) play out, you can make better decisions on how liable you are to randomness and adjust size accordingly. Position sizing matters a lot in trading, something we will cover in a later article.

How do you perform a Monte Carlo simulation backtest?

You perform a Monte Carlo simulation backtest by simulating multiple possible paths for the asset price based on the trading rules, and you can better judge the robustness and how to optimize the strategy. The simulation uses random numbers and simulates the strategy hundreds or thousands of times to make different paths. Based on this, you get a lot of statistics.

The main idea behind a Monte Carlo simulation is to use random numbers to understand the trading system’s characteristics better. This can be done in many ways. Curtis Faith describes two methods in his book Way Of The Turtle:

  • Trade scrambling: By randomly changing the order and start dates of the trades from the actual simulation and then using the percentage gain or loss from the trades to adjust equity curves.
  • Equity curve scrambling: building new equity curves by assembling random portions of the original equity curve.

To give you a better understanding of how this works in practice let’s check out the process with an example:

Monte Carlo simulation in Amibroker – a practical example

You can use Monte Carlo simulation in Amibroker. To better explain, in practice, a Monte Carlo simulation, we can go through an example in Amibroker, but the process is pretty similar in every trading platform/software (we also briefly touch upon Monte Carlo simulation in our Amibroker course).

First, we need to establish the number of runs/paths/sequences/alternative histories. This simply means how many times we want to simulate the trades in a random sequence. It’s recommended to use at least 1 000 runs.

Second, we need to choose that the Monte Carlo simulation in trading takes the trades from the original backtest to create simulation runs. This mode picks randomly trades from the backtest.

Third, the position sizing should most of the time be set to the same as in the original backtest.

This is how the settings for Monte Carlo simulation look like in Amibroker:

Let’s test a strategy that has the following results in a backtest:

  • 533 trades from 1993 until October 2021
  • Annual returns: 14.9%
  • The average gain is 0.8% per trade
  • The win ratio is 74%
  • The average winner is 1.68%
  • The average loss is a negative 1.72%
  • The profit factor is 2.9

All in all, a pretty decent strategy. Let’s apply the Monte Carlo simulation with 10 000 runs based on the settings described above. This returns the following results:

The column named “percentile” is the confidence level – a statistical term. Because the Monte Carlo simulation is based on independent runs, and you will not get the exact same result each time, it’s practical to use statistical confidence levels. The confidence level is the level we can quantify uncertainty based on the sample.

The 10% percentile shows that we can expect the strategy to go bust 10% of the time. Not very promising! But better is that we can expect the strategy to return annual returns of more than 14% 85% of the time (not shown in the table above).

However, the settings in the original backtest were done by using 100% of the equity for each trade (compounding). By using a lower equity allocation the chances for bust are reduced to zero.

What happens if you use leverage? Monte Carlo tells you

Let’s use Monte Carlo simulation to find out what happens to a trading strategy if you employ leverage:

Let’s test by using 2x leverage, ie. 200% of your equity. As expected, the chances of going bust are high:

Monte Carlo simulation in trading
Monte Carlo simulation in trading

How much reliance should you put on a Monte Carlo simulation?

Monte Carlo simulations are a great tool to test your strategies, but our experience indicates you should not put too much emphasis on them. Why is that?

For example, in the example above, we have an 85% chance of getting at least 14.4% annual returns which is way better than the buy and hold, even though we could face the risk of ruin.

The answer to managing risk is to reduce size. Again, we reiterate our best rule for managing risk: always trade a smaller size than you’d like. Don’t be greedy – aim for survival.

The above example involved 100% of your equity. If you reduce the equity to around 70%, you have no chance of ruin, but the annual returns drop 2-3 percentage points. You have to use common sense to find the sweet spot.

Another argument is that a trading strategy can be very good and robust even though it “fails” a Monte Carlo simulation. We have to differentiate between being street smart vs being academic smart:

Furthermore, financial markets are non-stationary. A backtest is unlikely to replicate and markets change and evolve. Again, you have to use some street-smartness in your trading.

Conclusions about Monte Carlo simulation in trading

Simulations are a great tool to measure luck, randomness, and chance. Monte Carlo simulation in trading doesn’t require any time on your end as it’s built into all the existing trading software. Anytime you perform a backtest, we recommend going to the Monte Carlo tab to see the results.

Nevertheless, don’t make hasty decisions based on the thousands of simulations. Use common sense. Markets are non-stationary and will change course frequently.

Monte Carlo Simulation Glossary

Monte Carlo simulation is a mathematical concept that is hard for many to understand – which is understandable.

To help you better understand randomness, robustness, and probabilities, we have put together a glossary that explains the main concepts of Monte Carlo simulation in a few words.

Here you have it (and below the glossary, you will find some recommended reading):

  1. Monte Carlo Simulation: A statistical technique used in trading to model and analyze the behavior of financial instruments or portfolios by simulating various random market scenarios.
  2. Stochastic Process: A mathematical model that describes the random fluctuations in asset prices over time, a key component in Monte Carlo simulations.
  3. Random Walk: A stochastic process where the future price movements of an asset are determined solely by random changes, often used to model stock price movements.
  4. Geometric Brownian Motion: A type of stochastic process used to simulate asset price movements, characterized by drift and volatility parameters.
  5. Drift: The expected return of an asset, used in Monte Carlo simulations to account for the asset’s long-term trend.
  6. Volatility: A measure of the asset’s price variability, used in Monte Carlo simulations to model the uncertainty in future price movements.
  7. Time Step: A discrete interval of time used in Monte Carlo simulations to model the evolution of asset prices.
  8. Path: A single realization of an asset’s price movements in a Monte Carlo simulation.
  9. Risk Factor: A variable or parameter that affects the outcome of a Monte Carlo simulation, often related to market conditions or trading strategies.
  10. Scenario Generation: The process of creating a set of possible future market scenarios for a Monte Carlo simulation.
  11. Historical Simulation: A Monte Carlo approach that uses historical price data to generate future scenarios.
  12. Risk-neutral Measure: A probability measure used in Monte Carlo simulations to price options and other derivatives.
  13. Black-Scholes Model: A mathematical model commonly used in Monte Carlo simulations to price European options.
  14. Asian Option: A type of option whose payoff depends on the average price of an underlying asset over a specified period, often simulated using Monte Carlo methods.
  15. Binomial Model: A discrete-time model used in Monte Carlo simulations to price options, based on the idea of tree-like price movements.
  16. Monte Carlo Estimation: The process of using simulated data to estimate the value of an option or portfolio.
  17. Pricing Model: A mathematical model used in Monte Carlo simulations to calculate the fair value of financial instruments.
  18. Random Number Generator: A software component that generates random numbers used in Monte Carlo simulations to mimic market randomness.
  19. Confidence Interval: A range of values that reflects the uncertainty in Monte Carlo simulation results.
  20. Simulation Horizon: The time period over which Monte Carlo simulations project future asset prices and returns.
  21. Convergence: The process by which the results of a Monte Carlo simulation stabilize as more iterations are performed.
  22. Scenario Analysis: The examination of different simulated scenarios in Monte Carlo simulations to assess risk and potential outcomes.
  23. Portfolio Optimization: The process of using Monte Carlo simulations to find an optimal mix of assets that maximizes returns while managing risk.
  24. Value at Risk (VaR): A risk measurement technique that uses Monte Carlo simulations to estimate the potential loss in a portfolio under adverse conditions.
  25. Risk Management: The use of Monte Carlo simulations to assess and mitigate risks associated with trading strategies.
  26. Efficient Frontier: A concept in portfolio theory that represents the set of portfolios that offer the highest expected return for a given level of risk.
  27. Capital Allocation: The distribution of capital among different trading strategies or assets, often determined using Monte Carlo simulations.
  28. Monte Carlo Methodology: A systematic approach to conducting Monte Carlo simulations, including input parameter selection and result analysis.
  29. Covariance Matrix: A matrix used in Monte Carlo simulations to model the relationships between different assets in a portfolio.
  30. Risk-Adjusted Return: A measure that evaluates the return of an investment relative to its risk, often assessed through Monte Carlo simulations.
  31. Random Seed: An initial value used to start the random number generator in Monte Carlo simulations, ensuring reproducibility.
  32. Greeks: Sensitivity measures (Delta, Gamma, Theta, Vega, and Rho) used in Monte Carlo simulations to assess the impact of changes in asset prices and other factors on option prices.
  33. Path-Dependent Option: An option whose payoff depends on the entire price path of the underlying asset, often simulated using Monte Carlo methods.
  34. Scenario Weighting: The assignment of probabilities to different market scenarios in a Monte Carlo simulation to reflect their likelihood.
  35. Reinvestment Assumption: The assumption in Monte Carlo simulations that cash flows are reinvested at a specified rate.
  36. Correlation Matrix: A matrix used in Monte Carlo simulations to quantify the degree of linear association between different assets in a portfolio.
  37. Monte Carlo VaR: The application of Monte Carlo simulations to estimate Value at Risk in a portfolio.
  38. Scenario-Based Stress Testing: The use of Monte Carlo simulations to evaluate the impact of extreme market scenarios on a portfolio.
  39. Parallel Processing: A technique used to speed up Monte Carlo simulations by performing multiple simulations simultaneously.
  40. Market Shock: A sudden and severe change in market conditions used as a scenario in Monte Carlo simulations to assess risk.
  41. Multi-Asset Monte Carlo: Monte Carlo simulations that involve multiple correlated assets or instruments.
  42. Capital Adequacy: The assessment of whether a financial institution has sufficient capital to cover potential losses, often determined through Monte Carlo simulations.
  43. Backtesting: The evaluation of a trading strategy’s performance using historical data and Monte Carlo simulations.
  44. Long-Term Investment Strategy: A trading approach that utilizes Monte Carlo simulations to project portfolio performance over an extended horizon.
  45. Monte Carlo Drawdown Analysis: The use of simulations to estimate the maximum potential loss a portfolio could incur over a specific period.
  46. Credit Risk Simulation: Monte Carlo simulations used to model the default risk associated with loans or credit portfolios.
  47. Monte Carlo Option Pricing: The use of Monte Carlo simulations to determine the fair value of options, especially in complex scenarios.
  48. Monte Carlo Analysis for Trading: Utilizing Monte Carlo simulation to assess and predict trading outcomes and risks.
  49. Trading Risk Assessment using Monte Carlo: Employing Monte Carlo simulation for a comprehensive evaluation of trading-related risks.
  50. Monte Carlo Portfolio Simulation: Simulating trading portfolios and their performance using Monte Carlo methods.
  51. Stochastic Trading Simulation: Running simulations that incorporate random factors (stochastic processes) in trading scenarios.
  52. Market Scenario Analysis with Monte Carlo: Analyzing various market scenarios and their impact on trading strategies via Monte Carlo simulation.
  53. Trading Strategy Monte Carlo Modeling: Developing and validating trading strategies through Monte Carlo modeling techniques.
  54. Probabilistic Trading Strategy Testing: Testing trading strategies under probabilistic conditions using Monte Carlo simulations.
  55. Monte Carlo Simulation for Financial Markets: Applying Monte Carlo simulations to assess trading strategies and their outcomes in financial markets.
  56. Trading Monte Carlo Risk Assessment: Using Monte Carlo simulation to evaluate and manage trading-related risks.
  57. Monte Carlo Trading Strategy Validation: Validating the effectiveness of trading strategies through Monte Carlo simulations.
  58. Market Monte Carlo Sensitivity Analysis: Analyzing trading strategy sensitivity to market changes using Monte Carlo methods.
  59. Monte Carlo Trading Performance Evaluation: Evaluating the performance of trading strategies using Monte Carlo simulations.
  60. Stochastic Trading Strategy Testing: Testing trading strategies under stochastic or random market conditions.
  61. Portfolio Optimization with Monte Carlo: Optimizing trading portfolios based on Monte Carlo-generated scenarios and outcomes.
  62. Monte Carlo-Based Trading Risk Management: Implementing risk management strategies in trading based on Monte Carlo simulations.
  63. Monte Carlo Value at Risk (MCVaR): An alternative risk measurement approach that combines Monte Carlo simulations with VaR to provide a more comprehensive risk assessment.
  64. Dynamic Hedging: The adjustment of trading positions in response to changing market conditions, often optimized through Monte Carlo simulations.
  65. Asset Allocation Strategy: A strategy that employs Monte Carlo simulations to allocate assets across different investment categories to achieve specific financial goals and risk tolerances.

Recommended reading:

Similar Posts