Getting the reason for REJECTED

ramatius
Hi, Is there any way to get the reason for REJECTED order through API? One of the BOs placed today (MARUTI qty 8) spawned two legs (qty 7 and 1) and one of the legs got rejected. Since the order was created by the system (not by an API call), the status is not retrievable via an API.

The API documentation doesn't seem to contain any API to get the reason for REJECTED orders. Pls let me know if it is there.
  • sujith
    Can you post the order id here? We will check and get back to you.
  • ramatius
    Thanks @sujith The orders are,
    MARUTI - 181010000192469
    JSWSTEEL - 181010000469438
  • sujith
    Can you private message the client id as well?
    Couldn't find order from your default account.
  • sujith
    You can check out the status_message field of the response. It says "BO: Self Trade Rejection". This is because, at that point in time, the same user was buyer and seller which is why the order was rejected.
    Both the orders are rejected with the same reason.
  • ramatius
    @sujith all these orders were created by Zerodha. Only the parent order (qty 8) was sent by user through API. If the order legs are going to cause problems, why should zerodha put out those orders in the first place?

    More importantly, what should be done from our side to avoid this situation? Pls note that Self Trade is a serious rule violation.

    Pls advise.

    Thanks for the pointer on status_message. Will look at that.
  • sujith
    sujith edited October 2018
    It is not a bug from the system's end. It will just place an order with whatever input user gives. If your stop-loss and target are nearby it can happen.
    Even though you have enough difference between target and stop-loss during volatile markets it might not be enough.
    You need to take care in such a way that your entry order doesn't become a match for your own target or stop-loss order.
  • ramatius
    @sujith The parent order had sufficient difference. When the order was split up into 7 and 1 by zerodha, the same differences should've been maintained by your system, irrespective of volatility (because the difference is set after taking into account the actual buy price). Please note that qty 7 went through fine, but qty 1 threw this error.

    So I am not sure what else can be done from the user's side to mitigate this problem. It would be great if you can give an example and explain.
  • Matti
    @ramatius What do you mean when 'Zerodha placed the order' or 'the order was split up by Zerodha'? The behaviour of bracket orders is well known. Based on the available bids/offers in the markets. When you place the entry order, you are instructing the system to place the exit orders as well. If the markets are volatile, it's possible that even though the entry and exit are quite far apart, they could result in a self-trade and so be rejected by the exchange. There's nothing one can do in such cases.
  • Matti
    Matti edited October 2018
    To add, @ramatius, the rejection is done by the exchange. Details here.
  • ramatius
    @Nikhil.A To give an example,
    (1) User sends a buy BO for SYM trading at Rs.100, with SL -2, TP +2, (i.e. SL 98, TP 102)
    (2) Zerodha sees that there are two offers with qty 7 and qty 1, at prices 101 and 102
    (3) Zerodha completes the buy trade for both
    (4) simultaneously it places 4 SL/TP orders - SL/TP for qty 7 (at 99/103) and SL/TP for qty 1 (at 100/104)
    (5) somehow due to price movements qty 7 legs get completed, but qty 1 legs cause "Self trade" error

    Except step (1), all other steps are initiated & executed by Zerodha. That is what I meant by "the order was split up by Zerodha". Hope this clarifies.

    Please note that there is no way the user can control steps (2) to (5) - everything is under Zerodha's control. So if an error arise in those steps, how can the user react/control the situation?
  • Matti
    @ramatius like I've said previously, none of this is 'controlled' by Zerodha. What you need to understand is that the BO product is essentially an algo built by Thomson Reuters and approved by the exchanges. If you wish to have complete control of the order (BO is meant to behave like this so the user can fire and forget, but these are the drawbacks) you can simply simulate a BO on your end by placing multiple orders for entry, Sl and target. While you won't receive the margin benefit of a BO, you will have more control.
Sign In or Register to comment.