Trade atomicity / bracket order functionality

ketansp
Zerodha used to have a feature called as bracket order where you could send 3 legs of a trade (entry, profit exit and stoploss exit) in the same order. For certain reasons, which I completely agree with from a risk standpoint, Zerodha chose to deprecate this feature.

In an ideal world, exchanges should implement this feature but thats a long shot. In meanwhile, now that Zerodha has deprecated this, the onus to manage these three legs of a trade, fall on trader, which is even further away from exchange. I am not sure if the postbacks over websockets protocol is robust enough for traders like myself to handle it our end.

What can I do, in my capacity as consumer of Zerodha APIs, to make this piece absolutely foolproof? I am doubtful if ALL order update events are sent over websocket postbacks. Additionally, if there is drop in connectivity, there is no way to even know that some events have been missed. Any suggestions about how can I maintain atomicity of entry, profit exit and stoploss exit legs at my end. Curious to know how others have handled this.
  • sujith
    You place an order and wait for order updates on Websocket API. If you get disconnected or reconnected then fetch orderbook and check for the latest status of the order.
    On order update, you can place OCO GTT for exit and keep modifying the required GTT for trailing stoploss.
  • sujith
    Please note that one can only modify an order 25 times.
  • ketansp
    Will check
Sign In or Register to comment.