Hi,
I see that there are a few threads with this issue already, but I cannot solve why my algo is giving me this error.
As my code might reflect, I tried many lines of code, with no success.
If I run my algo for a few days, there is no issue. But when change the starting date to 2018, it crashes.
I attached the backtest of a couple of days, since I cannot attach a backtest that crashes.
Any help is greatly appreciated :)
Varad Kabade
Hey Andre Meeusen,
The Update method in AlphaModel should always return a list of insights(can be empty), but the above algorithm returns null/None; hence the above error.
Â
Should be changed to.
Â
Refer to the attached backtest for reference. Note that with this change, the attached backtest still throws an error for insufficient buying power. This is because of the Custom PCM model.
Best,
Varad Kabade
Andre Meeusen
Thank you so much, that worked.
Also the PCM I adjusted with;
if len(self.targets)>0:
      return self.targets
That way, I believe, only once a day targets are set, and the algo doesn't throw the insufficient buying power error.
The also still doesn't do what I want it to do (buying a portfolio of 100 assets daily in the morning, and selling it the same day just before closing, with the weight of each asset depending on the momentum of the previous day), but I am getting closer (any hints are welcomed:) ).
I attached a backtest with my changes for whomever it might help also
Again thank you.
Â
Andre Meeusen
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!