Hi! I'm trying to add the Keltner Channels indicator as an extra filter for my universe selection, but I seem to be encountering some problems. Before trying to add the keltner indicator, I was only constructing EMAs and an RSI indicator to use for my universe selection, but I wasn't encountering this problem then with just these indicators. After trying to add the Keltner Channel, I encounter this error:
Runtime Error: TypeError : 'Timestamp' object does not support indexing
at <lambda> in FundamentalUniverseSelectionModel.py:46
TypeError : 'Timestamp' object does not support indexing (Open Stacktrace)
This is the class constructor:
class SelectionData():
def __init__(self, history):
self.slow = ExponentialMovingAverage(200)
self.fast = ExponentialMovingAverage(50)
self.keltner = KeltnerChannels(10, 2, MovingAverageType.Simple)
for bar in history.itertuples():
tradeBar = TradeBar(bar.Index[1], bar.Index[0], bar.open, bar.high, bar.low, bar.close, bar.volume, timedelta(1))
self.fast.Update(bar.Index[1], bar.close)
self.slow.Update(bar.Index[1], bar.close)
self.keltner.Update(tradeBar)
def is_ready(self):
return self.slow.IsReady and self.fast.IsReady and self.keltner.IsReady
def update(self, time, price):
self.fast.Update(time, price)
self.slow.Update(time, price)
And how I apply it to the symbols:
for security in sortedByDollarVolume:
symbol = security.Symbol
dollar = self.dollarVolumeBySymbol[symbol]
price = self.AdjustedPrice[symbol]
if symbol in history_symbols:
if not str(symbol) in history.index:
continue
self.averages[symbol] = SelectionData(history.loc[symbol])
self.averages[symbol].update(algorithm.Time, price)
selected[symbol] = dollar
https://www.quantconnect.com/forum/discussion/8840/keltner-channel-on-a-class