Hi,
I'm having a problem in backtesting mode.
It shows : Runtime Error: 'AAPL' wasn't found in the TradeBars 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")
How ever I think I've difine the security already.
Thanks.
James
Alexandre Catarino
In the Initialize method, you subscribe all the symbols you want to trade, but the data will flow in and appear on the OnData event handler only if there is new data. If, by any reason, a security wasn't trading at a given timespan it won't be part of the Tradebars object along with the other subscribed symbols.
This is common on iliquid assets with higher (second) resolution. Simply, there are no new trades on a whole second/minute and therefore it is impossible to contitute a new tradebar. Think of it as a missing candle in a candle chart.
Chiang Chih-I
Thanks a lot!! This really bothers me for days.
Chiang Chih-I
Hi Alexandre,
I'm wondering if one of stock basket shows this problem. How can I fix it or skip that particular timespan?
Alexandre Catarino
Do you mean, if you have 100 stocks and only one if missing, the OnData event handle returns (the algorithm does nothing)?
In the case of your algorithm, compare the number of symbols you subscribed (Securities.Count) against the number of symbols arrived at OnData:
public void OnData(TradeBars data) { if(data.Count < Securities.Count) return; }
If the algorithm never passes this point, one of the symbols may have been delisted or it is not avaliable (please check our database).
Chiang Chih-I
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!