I'm looking to create an algorithm that returns a list of companies that meet the following 5 criteria:

1. 20% revenue growth over the next 3 years

2. Cash > short term debt

3. PEG ratio not above 1.5

4. Within 3% of the 50dma or 200dma

5. Free cash flow positive

I've completed the boot camp and have been following the tutorials on universe selection but I'm new to all of this. I'm finding plenty of help with returning a list sorted by some value (dollar volume for example) but I need a list of companies that meet these criteria not a ranked list.

Here's the code I edited from the Stock Selection Strategy Based On Fundamental Factors Algorithm found in the strategy library. I would include a backtest but it won't even build. The issue is clearly in the FineSelectionFunction().

class StockSelectionStrategyBasedOnFundamentalFactorsAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2009, 1, 2) # Set Start Date self.SetEndDate(2017, 5, 2) # Set End Date self.SetCash(50000) # Set Strategy Cash self.current_month = -1 self.coarse_count = 300 self.fine_count = 10 self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction) self.SetAlpha(ConstantAlphaModel(InsightType.Price, InsightDirection.Up, timedelta(30))) self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel(lambda time:None)) def CoarseSelectionFunction(self, coarse): if self.current_month == self.Time.month: return Universe.Unchanged self.current_month = self.Time.month sortedByDollarVolume = sorted([x for x in coarse if x.HasFundamentalData], key=lambda x: x.DollarVolume, reverse=True)[:self.coarse_count] return [i.Symbol for i in sortedByDollarVolume] def FineSelectionFunction(self, fine): fine = [x for x in fine if x.FinancialStatements.BalanceSheet.Cash.OneMonth > x.FinancialStatements.BalanceSheet.CurrentLiabilities.OneMonth and x.ValuationRatios.PEGRatio < 1.5 and x.FinancialStatements.CashFlowStatement.FreeCashFlow.OneMonth > 0 and x.ValuationRatios.SecondYearEstimatedEPSGrowth > 0.12 sortedByfactor1 = sorted(fine, key=lambda x: x.FinancialStatements.BalanceSheet.Cash.OneMonth > x.FinancialStatements.BalanceSheet.CurrentLiabilities.OneMonth) sortedByfactor2 = sorted(fine, key=lambda x: x.ValuationRatios.PEGRatio < 1.5) sortedByfactor3 = sorted(fine, key=lambda x: x.FinancialStatements.CashFlowStatement.FreeCashFlow.OneMonth > 0) sortedByfactor4 = sorted(fine, key=lambda x: x.ValuationRatios.SecondYearEstimatedEPSGrowth > 0.12) stock_dict = {} for rank1, ele in enumerate(sortedByfactor1): rank2 = sortedByfactor2.index(ele) rank3 = sortedByfactor3.index(ele) rank4 = sortedByfactor4.index(ele) stock_dict[ele] = rank1 + rank2 + rank3 + rank4 sorted_stock = sorted(stock_dict.items(), key=lambda d:d[1], reverse=True)[:self.fine_count] return [x[0].Symbol for x in sorted_stock]

Any help with this would be greatly appreciated. I think these are good criteria to trade on.