This question is related to here. I am facing the same error when my algorithm trading through IB. Following is part of the order execution source code I am using. I would like to ask how to keep my algorithm running? Whcih dictionary should I check before sending limited order so that I can avoid the exception and keep my algorithm running? Thanks.

 

try:
if not self.ActiveSecurities.ContainsKey(symbol): return
quantity = self.CalculateOrderQuantity(symbol, weight)

self.LimitOrder(symbol, quantity, self.Securities[symbol].Price)

self.Log("Symbol: {} Price: {}".format(symbol, self.Securities[symbol].Price))
except Exception as e:
self.Log("Exception: {}".format(e))

 

I have already checked the self.ActiveSecurities dictionary,  and I am using try catch. I would like to ask what else is missing? Thanks