Overall Statistics |
Total Trades 21 Average Win 2.20% Average Loss -7.47% Compounding Annual Return 1.568% Drawdown 18.700% Expectancy 0.035 Net Profit 1.576% Sharpe Ratio 0.149 Probabilistic Sharpe Ratio 15.213% Loss Rate 20% Win Rate 80% Profit-Loss Ratio 0.29 Alpha 0.013 Beta 0.655 Annual Standard Deviation 0.159 Annual Variance 0.025 Information Ratio 0.05 Tracking Error 0.135 Treynor Ratio 0.036 Total Fees $24.75 Estimated Strategy Capacity $28000000.00 Lowest Capacity Asset AAPL R735QTJ8XC9X |
# DollarVolume-EMAC universe from AlgorithmImports import * # ------------------------------------------ N_DV = 6; FAST = 50; SLOW = 200; LEV = 1.00; # ------------------------------------------ class DollarVolumeEmacUniverse(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 6, 1) self.SetEndDate(2022, 6, 2) self.SetCash(100000) self.UniverseSettings.Resolution = Resolution.Minute self.AddUniverse(self.CoarseSelectionFunction) self.assets = [] self.ema_f = {} self.ema_s = {} self.universeMonth = -1 self.SetWarmUp(SLOW, Resolution.Daily) def CoarseSelectionFunction(self, universe): if self.Time.month == self.universeMonth: return self.assets stocks = [x for x in universe if (x.HasFundamentalData)] price_above_10 = [x for x in stocks if (x.Price > 10)] dollar_volume = sorted(price_above_10, key = lambda c: c.DollarVolume, reverse=True) self.dollar_volume_top = [c.Symbol for c in dollar_volume[:N_DV]] self.assets = self.dollar_volume_top return self.assets def OnSecuritiesChanged(self, changes): for x in changes.RemovedSecurities: if x.Symbol in self.assets: del self.assets[x.Symbol] for symbol in self.assets: self.ema_f[symbol] = self.EMA(symbol, FAST, Resolution.Daily) self.ema_s[symbol] = self.EMA(symbol, SLOW, Resolution.Daily) def OnData(self, data): if self.IsWarmingUp: return if self.Time.month == self.universeMonth: return if not (self.Time.hour == 10 and self.Time.minute == 1): return self.selectedSymbols = [] for symbol in self.assets: if self.ema_f[symbol].Current.Value > self.ema_s[symbol].Current.Value: self.selectedSymbols.append(symbol) for symbol in self.Portfolio.Keys: if symbol not in self.selectedSymbols: self.Liquidate(symbol) for symbol in self.selectedSymbols: wt = LEV/len(self.selectedSymbols) if len(self.selectedSymbols) > 0 else 0 self.SetHoldings(symbol, wt) self.universeMonth = self.Time.month