Introduction
Asset class trend following is a strategy that tries to exploit a momentum anomaly between various assets. It uses various moving averages or momentum filters to gain an exposure to an asset class only at the time when there is a higher probability for outperformance with less risk. The basic logic behind the trend following is finding a method to detect the trend of price movement and buy an asset when its price trend goes up, and sell when its trend goes down.
Method
This algorithm applies to trend following ideas to 5 ETFs in different asset classes like stocks, bonds, and commodities. The simple moving average is used to detect the trend. When the closing price is over its ten-month simple moving average,
we give equal allocation to those ETFs, otherwise stay in cash.
SMA(symbol, period, resolution)
is used to generate the moving average value in LEAN implementation. A warm-up period of ten months is set to prime the data and initialize the indicator so the SMA is ready to use when the algorithm starts.
Derek Melchin
See the attached backtest for an updated version of the algorithm in PEP8 style.
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.
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!