Overall Statistics |
Total Trades 12 Average Win 0.00% Average Loss -0.55% Compounding Annual Return -12.572% Drawdown 4.700% Expectancy -0.833 Net Profit -2.723% Sharpe Ratio -1.788 Probabilistic Sharpe Ratio 7.220% Loss Rate 83% Win Rate 17% Profit-Loss Ratio 0.00 Alpha -0.077 Beta -0.19 Annual Standard Deviation 0.059 Annual Variance 0.004 Information Ratio -2.259 Tracking Error 0.116 Treynor Ratio 0.558 Total Fees $13.11 Estimated Strategy Capacity $870000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
# https://quantpedia.com/Screener/Details/14 class MomentumEffectAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 7, 1) # Set Start Date self.SetCash(100000) # Set Strategy Cash self.UniverseSettings.Resolution = Resolution.Daily self.macd = {} # Dict of Momentum indicator keyed by Symbol self.num_coarse = 100 # Number of symbols selected at Coarse Selection self.num_fine = 50 # Number of symbols selected at Fine Selection self.userlist = ["SPY"] #User list self.spy = self.AddEquity("SPY", Resolution.Daily).Symbol self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction) def CoarseSelectionFunction(self, coarse): return [x.Symbol for x in coarse if x.Symbol.Value in self.userlist] def FineSelectionFunction(self, fine): return [x.Symbol for x in fine if x.Symbol.Value in self.userlist] def OnData(self, data): for i in self.Securities.Keys: self.Debug(self.macd[i].Current.Value) if self.macd[i].Current.Value > self.macd[i].Signal.Current.Value: self.SetHoldings(i, 1) elif self.macd[i].Signal.Current.Value > self.macd[i].Current.Value: self.Liquidate(i) def OnSecuritiesChanged(self, changes): # Clean up data for removed securities and Liquidate for security in changes.RemovedSecurities: pass for security in changes.AddedSecurities: if security.Symbol not in self.macd: self.macd[security.Symbol] = MovingAverageConvergenceDivergence(12, 26, 9, MovingAverageType.Exponential) history = self.History(security.Symbol, 100, Resolution.Daily).loc[security.Symbol] for idx, row in history.iterrows(): self.macd[security.Symbol].Update(idx, row['close']) self.RegisterIndicator(security.Symbol, self.macd[security.Symbol], Resolution.Daily)