I was sent here after communicating with the support team over email to seek advice on how to solve this strange bug. I implemented a history lookback into an already working algorithm using the code from the Documentation as you can see in the snippet below.

def OnSecuritiesChanged(self, changes):

for security in changes.AddedSecurities:

self.Small = self.EMA(security.Symbol, 50, Resolution.Hour)

history = self.History([security.Symbol], 50, Resolution.Hour)

for time, row in history.loc[security.Symbol].iterrows():
self.Small.Update(time, row["close"])


In a backtest of the last five years, the algorithm works perfectly and is correctly using the historical data and making trades for the first four years. However, on the July 1st bar in 2019, I get an error message saying, "Object is not callable at OnSecuritiesChanged" and the algorithm stops running (it also says the error is on line 94 even though my entire code has only 83 lines, but that's likely unrelated to the issue). I am sure this error comes from the time and row loop because this algorithm was backtesting just fine before I added these lines in.

What is the problem and how do I solve it?