All my backtests work, but when I go live, I get a runtime error:
Runtime Error: 'AAPL' wasn't found in the Slice object, likely because there was no-data at this moment in time and it wasn't possible to fillforward historical data. Please check the data exists before accessing it with data.ContainsKey("AAPL") in Slice.cs:line 315 Stack Trace: 'AAPL' wasn't found in the Slice object, likely because there was no-data at this moment in time and it wasn't possible to fillforward historical data. Please check the data exists before accessing it with data.ContainsKey("AAPL") in Slice.cs:line 315
How do I know if my code is good to trade live, because I don't get errors in my backtests?
Nico Xenox
Hey Alex Veraart,
you can check if your data for AAPL is ready by adding this to your code:
Another way would be to initiate a warmup request. Doing that, as soon as it is finished the algo will have the data it needs to start trading. Note that for this you will have to check if the algo is warming up.
Â
Hope it helps ;)
Alex Veraart
Yes, thanks. I build in the first option. Code did it the entire trading day. Unfortunately, no trade entry to test my code, but the error is gone!Â
Alex Veraart
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!