Hello everyone:

I am working to set up a stop loss and profit taking target for options trading. As a base I am using one of the options projects from QuantConnect.

I have added to this project:

1 - a stop market order at 0.9 * buy price

2 - a stop limit order at 1.2 * buy price

3 - an OnOrderEvent to cancel the remaining order if stop is hit

It seems that the stop limit order is working as it should. Unfortunately, it seems that my stop market order does not get cancelled and sells again (short calls) when that price is hit. 

I am wondering if the following code needs to be adjusted somehow to cancel an options order:


if order.Status == OrderStatus.Filled:
           if order.Type == OrderType.Limit or OrderType.StopMarket:
               self.Transactions.CancelOpenOrders(order.Symbol)

Thank you for the assistance.

Author