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.
Derek Melchin
Hi Jacob,
In the backtest above, we couldn't find a case where one of the take-profit or stop-loss orders weren't cancelled correctly. However, it usually occurs when the two orders fall within the range of a single TradeBar, causing both orders to execute.
Best,
Derek Melchin
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Jacob Ricks
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!