Hi guys, 

I'm getting an error when backtesting that is unexpected because I have tried to make the algo resillient to this exact scenario.

in the initialization phase set the following:

self.tickers = ['ESS','STOR']

in the OnData phase of the algo I start with

if False in [data.ContainsKey(x) for x in self.tickers]: return

and i have also tried 

if not all([data.ContainsKey(x) for x in self.tickers]): return

in both instances I get an KeyError (full error message at the bottom on 26 september 2019 for ticker 'ESS' (I have had the same error for other tickers on other dates). This specific example is with minute resolution data.

I would expect that if the ticker data is not present the algo would just skip this data point and continue with the next datapoint. 

anyone running into something similar or am I missing an elephant in the room?

 

Best,

 

Dirk

 

Runtime Error: KeyNotFoundException : 'ESS' 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("ESS") at QuantConnect.Data.Market.DataDictionary`1[T].get_Item (QuantConnect.Symbol symbol) [0x00024] in <8e85730333624c7d90e25a24998a3d52>:0 at QuantConnect.Data.Market.TradeBars.get_Item (QuantConnect.Symbol symbol) [0x00000] in <8e85730333624c7d90e25a24998a3d52>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0 at OnData in main.py:line 35 :: self.pair.updateMetrics(data) at updateMetrics in main.py:line 96 KeyNotFoundException : 'ESS' 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("ESS") at QuantConnect.Data.Market.DataDictionary`1[T].get_Item (QuantConnect.Symbol symbol) [0x00024] in <8e85730333624c7d90e25a24998a3d52>:0 at QuantConnect.Data.Market.TradeBars.get_Item (QuantConnect.Symbol symbol) [0x00000] in <8e85730333624c7d90e25a24998a3d52>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0 (Open Stacktrace)