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 9.117 Tracking Error 0.097 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
# region imports from AlgorithmImports import * # endregion class VolumeAggregationError(QCAlgorithm): def Initialize(self): self.SetStartDate(2022, 5, 1) # Set Start Date self.SetEndDate(2022, 5, 3) # Set Start Date self.SetCash(100000) # Set Strategy Cash self.display = False # Symbol. self.Ticker = "BTCUSDT" self.H1VolumeRollingWindowLength = 5 # Binance brokerage model set-up. self.SetBrokerageModel(BrokerageName.Binance, AccountType.Margin) # Initialise Binance symbol. self.MinuteSymbol = self.AddCrypto(self.Ticker, Resolution.Minute, Market.Binance).Symbol # Initialise RollingWindow. self.H1VolumeRollingWindow = RollingWindow[float](self.H1VolumeRollingWindowLength) # Create a 1-hour TradeBarConsolidator. H1Consolidator = TradeBarConsolidator(timedelta(minutes=60)) # Subscribe the method OnNewH1Bar to the consolidation event. H1Consolidator.DataConsolidated += self.OnNewH1Bar # Add the consolidator to the SubscriptionManager to update it automatically with self.MinuteSymbol data. self.SubscriptionManager.AddConsolidator(self.MinuteSymbol, H1Consolidator) self.CurrentH1Volume = 0 def OnNewH1Bar(self, sender, consolidated): # Add volume data of the bar that was just fully consolidated to the H1VolumeRollingWindow. self.H1VolumeRollingWindow.Add(consolidated.Volume) self.display = True def OnData(self, data: Slice): self.CurrentH1Volume = self.CurrentH1Volume + data.Bars[self.MinuteSymbol].Volume if self.display: # TODO: check diff. self.Debug("{0} Consolidated: {1}. Sum: {2}. Abs. difference {3}.".format(self.UtcTime, self.H1VolumeRollingWindow[0], self.CurrentH1Volume, self.CurrentH1Volume - self.H1VolumeRollingWindow[0])) self.CurrentH1Volume = 0 self.display = False