I have tried unsuccessfully to implement simulated bracket orders as described in QuantConnect's documentation and other community posts. My broker is Alpaca and when I try to submit a market order followed by a limit order and stop market order (or vice versa), the third order is returned as invalid and is not successfully submitted.
After reading Alpaca's documentation, I believe this is to be expected. Here's a link to the documentation for bracket orders:
Relevant excerpt: “Without a bracket order, you would not be able to submit both entry and exit orders simultaneously since Alpaca’s system only accepts exit orders for existing positions. Additionally, even if you had an open position, you would not be able to submit two conditional closing orders since Alpaca’s system would view one of the two orders as exceeding the available position quantity. Bracket orders address both of these issues, as Alpaca’s system recognizes the entry and exit orders as a group and queues them for execution appropriately.”
Is there any way around this, or am I just out of luck if I want to use QuantConnect for live trading? I like using QuantConnect very much and would like to stick with it, but I'm dismayed there doesn't seem to be a way to submit an actual bracket order.
Simulating stop and limit levels to liquidate my market order isn't an option for me because I'm using minute resolution.
Mia Alissi
Here's a direct illustration for you and 'Andrew' of why you’re running into this issue with Alpaca and QuantConnect when attempting simulated bracket orders:
Explanation:
OrderStatus.Invalid), even in backtest/live logs, due to Alpaca internal constraints.Result:
No workaround exists using only the QuantConnect Alpaca integration unless they add native bracket support. Code-simulated OCO works only if you use high-frequency (second/subsecond) data, which you cannot do at minute resolution without execution risk.
Alternatives:
Let me know if you need guidance on any of these workarounds or possible brokerage alternatives!
Sources: Other Order Types - QuantConnect.com, Order Tickets - QuantConnect.com, Stop Limit Order Regression Algorithm, Combo Order Ticket Demo Algorithm, Alpaca - QuantConnect.com
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.
Andrew
This is very disappointing. Having no support for something as basic as bracket orders to set both a stop loss and a take profit is such a letdown.
I've spent a good amount of time writing this algorithm so I can take advantage of everything QuantConnect has to offer, including the ability to switch brokers easily should the need ever arise. It's been great to work with, has very good documentation and good support, but everything I've read says true bracket/OCO orders are not yet a part of QuantConnect. Because of that, I believe I would run into the same issue if I tried to use IB. Additionally, my strategy is not high frequency, so Alpaca's “no commission” model works very well for me.
It seems my only option is to build something from scratch using Alpaca's API. Do any folks at QuantConnect have any feedback or suggestions? What is the timeline for adding bracket orders to QuantConnect? How do I submit a feature request?
Alexandre Catarino
Hi Andrew,
Please vote for the feature request:
[Feature Request] Support for Bracket Order #8253
so that it makes it to the roadmap .
Best regards,
Alex
Andrew
Alexandre Catarino,
Thank you for your reply! I have added a vote to the Feature Request. Do you have any idea when the feature might be added?
Do you know if there is a workaround solution for the issue I'm running into, or is Mia's assessment correct that a workaround does not exist? Just wanting to make sure I'm not missing anything before I start working on rebuilding from scratch.
Andrew
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!