Hi all,
I've followed the 200-50 Momentum Universe tutorial to the letter and attempted to substitute the indicators for bollinger bands and keltner channels. When running the algorithm it returns algorithm has no attribute self.indicators. In adding this into the Initialize method it then returns, algorithm has no attribute time. Can anyone help me in fixing this? What am I doing wrong?
Thanks!
class KeltnerBollingerSelectionModel2(QCAlgorithm):
def Initialize(self):
self.indicators = {}
def CoarseSelectionFunction(self, universe):
selected = []
universe = sorted(universe, key = lambda c: c.DollarVolume, reverse = True)
universe = [c for c in universe][:100]
for coarse in universe:
symbol = coarse.Symbol
if symbol not in self.indicators:
self.indicators[symbol] = SelectionData()
self.indicators[symbol].update(self.time, coarse.AdjustedPrice)
if self.indicators[symbol].bollinger.UpperBand < self.indicators[symbol].keltner.UpperBand and \
self.indicators[symbol].bollinger.LowerBand > self.indicators[symbol].keltner.LowerBand:
if self.indicators[symbol].is_ready():
selected.append(symbol)
return selected
class SelectionData(object):
def __init__(self):
self.bollinger = BollingerBands(20, 2, movingAverageType = MovingAverageType.Simple)
self.keltner = KeltnerChannels(20, 1.5, movingAverageType = MovingAverageType.Simple)
def is_ready(self):
return self.bollinger.IsReady and self.keltner.IsReady
def update(self, time, price):
self.bollinger.Update(time, price)
self.keltner.Update(time, price)
Louis Szeto
Hi Nicholas
Please refer to this related thread.
Best
Louis Szeto
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Nicholas Fitzgerald
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!