Hi Andrew Chan ,
In the code snippet, there is no AddOptionContract call.
Could you please share a backtest that reproduces the issue?
A common mistake is adding a contract with AddOptionContract method and placing an order at the same time iteration. In other words, if the algorithm adds a contract in OnData, it will need to until the next time OnData is triggered to place an order.
You can set a security initializer that will fetch the last know price and warm up the security:
self.SetSecurityInitializer(lambda x: x.SetMarketPrice(self.GetLastKnownPrice(x)))
Please note that it can get the closing price of the previous trading session depending on the time AddOptionContract was called and the liquidity of the contract.
P.S.: Since GetLastKnowPrice makes a history request, it may slow the algorithm down.