Hi guys,

I'm one of the folks just migrated from Quantopian. I've completed the bootcamp and I was starting converting my algos to the quantconnect framework.

I'm just struggling now with the following stock selection method, to filter and sort a fixed amount of stocks, from the Q1500 universe. Sorting should be done for a set of multiple parameters (LongTermDebt, cash ret, yield, etc.)

 universe = Q1500US() cash_return = ms.cash_return.latest.rank(mask=universe) fcf_yield = ms.fcf_yield.latest.rank(mask=universe roic = ms.roic.latest.rank(mask=universe) ltd_to_eq = ms.long_term_debt_equity_ratio.latest.rank(mask=universe) value = (cash_return + fcf_yield).rank() quality = ltd_to_eq # Momentum Factor returns_overall = Returns(window_length=context.MomentumDays) returns_recent = Returns(window_length=context.MomentumRecendDays) momentum = returns_overall - returns_recent # Filters for top quality and momentum to use in our selection criteria top_quality = quality.top(context.BestROEQTY, mask=universe) top_quality_filter = quality.top(context.BestQualityQTY, mask=universe) top_quality_momentum = momentum.top(context.SecuritiesToSelectQTY, mask=top_quality) 

I've started using the following selection methodology via the Coarse and Fine selection, but still a bit more to go:

class LiquidValueUniverseSelectionModel(FundamentalUniverseSelectionModel): def __init__(self): super().__init__(True, None, None) self.lastWeek = -1 def SelectCoarse(self, algorithm, coarse): if not algorithm.Time.day % 7 == 0: return Universe.Unchanged sortedByDollarVolume = sorted([x for x in coarse if x.HasFundamentalData], key=lambda x: x.DollarVolume, reverse=True) return [x.Symbol for x in sortedByDollarVolume[:100]] def SelectFine(self, algorithm, fine): if not algorithm.Time.day % 7 == 0: return Universe.Unchanged sortedByCashReturn = sorted(fine, key=lambda f: f.ValuationRatios.CashReturn, reverse=True) sortedByYields = sorted(sortedByCashReturn, key=lambda f: f.ValuationRatios.EarningYield, reverse=True)

Would somebody try to help me out on how to sort for multiple fundamentals charateristics, and