Back

Know when stop order or stop limit order has triggered?

Hello, is there any way I can tell via order status change or property/method on OrderTicket that a stop (or stop limit) order has "triggered" (market price reached the stop price)? Obviously, PartiallyFilled implicitly tells me this, but especially for stop limit orders that's insufficient since the order might not even get any fill due to limit being too tight!

Update Backtest








Specifically that the stop has been reached -- no, there's no way to know. Even if the stop price is reached if you're not first in line in the order book you won't neccessarily be filled first. Really its probably best to monitor for the fills in the order event handler:

public override void OnOrderEvent(OrderEvent orderEvent)
{
var order = Transactions.GetOrderById(orderEvent.OrderId);
}

 

1

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.


Inside OnOrderEvent you can check to see if you are invested in the security that just filled. If not, then that means the whole stop order just filled.

if (fill.Status.ToString() == "Filled" && !Securities[fill.Symbol].Invested){...}

 

1

Personally I handle my orders' workflow manually because I need to make sure that the orders are going to happen exactly (or near exactly) as I want them to be. I keep a "status" variable in my algo for every order that I place. Then I keep tracking them through OnOrderEvent. I also tag all the orders carefully to be able to track/debug them. It's a painful and tedious job but now that it's done, I think it was worth the time.

1

Update Backtest





0

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.


Loading...

This discussion is closed