@RED 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"
As mentioned by @RA7526, I check order history only when price comes near to my stoploss.
consider the following scenario: > Placed CO order @100 SL @95 > 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.
@RA7526 has explained better than me. I don't have any code samples at present and sorry if explanation is bad.
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 https://kite.trade/docs/connect/v3/postbacks/
Hi @prat, 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.
No shortcuts to find this.
Other ways to use: .orders() or .trades() functions to cross-check trade execution.
order_status=history[-1]["status"]
if order_status=="COMPLETE":
......
elif order_status == "TRIGGER PENDING":
.....
elif order_status == "REJECTED":
....
consider the following scenario:
> Placed CO order @100 SL @95
> 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.
@RA7526 has explained better than me. I don't have any code samples at present and sorry if explanation is bad.
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
https://kite.trade/docs/connect/v3/postbacks/