import datetime import pandas class LiquidUniverseSelection(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 11) self.SetCash(100000) self.AddUniverse(self.CoarseSelectionFilter) self.UniverseSettings.Resolution = Resolution.Minute self.openingBar = None # 1. Set the leverage to 2 self.UniverseSettings.Leverage = 2 def CoarseSelectionFilter(self, coarse): sortedByDollarVolume = sorted(coarse, key=lambda c: c.DollarVolume, reverse=True) self.filteredByPrice = [c.Symbol for c in sortedByDollarVolume if c.Price > 10] return self.filteredByPrice[:1000] def OnSecuritiesChanged(self, changes): self.changes = changes #self.Log(f"OnSecuritiesChanged({self.Time}):: {changes}") for security in self.changes.RemovedSecurities: if security.Invested: self.Liquidate(security.Symbol) for security in self.changes.AddedSecurities: pass def OnDataConsolidated(self, bar): if bar.Time.hour == 9 and bar.Time.minute == 30: self.openingBar = bar else: self.openingBar = None def OnData(self, data): for i in self.filteredByPrice: if data.ContainsKey(i): self.df = self.History(i,2) self.Log(self.df.info) self.YesterdayHigh=self.df.high[1] self.Consolidate(i, Resolution.Hour, self.OnDataConsolidated) b=data[i].High if self.openingBar != None: if self.openingBar.low > self.YesterdayHigh and data[i].High > self.openingBar.High: if data[i].High > self.YesterdayHigh and (self.openingBar != None and len(df.index)>=2): self.SetHoldings(i, 0.10) def EveryDayBeforeMarketClose(self): self.Liquidate() #if self.window.IsReady and window[0].Close > window[1].Close:

In The End i get  Message:

Runtime Error: IndexError : index out of bounds at pandas._libs.util.validate_indexer File "util.pxd" in util.pxd:line 89 IndexError : index out of bounds Where i was wrong?