Hello! I've really enjoyed working with your platform and learning Python at the same time. I've tried to re-create a strategy called "Defensive Asset Allocation" that has been posted on these forums before. It uses a momentum score using differing weights of 1, 3, 6, and 12 month momentum. It also uses the momentum score in two ETFs (VWO/BND) as a "canary" signal to change to a lower risk asset such as bond ETF.
The problem is that when I run the same backtest with a different starting date or changing the number of assets held in the portfolio at any one time, I get different results in the "canary" signal which cause the strategy to go into bonds when it should not have. I assume this is because the MOMP numbers are different for some reason. I cannot understand why changing the # of assets held would affect that in the code. I'll try to include both backtests covering the same date period but with different results. It's most easy to see in 2017. I also had it print the momentum score in the logs to help with figuring out the difference.
Thanks!
Derek E
Here is the other backtest. The only change is the "self.numberOfGrowth = 4" line.
If you look at the logs, the momentum score seems to be off from the very beginning.
Shile Wen
Hi Derek,
This is likely because of the Liquidate() on line 96 which may or may not get called and mess up the portfolio. To address this, we should keep a field for the previous safety and call Liquidate on just this security. I've shown this in the attached backtest.
Best,
Shile Wen
Derek E
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!