It looks like you're new here. If you want to get involved, click one of these buttons!
.Net API client
.Net / VBA / Excel (3rd party)
Algorithms and Strategies
Mobile and Desktop apps
Market data (WebSockets)
In this Discussion
What is the ideal way to check if stoploss of an order has been hit and the order is no longer valid
other than polling every n seconds for order status?
Use orderhistory() function to get the status of your order time to time. Besides, keep monitoring the price with your local Buy/Sell.
No shortcuts to find this.
Other ways to use: .orders() or .trades() functions to cross-check trade execution.
That's what I currently do. I don't know the order status changes when stoploss gets hit, though. For cover orders or bracket orders, I can check status of second leg. Can you elaborate on what I should check for SL, SL-M orders?
check last element in history. get status field in that. if sl has not hit then status will be "TRIGGER PENDING". if it got executed it will be "COMPLETE"
elif order_status == "TRIGGER PENDING":
elif order_status == "REJECTED":
As mentioned by
, I check order history only when price comes near to my stoploss.
consider the following scenario:
> Placed CO order
> From web socket data I check the price if it is coming near to SL(<96) then start checking kite.order_history(order_id) for order status.
has explained better than me. I don't have any code samples at present and sorry if explanation is bad.
edited April 2020
in my opinion,rather than polling the order-status every n seconds a better approach would be setup a Web-hook and only fetch the order book when there is a event published in the web-hook,
or check for any string message in the web-socket stream and only react to messages that are order updates.
You can check the docs here
Thanks a ton, guys. That was helpful.
, There is a 1% probability where RMS system doesn't update your order status(ie; postbacks aren't received). So if an order is placed and it isn't updated during postback checks, you ought to miss the trade status. There are many cases reported in the API on this issue.