This algorithm is the LEAN implementation of the paper Momentum and Markowitz: A Golden Combination from Wouter J. Keller, Adam Butler, and Ilya Kipnis.
The CAA model here applies mean-variance optimization over a lookback horizon of one year. The return and volatility are calculated with daily resolution and monthly rebalancing.
- Data
- The universe includes 7 ETFs of the global market. The risky assets are ETFs of S&P 500 (SPY), EAFE (EFA), MSCI Emerging Markets Index (EEM), JPX-Nikkei 400 (JPXN), Vanguard Information Technology ETF (VGT), The cash-like assets are ETFs of 7-10 Year Treasury Bond(IEF) and 20+ Yr Treasury Bond(TLT). The backtesting period is from 2007 to 2018.
- Method
- Each month we estimate the optimal mix of assets weights based on information from the prior 252 trading days and use that mix for the next month. For the covariance matrix, we used the historical covariance matrix of returns for the trailing twelve months.
- As the mean-variance optimization seeks any optimal set of portfolio weights, There is the potential for the portfolio to become quite concentrated at times. To reduce this possibility, we imposed caps (max weights) on assets to enforce greater diversification as indicated in the paper. E.g. impose a cap of 25% for all risky assets and no cap (i.e. a cap of 100%) for all cash-like assets.
- Optimization
- For optimization, we tried the different methods like maximizing the Sharpe Ratio, maximizing the return given target volatility stays unchanged (We use 5% as the target volatility). In addition, we also compare the results with the equally weighted algorithm. You could change the target volatility variable in the algorithm to test the defensive and offensive model.
Results are presented below.
- <1> Maximizing the Sharpe Ratio
Jing Wu
Jing Wu
Sdoof
Thanks Jing , this is a really cool paper (and Python code!)
Merci
Okana Ira
Thank you very much for sharing, I am working on an adaptation...I am not a coder just an enthusiast.
However, one wonders how the rebalance function behaves when a ticker is removed from the portfolio. Does the algorythm liquidate all shares of the removed ticker once it is time to rebalance?
Jing Wu
Hi Okana, you need to manually remove stocks which are not in the portfolio
Here is an example
Okana Ira
Thanks...will research further.
Tim De Lise
Hi Jing Wu Thats really great I'm sure you can apply this to a broader universe of stocks. I added a few more funds and relaxed the constraints on the bounds and was able to get the sharpe of the backtest to 1.15!
Jack Simonson
Hi,
This is a large topic covered in Modern Portfolio Theory, and you can find some great research about it here. Briefly, we use the covariance matrix because the variance of a portfolio is not just the weighted individual variances of each asset, but rather their individual variances and their covariance terms. This captures all of the factors that play into portfolio variance, and so is the widely accepted method for calculating multi-asset variance.
Jing Wu
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!