Hi,
I have written an algorithm that trades based on some history calls.
The algorithm works for most dates and number of stocks, however for some dates it only works under a certain amount of stocks.
I come to the conclusion that it is in history calls; that for some dates some stock don't have data.
I have tried to filter these stock out, but I failed.
Attached backtest fails when I use 9 securities or less but fails for 10 or more.
I have attached a backtest with 5 securities (variable self._numberofsymbols), the algorithm fails if I set this to 10 or more…
What goes wrong, and how to debug this?
Thanks for any help offered
Varad Kabade
Hi Andre Meeusen,
We recommend the following pattern before using the historical data after the historical request:
Best,
Varad Kabade
Andre Meeusen
Hi Varad,
Thanks for your answer, it did lead me to the fix.
For some securities the history did not had enough days to get an average.
By checking the shape of the history I was able to filter those out:
if not history.shape[0]== self._lengt_avg: #self._lengt_avg is a integer (the n in the n-day average) return
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!