I'm receiving this in my backtest:
Data for symbol IR has been limited due to numerical precision issues in the factor file. The starting date has been set to 3/9/2020.
Then right after, I'm getting this error:
Runtime Error: KeyNotFoundException : 'IR R735QTJ8XC9X' 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("IR R735QTJ8XC9X")
The backtest is for 2016-2019, how can I just remove all securities from my universe that do not have data relative to the timeframe of the backtest.
My logic in my OnData function is the following:
if self.IsWarmingUp:
return
if data.Count < len(self.universe):
self.Debug("Not Ready. Getting data...")
return
self.Debug("Initialized! All data is present.")
# Add to and update all the moving averages
for symbol in self.universe:
if symbol not in self.averages:
# 1. Call history to get an array of day of longest average of history data
history = self.History(symbol, self.longAvg, Resolution.Daily)
#2. Adjust SelectionData to pass in the history result
self.averages[symbol] = SelectionData(history, self.longAvg, self.shortAvg)
self.averages[symbol].update(self.Time, tradeBars[symbol].Close)
Basically, I'm calculating moving averages for every stock in my universe and adding it to a dictionary later, just like in the tutorials. However, when I hit that security, it bugs out at me.
Is there a HasData property on these security I can check for?