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 -10.13 Tracking Error 0.022 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
from clr import AddReference AddReference("QuantConnect.Common") AddReference("QuantConnect.Algorithm.Framework") AddReference("QuantConnect.Indicators") from QuantConnect import * from QuantConnect.Indicators import * class EMAMomentumUniverse(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 8, 15) self.SetCash(25000) self.SetTimeZone("America/New_York") self.UniverseSettings.Resolution = Resolution.Minute self.AddUniverse(self.Coarse, self.Fine) self.averages = { } self.selected = [] self.fine_universe = [] self.SetWarmUp(200) self.ATRscan = { } def Coarse(self, coarse): self.selected = [] coarse = sorted(coarse, key=lambda c: c.DollarVolume, reverse=True) self.selected = [c.Symbol for c in coarse if (c.HasFundamentalData and c.Price > 100 and c.Price < 1000)][:100] return self.selected def Fine(self, fine): sortedfine = sorted(fine, key=lambda x: x.MarketCap) self.fine_universe = [x.Symbol for x in sortedfine if x.MarketCap > 650000000000 ][:10] return self.fine_universe def OnData(self, data): if self.IsWarmingUp: return for symbol in self.fine_universe: if symbol not in self.ATRscan: SPC_history = self.History(symbol, 14, Resolution.Minute) self.ATRscan[symbol] = SPC_Data(symbol, SPC_history) for symbol, spc_data in self.ATRscan.items(): if data.Bars.ContainsKey(symbol): spc_data.update(data.Bars[symbol]) if spc_data.ATR14.IsReady: ATR = spc_data.ATR14.Current.Value else: seld.Debug("ATR not ready") # Self.Debug(f"Symbol: {symbol} ATR: {ATR} Time: {self.Time}") class SPC_Data: def __init__(self, symbol, SPC_history): self.symbol = symbol self.ATR14 = AverageTrueRange(14, MovingAverageType.Wilders) # self.ATR14 = NormalizedAverageTrueRange(14) for bar in SPC_history.itertuples(): tbar = TradeBar(bar.Index[1], self.symbol, bar.open, bar.high, bar.low, bar.close, bar.volume) self.ATR14.Update(tbar) def is_ready(self): return self.ATR14.IsReady def update(self, bar): self.ATR14.Update(bar)