Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 1.539 Tracking Error 0.143 Treynor Ratio 0 Total 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) self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction) 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]