This post will conclude the portfolio optimization series. In this post, we will construct a trading strategy based on portfolio optimization and test the results against the CAPM market portfolio as well as another strategy.
It is worth reiterating: Nothing I am about to say should be taken as advice for investing. These results are based on prior observed returns and the future rarely mimics the past. These techniques can give helpful insight on how you can better allocate a portfolio. It should not be used as the sole investment decision. Speak with a qualified professional if you are looking for advice.
Building on the work of Markowitz, Treynor, Sharpe, et. al. developed the Capital Asset Pricing Model — CAPM. They shared the Nobel Prize with Markowitz in 1990 for this work. CAPM is a general equilibrium model. The model assumes that market prices reflect all available information and give the “fair” value of a security. Based on that, the market portfolio can be shown to be market capitalization weighted portfolio. Market capitalization (or market cap) is defined as the share price times the number of shares outstanding — the total value of the equity of a company. A company’s weight is its market cap divided by the total market cap of all securities.
Capitalization weighting has become the standard for indexes and index funds. The S&P500 being what most people consider the standard “market portfolio.” We will test our portfolio optimization strategy against a capitalization weighted strategy.
Now there are problems with CAPM. There are lots of ways to poke holes in it. One way is to say that prices are not exactly fair value, but instead mean revert to fair value. In this case, when a price is above fair value, the market cap weighted portfolio will overweight the overpriced security. When it mean reverts, the cap weight portfolio will under perform because of the overweighting.
This position was famously put forward by Robert Arnott. I highly recommend his book,The Fundamental Index: A Better Way to Invest. He argues that any portfolio strategy that breaks the correlation with price will outperform the capitalization index over time. He created a new index which he puts forward in the book. Another would be to simply equal weight each security (S&P actually publishes this index). Because of that, we will also test our strategy against an equal weight strategy.
Here is our portfolio optimization strategy:
At the beginning of each quarter, take the previous quarterly returns and calculate the market portfolio.
Use this portfolio for the current quarter.
At the start of the next quarter, go back to #1.
Require at least 3 stocks in our portfolio.
Use 2% as the risk free rate.
For the first quarter and if the optimization fails, use an equal weight portfolio.
This strategy will tend to outperform when prices are trending quarter over quarter. I.E. if last quarter’s returns and volatility accurately predict this quarter’s values. We are not taking trading costs into account. The 2% rate is static, and we should technically use the 3 month treasury rate for each quarter beginning. That’s why this is just an illustration.
To start, we need to modify the marketPortfolio() function we previously created. You can find it here. The new function signature is
Add a Debug option to print outputs if we request them
Make the function fault tolerant. Sometimes a feasible solution is not possible and the function needs to detect this and handle it accordingly.
Cap the max return we search over to 50%. This is a sanity check as large values can cause other weird behavior.
Likewise, put a floor on the min return at .005%.
If the max return is <0, then simply find the minimum variance portfolio that achieves that value.
Add a maxWeight option that lets us cap the weight on any 1 security.
The universe of stocks we will consider is 28 of the Dow components (for some reason Yahoo! Finance only gave me 28 instead of 30). I pre-downloaded the returns and stored them in a .rda file. You can get it here. I calculated the starting market cap weights of each stock and stored them in a .csv file. Get it here.
Our portfolio optimization portfolio outperforms the Cap Weight, but under performs the Equal Weight. Not surprising if you believe Mr. Arnott as we did not break the correlation with price.
Here is the chart of correlations:
We’ve created a portfolio that is correlated with the “market” cap weight portfolio, but not nearly so as the equal weight portfolio. The degree of correlation of the equal weight and the cap weight is interesting.
Here is the time series of returns charted:
Interestingly, our portfolio in green has trended sharply up since the market bottom in March of 2009. It strongly outperformed the Cap Weight portfolio.