Following the Risk-Opportunity Analysis conference I attended earlier this month, I decided to test the model and the software used to implement it (Vince‘s java app and Joshua Ulrich’s R implementation).
Most of the mathematical formulas supporting the model are in the book Leverage Space Trading Model. I will not paraphrase the book and reproduce all the formulas here – but I will refer to some of them. Getting the book is probably a good idea for a better understanding of the concepts.
The trading application of the Leverage Space Model is presented as a generalisation of the Kelly formula, which is well illustrated by the coin-toss betting example (as per Vince’s paper).
In a practical “trading” example, I have decided to look at the four Trend Following Wizards with the longest track records (that I have): Campbell, Dunn, John Henry and Millburn. All track records go back to 1985 (up to end 2009). The question this test tries to answer is this:
As an investor from 1985, what would have been the best allocation between the four managers?
Note: Here “best” simply means the highest CAGR (we’ll see later that “best” can be defined in different ways based on your preferences / utility function).
I will describe the concepts using the simple two-coin toss example and draw a parallel with the “real-world” application on the four Trend Following Wizards.
For a single stream of returns or betting outcomes/probabilities, there is a specific level of leverage, or fraction of capital, to risk on each event, which maximizes the geometric growth of the equity. This is what Optimal f relates to.
In the example of the coin-toss with the following parameters:
The fraction of capital staked on each bet will alter the expected growth rate as per this curve:
This has been covered extensively elsewhere (as a simple application of the Kelly formula) so I will not repeat the details here. The main point is that .25 is the Optimal f (meaning, in that case, that staking 25% of the largest loss on each bet will maximize the growth of the trading stake over time – any other value would be sub-optimal). Note that here the largest loss is equal to 100% of the bet size and therefore the Optimal f and the fraction of capital to stake are equal. This is a special case and we’ll see further down that these are usually different values, especially in trading.
Adapting this example to a single Trend Following Wizard track record, we can establish a posteriori what the optimal f would have been, in order to maximize the growth of the equity curve.
Here is the f curve for Dunn’s track record:
The shape of the curve is fairly similar, it peaks at around f=0.5.
Note that here, the optimal f does not represent the actual leverage or fraction of capital to apply. This is because of the nomenclature in the formulas used by Vince, where each “leveraged” return (or HPR: Holding Period Return) is expressed as:
In effect, the leverage applied to each periodic (monthly) return is:
In the case of Dunn, the biggest monthly loss is 30.68%. An f of 1 would equate to leveraging each period return by a factor of 1/0.3068 = 3.26, which is the maximum leverage that can be achieved before hitting a zero final equity (the HPR would be equal to 0 as soon as the biggest loss occurs). The actual leverage amount is independent of the biggest loss, but expressing it that way bounds the value for f between 0 and 1. This is really just a notation.
The optimal leverage for the Dunn track record can be derived from Optimal f = 0.5: Optimal leverage = 0.5/0.3068 = 1.63. This effectively means that an investor would have achieved the highest possible final equity investing in Dunn by resetting the notional account size to 163% of the actual account size, every month (this is theoretical as it ignores the (im)practicality of this and impact of fees, etc.).
Any other value, higher or lower would have resulted in a lower equity curve. At 100% (no leverage), the monthly geometric mean return is 1.11%; at 163% leverage, the mean return becomes 1.29% (which is the maximum value possible). Of course the drawdown would also increase (around 60% MaxDD at 100% leverage vs. around 83% MaxDD at 163% leverage).
Following on with our coin-toss example, let’s now consider the case of two simultaneous coin-tosses.
The method requires a discrete set of outcomes and associated probabilities. In case of the simple two-coin toss example, these are easy to identify:
Using this set of outcomes with the same concept as above for f optimization, this now gives us a 3-dimensional curve displaying each possible f-combination (each simultaneous coin toss has its own f). Each combination generates its corresponding growth rate (which is related to the Terminal Wealth Relative, TWR). The f-combination that generates the highest TWR is the “optimal” solution.
In the case of the two-coin toss, the optimal f-combination is (0.23, 0.23) – meaning that staking 23% of the capital on each simultaneous coin toss (46% in total for each period) would result in the highest growth rate (over time). This is simply where the curve peaks in the chart above.
Adding a third simultaneous coin toss would simply generate a 4-dimensional curve (with each point representing the growth rate output of the f-triplet) and so on: the curve is always [N+1]-dimensional, where N is the number of components.
Let’s now look at our test case with the four Trend Following Wizards.
Similarly, we need a discrete set of outcomes and associated probabilities for our input . For this, we need to bin the data distribution and create the Joint-Probability Table (which holds each possible outcome combination and its associated probability – similarly to the 3 possible outcomes identified above for the coin-toss example). This is effectively how Vince does away with the concept of correlation input that can be used in other models such as Mean-Variance Optimization.
The pseudo-code to build the Joint-Probability Table (JPT) is as follows:
This is a bit tricky to explain in a concise manner, and it is developed in further detail in Vince’s book. However, the files attached at the end of this post in the “technical” appendix should help you retrace this logic.
Once the JPT is built, it can be used as an input for the f optimization.
The java app developed by Vince creates the Joint-Probability Table from the import of the equity curve for each component.
The “meat” of the leverage space model code is contained in the R implementation by Joshua Ulrich (from FOSS Trading). This is where the optimization is actually run (Vince’s java app also implements the optimization but the R implementation is much faster).
Note that Josh has a blog post on how to create the JPT, so you might be able to only use R, should you want to experiment with the Leverage Space Model (I am not sure the java app is freely available).
The R LSPM package needs the JPT as an input, as well as the optimization parameters. Note that this is my first foray in R – so you definitely do not need to be any expert at it to run this sort of test. The fact that the java app generates the R commands directly was helpful, but you can probably “learn by example” by checking the R session file at the end of the post (there is more doc available on Josh’s blog or the LSPM project page anyway).
Using the JPT as an input, the LSPM package runs the optimization, which estimates the peak of the 5-dimensional curve. A genetic algorithm is used for the optimization; and after a specific number of iterations, the optimal set of f-values is output by the program.
For the four wizards, the respective optimal f values are as follows:
Again, these are f values, which only relate to the leverage to be applied, via each component’s biggest loss:
One interesting thing to note is the fact that some f-values can be assigned to 0, which basically means that the component does not add value to the portfolio with regards to the growth rate, which maximum is attained when excluding it.
An investor would have maximized the geometric growth of their capital by resetting every month the notional account size allocated to each manager according to the three leverage factors identified above. For example, starting with $100 million total capital, the first month would see $30.4M allocated to Campbell, $118.2M to JWH and $265.7M to Millburn. After the first month, the equity would have increased by 22.9% to $122.9M, which would then be re-allocated according to the same leverage ratios.
After 25 years of repeating the same process monthly, the $100M would become a theoretical figure of… $411.4 Billion thanks to a monthly geometric mean return of 2.81% (whereas an unleveraged equal-split across four managers – with monthly rebalancing – would result in a “paltry” $3.9 Billion). Of course, this improvement is only possible “in hindsight”.
The other implication from this sample application is that the optimal f value can dictate a leverage value which can be higher than the maximum allowed (be it by margin requirements or stock trading in a cash account, etc.). The Leverage Space Model caters for this, with the possibility of adding margin constraints (I have not looked into this yet but this post on FOSS trading talks about it).
One of the main problem usually raised with the concept of optimal f is that trading for growth rate optimization is often not realistic, as it generates untenable levels of drawdown and volatility. Most investors, traders or managers would happily give up some return to stay in their acceptable levels of volatility and drawdown.
I will not detail the formula here (I’ll refer you to the book again) but Vince presents a way of calculating the probability of a specific drawdown. The main idea is to introduce a risk constraint to the model, so that instead of solely optimizing for maximum growth rate, one can optimize with a constraint on drawdown. For example:
Find the optimal f values for which the probability of a 30% drawdown over 12 periods does not exceed 50%. The n-dimensional curve is constructed in the exact same way, but any f-values that result in a probability of drawdown over the constraint threshold are ignored – this would usually result in all values around the peak being discarded.
This is exactly what I ran on the same four Wizard track records and the f-values obtained were as follows:
The monthly geometric mean return drops to 2.68% (final equity of $282.7B). The Max Drawdown figure drops from 79% to 68%.
The main problem of adding drawdown constraint to the optimization is the dramatic increase in computing time. Whereas the first optimization for the simple growth-optimal f values took seconds for 100 or 1,000 iterations of the algorithm, adding the drawdown constraint has a significant impact on the computation time.
The LSPM uses another R package: snow, in order to leverage multi-processors with parallel computing to speed things up. Info for the techies: I am running an Intel Core 2 Quad Processor @2.40GHz and I allocated three processors to the optimization process – but the running time came at a disappointing three hours for 100 iterations. This is only for four components and 300 monthly periods. I initially had the idea of running the daily equity curve of a few hundred components through the LSPM package but that will probably have to wait for the technology to improve.
I understand that this is mostly due to the heavy computational costs of evaluating the probability of drawdown. Maybe a less costly risk computation might make the running time more manageable.
This is a bit of an extended post (probably the longest on the blog so far) but it hopefully provides a decent step-by-step illustration of some of the concepts and how to apply them practically (there are more details in the “technical” appendix below).
The model is really an alternative portfolio allocation method and I can not see how it could be applied directly to determine position sizing for a trading system. This is primarily because all component returns have to be split across identical periods, whereas trades from a single system do overlap. It might well be possible to use each instrument’s equity curve when traded through a specific system. Something to investigate – but with the high computation costs, running the optimization over a large diversified portfolio might be all but impossible.
On the other hand, I can see how the model might be useful to the manager running a programme made up of several systems and wanting to optimize the allocation to each system. Alternatively, one could split the system portfolio into several asset classes (Financials, Currencies, Energies, etc.) and optimize the allocation to each asset class.
Another aspect worth looking into is how useful the model is in a forward-looking mode (ie to determine optimal f/leverage to apply to each component for the next periods) and how this can be used/configured (over the whole history available at that time or over a rolling optimization window? Which length of data to use in that window?). This would obviously be dependent on how stable the component returns are over time (like for any aspect of back-testing).
Below is some additional material to support the explanations in this post and illustrate the step-by-step process.
I used the java app to generate both the Joint-Probability Table and the R commands to run the optimization.
The app requires a file per component, containing the equity curve with constant position sizing (ie. no reinvestment). For the four Wizard track records, the equity curve is simply the cumulative sum of the monthly percentage returns (representative of a constant position size of 100). Below are the four CSV files:
When importing the files, the app bins the period returns and generates the JPT:
The optimization parameters can be configured via the second half of the screen below:
The parameters of the optimization defined above are: maximum probability of a 30% drawdown over 12 periods must be less than 50%. The Maximum Calculated Cycles of 8 is a number used in the drawdown probability calculation. As I understand it, the drawdown probability is extrapolated off an 8-period calculation and the computation time goes up exponentially with this number.
The R button generates the R instructions to run with the LSPM package. Below is a file containing the R session that I used to run the example in the posts. The first run is a straight optimal f calculation with 100 iterations. The second run is the same with 1,000 iterations and the third run is the optimization with drawdown constraint.
You can check the joint-probability table (contained in the outcomes and probs arrays) generated from the track record input files as well as the command to run in R.