ETF Sector Rotation Algorithm
![]()
Author: Peter
Intro
Every industry has its heroes unbeknown to most people. Marcos Lopez de Prado, is one such hero and was voted Quant of the Year several times and brought algorithmic investing to a whole new level. It would not be surprising if he received a Nobel Prize for his work.
This algorithm is based on Marcos’ Research, and it’s a tried and tested algo, but our quants have adjusted it to make it more robust by adding a trend detector
Hypothesis
Every stock or asset has its inherent risk based on the volatility it shows in the price. Volatile stocks (GameStonk, anyone?) have more risk, and not-so volatile stocks have a lower risk. The idea is that you give stock with a higher risk a lower weighting and stock with a lower risk a higher weighting. Altogether, it will result in a portfolio in which every stock has the same risk. At least, that is what a lot of traders thought.
Marcos found that this was flawed and later discovered that one should create clusters of stock that behave the same (ie. correlated). So he endeavoured to test this theory and create clusters of similar stocks. If you weigh those clusters, then there is a more reliable risk reward scenario.
Based on these academic research papers:
- Lopez de Prado, Marcos. 2016. “Building Diversified Portfolios That Outperform Out-of-Sample.” SSRN Electronic Journal.
- Thomas Raffinot, 2018, The Hierarchical Equal Risk Contribution Portfolio
- Joseph Simonian, Chenwei Wu, Daniel Itano and Vyshaal Narayanam, 2019,A Machine Learning Approach to Risk Factors: A Case Study Using the Fama–French–Carhart Model
Inner Workings
- Determine the trend of the market.
- Are we in an uptrend? We buy ETFs of the sectors of the S&P
- Or in a downtrend? then we buy set of short and long duration bonds (IEF, TLH, TLT)
- Weighting is based on the HRP Machine Learning portfolio allocation algorithm that determines the distance of ordered tree clusters based on the correlation and covariance of the returns. The stocks are weighted in such a way that the clusters have an equal contribution to the risk.
The gory details
Because this algorithm is on the edge of Machine Learning and Artificial intelligence, it’s hard to publish gory details as from here on: it’s all code! What is interesting though is diving into which ETFs this algorithm can buy.
This algorithm will be buying most of the time a combination of the following ETFs
- XLB – The Materials Select Sector SPDR Fund: S&P 500 companies involved in any part of the metals, mining, or forestry industries
- XLE – The Energy Select Sector SPDR Fund: Oil and gas .
- XLF – The Financial Select Sector SPDR Fund: Banks, REITs, and financial institutions.
- XLI – The Industrial Select Sector SPDR: Industrial companies like aerospace and defence, machinery, or roads and railways.
- XLK – The Technology Select SPDR Fund: All kinds of tech companies, software and service giants, cloud and semiconductor.
- XLP – The Consumer Staples Select Sector SPDR Fund: Consumer Staples: groceries, hygiene products, and tobacco
- XLRE – The Real Estate Select Sector SPDR Fund: Focuses on investments in properties and property management.
- XLU – The Utilities Select Sector SPDR Fund: The utility companies: electric companies, gas companies, and energy traders.
- XLV – The Health Care Select Sector SPDR Fund: Biotech, pharmaceutical, and health service companies.
- XLY – The Consumer Discretionary Select Sector SPDR Fund: Consumer discretionary luxuries, including restaurants, hotels, and cars.
- XME – SPDR S&P Metals and Mining ETF: Companies that deal with metals, coal and consumable fuels.
- EWJ – Tracks a market-cap-weighted index that covers roughly 85% of the investable universe of securities traded in Japan
- EEM – Tracks the investment results of an index composed of large- and mid-capitalization emerging market equities
Disclosure:
The Information on this page is based on backtesting and is, therefore, to be considered as HYPOTHETICAL. Any financial products described on this page will be issued by third parties, as disclosed in the relevant disclosure document. All information is general information only and does not take into account your personal circumstances, financial situation or needs. Before making a financial decision, you should read the relevant disclosure document and consider whether the product is right for you and whether you should obtain advice from a professional financial adviser. Any information contained on this page may have been automatically generated by an algorithm based on raw data inputs, has not been independently verified and is subject to change.
