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 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
from datetime import datetime class DynamicCalibratedContainmentField(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 9, 28) # Set Start Date self.SetEndDate(2021, 9, 28) #Set End Date self.SetCash(50000) ticker = Futures.Indices.Dow30EMini future = self.AddFuture(ticker, Resolution.Minute) # Daily Minute future.SetFilter(0, 183) self.barWindow = RollingWindow[QuoteBar](1) self.macdWindow = RollingWindow[IndicatorDataPoint](5) self.hmaWindow = RollingWindow[IndicatorDataPoint](5) self.currentSymbol = "testing" self.marketOpenTime = datetime(2010, 1, 9, 7, 25, 0).time() self.marketCloseTime = datetime(2010, 1, 9, 10, 30, 0).time() self.consolidator_by_symbol = {} self.calls = 0 self.current_min = 0 self.current_date = 0 self.macd = None self.hma = None self.SetWarmUp(timedelta(27)) def OnData(self, data): if self.current_min == self.Time.minute: return # register the new future for chain in data.FutureChains: contracts = list(filter(lambda x: x.Expiry >= self.Time , chain.Value)) if len(contracts) == 0: continue sortedContracts = sorted(contracts, key=lambda k : k.Expiry) contract = sortedContracts[0] if contract.Symbol not in self.consolidator_by_symbol: CountConsolidator = QuoteBarConsolidator(timedelta(minutes=5)) CountConsolidator.DataConsolidated += self.BarHandler self.SubscriptionManager.AddConsolidator(contract.Symbol, CountConsolidator) self.consolidator_by_symbol[contract.Symbol] = CountConsolidator # self.macd = self.MovingAverageConvergenceDivergence(12, 26, 9, MovingAverageType.Exponential) # self.RegisterIndicator(contract.Symbol, self.macd, timedelta(minutes=5)) # self.hma = SimpleMovingAverage(2) self.hma = HullMovingAverage(2) self.RegisterIndicator(contract.Symbol, self.hma, CountConsolidator) # self.macd.Updated += self.macdUpdated self.hma.Updated += self.hmaUpdated self.currentSymbol = contract.Symbol if self.Time.time() >= self.marketOpenTime and self.Time.time() <= self.marketCloseTime: if self.barWindow.IsReady and self.hma.IsReady: # self.Debug(", {}, {}, {}, {}, {}, {}".format(data[self.currentSymbol].Open, data[self.currentSymbol].High, data[self.currentSymbol].Low, data[self.currentSymbol].Close, self.hma.Current.Value, self.hmaWindow[1].Value)) self.Debug(", {}, {}, {}, {}".format(self.barWindow[0].Close, data[self.currentSymbol].Close, self.hma.Current.Value, self.hmaWindow[0].Value)) self.current_min = self.Time.minute def BarHandler(self, sender, bar): self.barWindow.Add(bar) def macdUpdated(self, sender, updated): self.macdWindow.Add(updated) def hmaUpdated(self, sender, updated): self.hmaWindow.Add(updated)