I want to create a stock selection model base on: 

1) market cap > $n Million, 

2) average turnover($dollar) > $n Million

3) in two industry 

4) select above list of stock that match: n period EMA < today EMA (e.g two months 60 days EMA < today 60 days EMA) 

 

So how to add average turnover to the model and return a list that can screen out all the stocks that meet 4) EMA criteria ?? Thanks

Here is my work for now, please feel free to comment any improvement:

main.py: 

from universe_selection import UniverseSelectionModel class UncoupledNadionFlange(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 6, 13) # Set Start Date self.SetCash(10000) # Set Strategy Cash self.UniverseSettings.Resolution = Resolution.Daily self.CustomUniverseSelectionModel = UniverseSelectionModel(self) self.AddUniverse(self.UniverseSelectionModel.SelectCoarse, self.UniverseSelectionModel.SelectFine) def OnData(self, data): pass

universe_selection.py:

class UniverseSelectionModel(): def __init__(self, algorithm): self.algorithm = algorithm def SelectCoarse(self, coarse): universe = self.FilterMarket(coarse) return [c.Symbol for c in universe] def SelectFine(self, fine): universe = self.FilterIndustry(fine) self.algorithm.securities = universe return [f.Symbol for f in universe] def FilterMarket(self, coarse): marketcap = [c for c in coarse if c.Fundamentals.MarketCap > 10000000000] return marketcap def FilterIndustry(self, fine): filter_industry = [f for f in fine if f.AssetClassification.MorningstarIndustryCode.ShippingAndPorts and MorningstarIndustryCode.Trucking] return filter_industry

 

Author