How to do this in C#?

def CoarseSelectionFunction(self, coarse): if self.rebalence_flag or self.first_month_trade_flag: # drop stocks which have no fundamental data or have too low prices selected = [x for x in coarse if (x.HasFundamentalData) and (float(x.Price) > 5)] # rank the stocks by dollar volume filtered = sorted(selected, key=lambda x: x.DollarVolume, reverse=True) return [ x.Symbol for x in filtered[:200]] else: return self.symbols def FineSelectionFunction(self, fine): if self.rebalence_flag or self.first_month_trade_flag: hist = self.History([i.Symbol for i in fine], 1, Resolution.Daily) try: filtered_fine = [x for x in fine if (x.ValuationRatios.EVToEBITDA > 0) and (x.EarningReports.BasicAverageShares.ThreeMonths > 0) and float(x.EarningReports.BasicAverageShares.ThreeMonths) * hist.loc[str(x.Symbol)]['close'][0] > 2e9] except: filtered_fine = [x for x in fine if (x.ValuationRatios.EVToEBITDA > 0) and (x.EarningReports.BasicAverageShares.ThreeMonths > 0)] top = sorted(filtered_fine, key = lambda x: x.ValuationRatios.EVToEBITDA, reverse=True)[:self.num_screener] self.symbols = [x.Symbol for x in top] self.rebalence_flag = 0 self.first_month_trade_flag = 0 self.trade_flag = 1 return self.symbols else: return self.symbols

I tried:

public IEnumerable<Symbol> FineSelectionFunction(IEnumerable<FineFundamental> fine) { if (!_reSelectUniverse) return Enumerable.Empty<Symbol>(); var hist = History(fine.Select(x => x.Symbol), 1, Resolution.Daily); try { filtered = from x in fine where x.SecurityReference.SecurityType == "ST00000001" where x.SecurityReference.IsPrimaryShare where x.ValuationRatios.EVToEBITDA > 0 where x.EarningReports.BasicAverageShares.ThreeMonths > 0 where ((float) x.EarningReports.BasicAverageShares.ThreeMonths) * hist ????) > 2 * 1000 * 1000 * 1000) select x; filtered_fine = [x for x in fine if (x.ValuationRatios.EVToEBITDA > 0) and(x.EarningReports.BasicAverageShares.ThreeMonths > 0) and float(x.EarningReports.BasicAverageShares.ThreeMonths) * hist.loc[str(x.Symbol)]['close'][0] > 2e9] } catch { except: filtered_fine = [x for x in fine if (x.ValuationRatios.EVToEBITDA > 0) and(x.EarningReports.BasicAverageShares.ThreeMonths > 0)] } return filtered.OrderByDescending(x => x.ValuationRatios.EVToEBITDA).Select(x => x.Symbol); }

no success so far...

Author