Hey All, 

I'm trying to create some renko bars from S&P500Emini ticks. The renko consolidator seems broken? when I run the following backtest with an equity (SPY) the backtest logs some renko closes. when I run the same code with the ES it fails with 

During the algorithm initialization, the following exception has occurred: ArgumentException : Please subscribe to this symbol before adding a consolidator for it. Symbol: at QuantConnect.Data.SubscriptionManager.AddConsolidator (QuantConnect.Symbol symbol, QuantConnect.Data.Consolidators.IDataConsolidator consolidator) [0x00047] in <796a9fb122d841fdaad855535a8219c0>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in :0 at Initialize in main.py:line 35 ArgumentException : Please subscribe to this symbol before adding a consolidator for it. Symbol: at QuantConnect.Data.SubscriptionManager.AddConsolidator (QuantConnect.Symbol symbol, QuantConnect.Data.Consolidators.IDataConsolidator consolidator) [0x00047] in <796a9fb122d841fdaad855535a8219c0>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in :0

the code I'm running.

from clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Common") from System import * from QuantConnect import * from QuantConnect.Data import * from QuantConnect.Data.Market import * from QuantConnect.Algorithm import * from QuantConnect.Indicators import * from QuantConnect.Securities import * from QuantConnect.Data.Consolidators import * from datetime import timedelta class TestFuturesAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2013, 10, 7) self.SetEndDate(2013, 10, 11) self.SetCash(1000) # spy_equity = self.AddSecurity(SecurityType.Equity, "SPY", Resolution.Tick).Symbol es_future = self.AddFuture(Futures.Indices.SP500EMini, Resolution.Tick) es_future.SetFilter(timedelta(0), timedelta(182)) renkoClose = RenkoConsolidator(0.5, RenkoType.Wicked) renkoClose.DataConsolidated += self.HandleRenkoClose self.SubscriptionManager.AddConsolidator(Futures.Indices.SP500EMini, renkoClose) # self.SubscriptionManager.AddConsolidator(spy_equity, renkoClose) def OnData(self,slice): pass def HandleRenkoClose(self, sender, data): '''This function is called by our renkoClose consolidator defined in Initialize() Args: data: The new renko bar produced by the consolidator''' if not self.Portfolio.Invested: self.SetHoldings(data.Symbol, 1) self.Log(f"CLOSE - {data.Time} - {data.Open} {data.Close}")

 

Author