Overall Statistics Total Trades0Average Win0%Average Loss0%Compounding Annual Return0%Drawdown0%Expectancy0Net Profit0%Sharpe Ratio0Probabilistic Sharpe Ratio0%Loss Rate0%Win Rate0%Profit-Loss Ratio0Alpha0Beta0Annual Standard Deviation0Annual Variance0Information Ratio1.539Tracking Error0.143Treynor Ratio0Total Fees\$0.00
import pandas as pd
class MyAlgo(QCAlgorithm):

def Initialize(self):
self.SetCash(100000)
self.SetStartDate(2020, 11, 13)

columns = ['SYMBOL', 'VOL', 'SIZE', '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) and x.DollarVolume][:10]
for x in selected:
v = x.DollarVolume
z = x.Symbol.Value

if v > 20000000:
self.data.append(pd.DataFrame({'VOL': [1], 'SYMBOL': z, 'SIZE':0, 'RATING':0}, index=['SYMBOL']))
else:
self.data.append(pd.DataFrame({'VOL': [v/20000000], 'SYMBOL': z, 'SIZE':0, 'RATING':0}, index=['SYMBOL']))

return [x.Symbol for x in selected]

def FineSelectionFunction(self, fine):
for x in fine:
if not x.MarketCap:
continue
m = x.MarketCap
z = x.Symbol.Value

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)

return [x.Symbol for x in fine]