I have troubles with futures using consolidator and indicators.

I don't get any data coming trough OnData and OnBar

Please help!

from System import * from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Indicators import * class Strategy(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) self.SetCash(100000) self.symbols = ['ZW', "ZC", "ZS", "ZM", "ZL", "ZO"] self.res_data = Resolution.Hour self.res_bar = Resolution.Daily self.res_cons = timedelta(hours=24) self.SetTimeZone("America/New_York") self.futures = {} self.db = {} self.ind = {} self.p = AttrDict() self.p.ema_period = 9 self.p.bb_period = 20 self.p.bb_std = 2 self.p.bb_ma = MovingAverageType.Simple for s in self.symbols: self.init_symbol(s) warm_period = max([self.p.ema_period, self.p.bb_period]) + 1 self.SetWarmUp(timedelta(hours=warm_period)) def init_symbol(self, s): self.futures[s] = self.AddFuture(s, self.res_data) self.futures[s].SetFilter(timedelta(0), timedelta(182)) self.Consolidate(self.futures[s].Symbol, self.res_bar, self.OnBar) self.ind[s] = {} self.ind[s]['ema'] = ema = ExponentialMovingAverage( self.p.ema_period) self.ind[s]['bb'] = bb = BollingerBands( self.p.bb_period, self.p.bb_std, self.p.bb_ma) self.RegisterIndicator(self.futures[s].Symbol, ema, self.res_bar) self.RegisterIndicator(self.futures[s].Symbol, bb, self.res_bar) self.db[s] = {} self.db[s]['history'] = RollingWindow[QuoteBar]( self.p.entry_valid) self.db[s]['ema'] = RollingWindow[IndicatorDataPoint]( self.p.entry_valid) self.db[s]['bb_top'] = RollingWindow[IndicatorDataPoint]( self.p.entry_valid) self.db[s]['bb_mid'] = RollingWindow[IndicatorDataPoint]( self.p.entry_valid) self.db[s]['bb_bot'] = RollingWindow[IndicatorDataPoint]( self.p.entry_valid) self.db[s]['prices'] = [] def OnData(self, data): self.Debug('OnData') def OnBar(self, bar): s = bar.Symbol.Value self.Debug('OnBar %s' % s) class AttrDict(dict): def __init__(self, *args, **kwargs): super(AttrDict, self).__init__(*args, **kwargs) self.__dict__ = self

 

Author