Hi All,
Sorry to ask a noob question, but I am trying to use fine fundamental to sort small cap stocks like in the tutorial link at the bottom. I'm new to C# and just can't seem to get the code right for the the for loop/sort function in the below python example.
This is snippet of code I am struggling with. It is the for loop I can't get working
def FineSelectionFunction(self, fine):
if self.yearly_rebalance:
fine = [x for x in fine if (x.ValuationRatios.PERatio > 0)
and (x.EarningReports.BasicAverageShares.ThreeMonths > 0)
and (x.EarningReports.BasicEPS.TwelveMonths > 0)]
##THE BELOW FOR LOOP I CANT CONVERT PROPERLY##
for i in fine:
i.MarketCap = float(i.EarningReports.BasicAverageShares.ThreeMonths * (i.EarningReports.BasicEPS.TwelveMonths*i.ValuationRatios.PERatio))
sorted_market_cap = sorted(fine, key=lambda x: x.MarketCap)
self.filtered_fine = [i.Symbol for i in sorted_market_cap[:20]]
self.yearly_rebalance = False
return self.filtered_fine
else:
return []
This is the code I currently have: note it is incomplete
public IEnumerable<Symbol> FineSelectionFunction(IEnumerable<FineFundamental> fine)
{
// return list of symbols
var fineStocks = (from f in fine
//where f => f.ValuationRatios.PERatio > 0 && f.EarningReports.BasicAverageShares.ThreeMonths > 0 && f.EarningReports.BasicEPS.TwelveMonths > 0
where f.ValuationRatios.PERatio > 0 && f.EarningReports.BasicAverageShares.ThreeMonths > 0 && f.EarningReports.BasicEPS.TwelveMonths > 0
orderby f.ValuationRatios.PERatio ascending
//select f.Symbol).Take(10);
select f.Symbol);
I would appreciate a kind sir to help a noob out please :)