Hey everyone,
In this video we are tackling index investing and aiming to replicate the S&P 500 index. We discuss how we measure performance and then code our own index investing algorithm. You can find the video here:
The market cap weighted backtest is attached below and you can find the code snippet for the equal weighted algorithm commented out in the rebalance function.
Happy coding!
Ollie
Jared Broad
Sorry for some reason this isn't cloning properly. Please copy the code here:
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.
.ekz.
Brilliant! Thanks for sharing this.Â
I recently had to do something similar, building a factor weighted portfolio using the historical constituents of the Nasdaq 100. It was a bit cumbersome as I had to buy the data, and load it manually via a CSV file on dropbox. Â Using self.Universe.ETF will make life considerably easier.Â
Will give it a try soon with NDX. Â
Vladimir
Here is Ollie Hooper's original code with some lines I added to compare "own index fund"Â
to the underlying ETF.
Josh M
Cool stuff good work!
Louis Szeto
Hi QC Community
For those who are interested in this topic, we recommend further reading on Sparse Portfolios for High-Dimensional Financial Index Tracking (Benidis, Feng & Palomer, 2018). This paper demonstrates how to properly trimmed components to track index for similar results with a minimum number of positions, such that we can
Best
Louis
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.
.ekz.
Played with this a bit. Here’s a version that trades the top 10 securities in the QQQ ETF, based on Momentum.Â
I’ve also externalized a few settings in case folks want to tinker with it, including:Â
Â
I’m going to try some other performance metrics as well (e.g.: sharpe ratio, drawdown, etc), hence the extra ENUM code that's currently unused.
Â
Ollie Hooper
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!