Interleaving orders

Maybe this is a basic question, but I haven't been needing to get down into the gritty details of order execution until now as I'm trying to make an intraday algo production ready.

Let's say that I want several orders at once. Two scenarios I can think of:

- Multiple orders to exit a position: A stop market (or stop limit) order as a hard condition stoploss, plus a limit order to try to sell for a profit. If both are issued at once, what happens if the latter is partially filled and then the stoploss triggers?

- An order to enter a position plus a stoploss order to protect the quantity filled so far. Aside from "would this work", it's also a question of what happens when latency enters the equation. Creating a new order after another has been submitted isn't atomic of course.

Any comments or samples illustration such issues would be welcome.

Update Backtest

Update Backtest


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.


This discussion is closed