Hello QuantConnect community,

I'm currently building an algorithm that relies on the ScheduledUniverseSelectionModel so I can pick stocks for my universe at a certain time. However, the problem is that it retains all of the stocks in the universe even after the day ends. So the next day, when I run self.Securities, it includes all of the securities from the previous day. I tried doing RemoveSecurity, but that didn't seem to work. Is there a way I can remove my securities (kind of like the fundamental / coarse universe selection) or have it reset each day like how it does in the liquid universe selection methods?

Thank you!

class Algo(QCAlgorithm):        def Initialize(self):         self.SetCash(10000)         self.SetStartDate(2020, 9, 1)         self.SetEndDate(2020, 10, 1)                  self.AddEquity("SPY")         self.AddUniverseSelection(ScheduledUniverseSelectionModel(self.DateRules.EveryDay("SPY"), self.TimeRules.At(9, 25), self.AddStocks))         self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.BeforeMarketClose("SPY", 5), self.RemoveStocks)         def AddStocks(self, dateTime):         data = pandas.read_csv(io.StringIO(self.Download("https://dropbox.com/my_stocks.csv")                   for symbol in data[data.columns[data.columns.get_loc(dateTime.strftime("%F"))]].to_list():             symbols.append(Symbol.Create(symbol, SecurityType.Equity, Market.USA))                  return symbols          def RemoveStocks(self):                 map(lambda x: self.RemoveSecurity(x.Key) if x.Key != "SPY" else None, self.Securities)    

 

Author