Hey Guys,

For a project i need to create my own rating.

Based on coarse and fine selection I want to create a rating (0-100) on which the trades are made.

I thought of creating an DataFrame with initializing and adding my weighted indicators.

For example:

def Initialize(self):

columns = ['SYMBOL', 'VOL', 'RATING']
self.data = pd.DataFrame(columns=columns)


def CoarseSelectionFunction(self, coarse):
selected = [x for x in coarse if (x.HasFundamentalData) and (float(x.Price) > 5)]
for x in selected:
v = lambda x: x.DollarVolume
z = lambda x: x.Symbol.Value
try:
if v > 20000000:
self.data.append(pd.DataFrame({'VOL': [1], 'SYMBOL': z}, index=[z]))
else:
self.data.append(pd.DataFrame({'VOL': [v/20000000], 'SYMBOL': z}, index=[z]))
except:
self.data.append(pd.DataFrame({'VOL': [0], 'SYMBOL': v}, index=[z]))

return [x.Symbol for x in selected]

def FineSelectionFunction(self, fine):
for x in fine:
m = lambda x: x.MarketCap
z = lambda x: x.Symbol
try:
if m >= 10000000000:
self.data.loc[z, "SIZE"] = 1
elif m <= 1000000000:
self.data.loc[z, "SIZE"] = 0
else:
self.data.loc[z, "SIZE"] = ((m - 1000000000) / 9000000000)
except:
self.data.loc[z, "SIZE"] = 0

Since I get an Attribute error when accessing Symbol in FineSelection, I'm wondering wether my approach with Lambda is even correct?