After purchases equity, I want to submit an OCO order. However, it does not appear QuantConnect has support for this?
So instead, I submit two tickets: 1) take profit (limit_order) and 2) stop loss (stop_market_order). I have code set up to handle canceling the other order if one is filled.
This works fine locally, and in backtesting.
However, when I launch my algo live, using Schwab as the brokerage, Schwab returns an error saying that my tickets will result in an oversold/overbought position. It then only accepts one of the two orders (the take profit order). I am approved for the highest level of options trading, and for shorting, and have margin, so I am unsure why it returns this error.
Due to this issue, I've had to re-work my algo with a custom risk manager. It is less efficient and the backtest results are much poorer now.
Has anyone else found a good workaround for this? In thinkorswim, and on schwab, you can definitely submit OCO orders, but unsure how we can submit that via QuantConnect. I called Schwab and they were not super aware about QuantConnect and told me to just use the thinkorswim platform, haha!
Any guidance would be greatly appreciated!! Thank you
Mia Alissi
How this addresses Schwab's limitations:
If Schwab or QuantConnect adds native OCO support in the future, this logic can be simplified. For now, this is the most reliable workaround to avoid the error and maintain OCO logic as much as possible.
Sources: Stop Limit Order Regression Algorithm, Other Order Types - QuantConnect.com, Stop Limit Orders - QuantConnect.com, docs writing algorithms trading and orders order management order tickets, Limit If Touched Regression Algorithm
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.
All Gold
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!