Hello,

I am struggling with learning how to warm up an indicator when using universe selection. My test code and the error message it yields are given below. I would just attach the backtest, but apparently I am not able to do that since it results in a runtime error. It seems to dislike the "loc" attribute in line 36 for some reason. Any suggestions would be appreciated because I am at a loss as to how I can fix this.

 

2010-01-01 00:00:00 : Runtime Error: AttributeError : '0, Culture=neutral, PublicKeyToken=null]]' object has no attribute 'loc' AttributeError : '0, Culture=neutral, PublicKeyToken=null]]' object has no attribute 'loc'

 

from Execution.ImmediateExecutionModel import ImmediateExecutionModel from Portfolio.EqualWeightingPortfolioConstructionModel import EqualWeightingPortfolioConstructionModel from Risk.MaximumDrawdownPercentPerSecurity import MaximumDrawdownPercentPerSecurity from Selection.QC500UniverseSelectionModel import QC500UniverseSelectionModel class SimpleRSITestQC500Universe(QCAlgorithm): def Initialize(self): self.SetStartDate(2010, 1, 1) # Set Start Date self.SetEndDate(2010, 2, 28) # Set End Date self.SetCash(100000) # Set Strategy Cash self.SetExecution(ImmediateExecutionModel()) self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel()) self.SetRiskManagement(MaximumDrawdownPercentPerSecurity(0.05)) symbols = [ Symbol.Create("SPY", SecurityType.Equity, Market.USA)]#, Symbol.Create("GE", SecurityType.Equity, Market.USA), Symbol.Create("BA", SecurityType.Equity, Market.USA) ] self.SetUniverseSelection(ManualUniverseSelectionModel(symbols)) self.AddAlpha(RsiAlphaModelTest()) class RsiAlphaModelTest(AlphaModel): def __init__(self, period = 14, resolution = Resolution.Daily): self.period = period self.resolution = resolution self.insightPeriod = Time.Multiply(Extensions.ToTimeSpan(resolution), period) self.rsiData ={} resolutionString = Extensions.GetEnumString(resolution, Resolution) self.Name = '{}({},{})'.format(self.__class__.__name__, period, resolutionString) def OnSecuritiesChanged(self, algorithm, changes): addedSymbols = [X.Symbol for X in changes.AddedSecurities] [algorithm.Debug(str(X) + ' added to universe at ' + str(algorithm.UtcTime)) for X in addedSymbols] #warmUpData = algorithm.History([X.Symbol for X in changes.AddedSecurities],self.period, self.resolution) warmUpData = algorithm.History(self.period, self.resolution) for symbol in addedSymbols: self.rsiData[symbol] = algorithm.RSI(symbol, self.period, MovingAverageType.Wilders, self.resolution) for time, row in warmUpData.loc[symbol].iterrows(): self.rsiData[symbol].Update(time, row["close"]) algorithm.Debug("Debug message OnSecuritiesChanged for:" + str(symbol) + " " + str(self.rsiData[symbol])) #[algorithm.Debug("Time: " + str(X.Time) + " , Close:" + str(X.Bars["GE"].Close)) for X in WarmUpData] def Update(self, algorithm, data): insights = [] prior_rsiData = self.rsiData for symbol in self.rsiData.keys(): #self.rsiData[symbol] = algorithm.RSI(symbol, self.period, MovingAverageType.Wilders, self.resolution) #if self.rsiData[symbol] <= 34.0: algorithm.Debug("Debug message for:" + str(symbol) + " " + str(self.rsiData[symbol])) #prior_rsiData[symbol] <= 34.0 and self.rsiData[symbol] >= prior_rsiData[symbol] + 1.0: #insights.append(Insight.Price(symbol, self.insightPeriod, InsightDirection.Up)) # elif prior_rsiData[symbol] >= 70 and self.rsiData[symbol] <= prior_rsiData[symbol] - 1: # #insights.append(Insight.Price(symbol, self.insightPeriod, InsightDirection.Down)) # algorithm.Debug("Insight down for:" + symbol) return insights

. Many thanks.