Hello, when I launch this algorithm it returns me an error.However I don't see what can be wrong.Can Someone help me please
Thank You
class DynamicHorizontalChamber(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019, 1, 7)
self.SetEndDate(2019, 4, 1)
self.SetCash(100000)
self.UniverseSettings.Resolution = Resolution.Daily
self.AddUniverse(self.CoarseSelectionFunction)
self.averages = { }
def SelectionFunction(self, universe):
selected = []
universe = sorted(universe, key=lambda c: c.DollarVolume, reverse=True)
universe = [c for c in universe if c.Price > 100][:100]
for coarse in universe:
symbol = coarse.Symbol
if symbol not in self.averages:
history = self.History(symbol, 200, Resolution.Daily)
self.averages[symbol] = Selection(history)
self.averages[symbol].update(self.Time, coarse.AdjustedPrice)
if self.averages[symbol].is_ready() and self.averages[symbol].stt < 20:
selected.append(symbol)
return selected[100:]
def OnSecuritiesChanged(self, changes):
self.changes = changes
self.Log(f"OnSecuritiesChanged({self.Time}):: {changes}")
for security in self.changes.RemovedSecurities:
if security.Invested:
self.Liquidate(security.Symbol)
for security in self.changes.AddedSecurities:
self.SetHoldings(security.Symbol, 0.10)
class Selection():
def __init__(self,history):
self.stt = StandardDeviation(200)
for bar in history.itertuples():
self.stt.Update(bar.Index[1],bar.close)
def is_ready(self):
return self.stt.IsReady
def update(self, time, price):
self.stt.Update(time,price)