Following up on the prior Strategy Stress Testing post: with the release of AmiBroker version 6.10.0 a new Monte Carlo mode has come available for simulating portfolio equity changes. Instead of randomizing the trade list, the new mode uses bar-per-bar percent equity changes at the portfolio level to generate permutations. Consequently cross-sectional correlations are preserved. According to AmiBroker’s developer, the new method is perfectly fine for multiple overlapped positions, provided the number of bar-per-bar equity changes is sufficiently large (> 100).
The portfolio level Monte Carlo simulation is controlled by a couple of new SetOption fields which allow for AFL implementation right into the strategy code:
The Monte Carlo Portfolio Analysis code is suitable for copy/paste inside a rotational model like the familair Simple GMR code attached to the prior Monte Carlo post. However, my preferred method is to save the code as a separate file for inclusion in strategy models by calling the #include command:
Showing posts with label Monte Carlo. Show all posts
Showing posts with label Monte Carlo. Show all posts
Strategy Stress Testing à la Monaco
After a short, admittedly rather superfluous, historical digression, this post will introduce Monte Carlo Analysis. What is Monte Carlo Analysis? Why is such analysis useful if not prerequisite for a strategy trader? What does it supplement to customary backtest information? By exploring the darker corners of a strategy the objective of this post is revealing real risk.
Crunching numbers in a monastery
During the first half of the 1600s a French monk, Marin Mersenne, had many acquaintances in the scientific world. Mersenne studied (and taught) theology, philosophy, mathematics and music. He communicated extensively with other scholars like Descartes, Pascal, Huygens and Galilei.
In spite of being a theologian and philosopher primarily, Mersenne’s name is associated with prime numbers that compound to Mn = 2n – 1. Such numbers are called Mersenne primes. The first four Mersenne primes are 3, 7, 31 and 127 and significantly a Mersenne prime (219937−1) is elementary for the most commonly used version of the Mersenne Twister.
The Mersenne Twister is a fast generator of high-quality pseudorandom integers. Recently AmiBroker’s already extensive feature set was expanded with a Mersenne Twister based Monte Carlo simulator which is capable of rendering 30+ million trades per second (!). More specific, the Monte Carlo simulator runs series of trade sequences based on backtest output and uses the high-quality Mersenne Twister for randomizing the order of the trades.
And so we finally arrive down the stairs of the famous "Casino de Monte-Carlo" in mondain Monaco ;-)
Why stress test strategies with Monte Carlo Analysis?
Before we start familiarizing ourselves with Monte Carlo Analysis let’s first pick a sample strategy for illustration purposes: SeekingAlpha's contributor Varan's Simple GMR. Each month all available trading capital is re-allocated to the top performing ETF out of a basket with IJJ, EFA, IEV, EPP, QQQ, EEM and TLT. See Varan's post for details. For establishing points of reference and collecting the trade data required for a Monte Carlo Analysis, a backtest is run starting at year-end 2003 and ending August 2015 using high-quality monthly total return data as provided by Norgate Premium Data (Alpha-tester program).
The equity curve as well as the distribution of the yearly returns obtained from the backtest look reasonable, even considering the 2008 drawdown when compared to the market in general. Volatility is not too high. Actually, the ratios for Sharpe, Sortino and Calmar are quite nice. The complete chart suite is available in the Google drive folder connected to this post (zooming required!).
Crunching numbers in a monastery
During the first half of the 1600s a French monk, Marin Mersenne, had many acquaintances in the scientific world. Mersenne studied (and taught) theology, philosophy, mathematics and music. He communicated extensively with other scholars like Descartes, Pascal, Huygens and Galilei.
In spite of being a theologian and philosopher primarily, Mersenne’s name is associated with prime numbers that compound to Mn = 2n – 1. Such numbers are called Mersenne primes. The first four Mersenne primes are 3, 7, 31 and 127 and significantly a Mersenne prime (219937−1) is elementary for the most commonly used version of the Mersenne Twister.
The Mersenne Twister is a fast generator of high-quality pseudorandom integers. Recently AmiBroker’s already extensive feature set was expanded with a Mersenne Twister based Monte Carlo simulator which is capable of rendering 30+ million trades per second (!). More specific, the Monte Carlo simulator runs series of trade sequences based on backtest output and uses the high-quality Mersenne Twister for randomizing the order of the trades.
And so we finally arrive down the stairs of the famous "Casino de Monte-Carlo" in mondain Monaco ;-)
Why stress test strategies with Monte Carlo Analysis?
Before we start familiarizing ourselves with Monte Carlo Analysis let’s first pick a sample strategy for illustration purposes: SeekingAlpha's contributor Varan's Simple GMR. Each month all available trading capital is re-allocated to the top performing ETF out of a basket with IJJ, EFA, IEV, EPP, QQQ, EEM and TLT. See Varan's post for details. For establishing points of reference and collecting the trade data required for a Monte Carlo Analysis, a backtest is run starting at year-end 2003 and ending August 2015 using high-quality monthly total return data as provided by Norgate Premium Data (Alpha-tester program).
The equity curve as well as the distribution of the yearly returns obtained from the backtest look reasonable, even considering the 2008 drawdown when compared to the market in general. Volatility is not too high. Actually, the ratios for Sharpe, Sortino and Calmar are quite nice. The complete chart suite is available in the Google drive folder connected to this post (zooming required!).
![]() |
| Portfolio performance over 2004 - 2015 |
Subscribe to:
Posts (Atom)


