May I know how to handle OCO orders using python in Zerodha

Vishnuvardhan
Let's say i placed 2 orders Target and Stop Loss. If one order is executed, then other order should cancel automatically.
Is there any function available in Zerodha for this ?
If not, can you please tell, how to handle this ?
Tagged:
  • sujith
    You can use GTT for this. You can know more about it here and check out the example here.
  • Vishnuvardhan
    Thanks @sujith
    Have one last doubt. in the below code, function is expecting Ltp of the trading symbol.

    gtt_oco = kite.place_gtt(trigger_type=kite.GTT_TYPE_OCO, tradingsymbol="SBIN", exchange="NSE", trigger_values=[470,480], last_price=473, orders=order_oco)

    Do I need to fetch externally using Ltp function and pass or is it optional parameter ?
  • sujith
    LTP is a must field. It is used by the backend to determine the direction. You may use LTP method or Quote API or Websocket API.
This discussion has been closed.