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?
  • RED
    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.
  • anonymous
    @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?
  • RA7526
    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"
  • RA7526

    if order_status=="COMPLETE":
    elif order_status == "TRIGGER PENDING":
    elif order_status == "REJECTED":

  • RED
    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.
  • prat
    prat 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
  • anonymous
    @RA7526 @RED @prat Thanks a ton, guys. That was helpful.
  • RED
    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.
Sign In or Register to comment.