I would expect coarse universe selection to be able to automatically add and remove securities. However, I am running into the following two issues right now:
1. I still need to call self.AddEquity() specifically to be able to get stock price through self.Securities[stock].Price.
2. self.Securities.Count keeps on growing. I suppose it will hit memory issue if the securities maintained by self.Securities keep on growing.
Does anyone know anything about this? How do I fix those issues? Any suggestions are welcome!
The following is how I am using coarse universe selection:
...
self.UniverseSettings.Resolution = Resolution.Minute
self.AddUniverse(self.CoarseSelectionFunction)
...
def CoarseSelectionFunction(self, coarse):
CoarseWithFundamental = [x for x in coarse if x.HasFundamentalData]
sortedByDollarVolume = sorted(CoarseWithFundamental, \
key=lambda x: x.DollarVolume, reverse=True)
return [ x.Symbol for x in sortedByDollarVolume[:250] ]
Thanks,
Jessica