def Initialize(self): etf_tickers = ["XLB","XLE","XLF","XLI","XLK","XLP","XLU","XLV","XLY"] for ticker in etf_tickers: symbol = self.AddEquity(ticker, Resolution.Daily).Symbol self.Securities[symbol].SetDataNormalizationMode(DataNormalizationMode.TotalReturn) self.Consolidate(symbol, Calendar.Monthly, self.CalendarTradeBarHandler) self.Securities[symbol].SetLeverage(1.0) #Leverage is set to 1 to ensure no margin used historydate = datetime.date(datetime.now()) - datetime.date(datetime(1998,12,23)) self.history_days = int(historydate.days)+1 self.history_df = self.History(etf_tickers,timedelta(days=self.history_days),Resolution.Daily) tester = True while tester == True: if self.history_df.empty == True: self.history_df = self.History(self.Securities.Keys,timedelta(days=self.history_days),Resolution.Daily) elif self.history_df.empty == False: tester=False

Hi guys,

I'm having trouble with self.History. For some reason, the below code does not return any values/dataframe

self.history_df = self.History(etf_tickers,timedelta(days=self.history_days),Resolution.Daily)

The while loop never stops, which implies that the dataframe is empty. 

Is there anything wrong with the way I'm using self.History?

Author