Say I want to trade only the top 10 holdings of QQQ.  Can this be done via a Coarse/Fine universal selection?

Anyone have an example of this?


I would be envisioning something like the following, but specific to an ETF rather than a sector.

  1. def Coarse(self, coarse):
  2. if self.Time.month == self.lastMonth:
  3. return Universe.Unchanged
  4. self.lastMonth = self.Time.month
  5. allCoarse = [x for x in coarse if x.HasFundamentalData and x.Price > 1 and x.Volume > 1]
  6. finalCoarse = sorted(allCoarse, key = lambda x: x.DollarVolume, reverse = True)
  7. return [x.Symbol for x in finalCoarse][:1]
  8. def Fine(self, fine):
  9. filteredSymbols = []
  10. sortedBySector = [x for x in fine]
  11. for code, g in groupby(sortedBySector, lambda x: x.AssetClassification.MorningstarSectorCode):
  12. for x in sorted(g, key = lambda x: x.ValuationRatios.PERatio, reverse = True)[:1]:
  13. filteredSymbols.append(x.Symbol)
  14. return filteredSymbols[:10]
+ Expand

Author

Axist

July 2021