Skip to Content

GTT OCO Order

This API allows you to place a one-cancels-other (OCO) GTT order with two legs, where the first leg to trigger cancels the other.

USE CASE

Set a target and a stop-loss together on a position you hold, so whichever triggers first cancels the other.

Details

  • This type allows you to place both a Stop Loss and a Target order simultaneously. If one order is triggered, the other gets automatically canceled.
  • To avoid rejections:
  • For Leg1: The trigger price must always be greater than the LTP
  • For Leg 2: The trigger price must always be less than the LTP
  • Each leg can be a Limit or Market order through type, and the two legs can use different order types. For Market orders, the order is sent at the market price once the trigger price is hit, so the executed price can differ from the trigger price.
  • Market orders are not allowed for BFO symbols. Such requests are rejected with code -50.
  • It uses the same endpoint as a single GTT. Sending both leg1 and leg2 makes the order an OCO.
  • Each leg carries its own type, price, triggerPrice and qty. The two legs can use different order types: 1 for Limit (the default) and 2 for Market.
  • For a Market leg, send price as 0 or leave it out.
  • Product type can be CNC, MARGIN or MTF. The order stays active for up to one year unless a leg triggers or you cancel it.
  • Response code 1101 means the order was placed. Code 201 means it is in transit, so confirm it in the GTT Order Book.
  • In the GTT Order Book an OCO order shows gtt_oco_ind as 2, and the second leg appears in price2_limit, price2_trigger, qty2 and ord_type2.
  • Rate limits differ between the Standard and Prime plans. See Plans & rate limits.

Request Attributes

AttributeData TypeDescription
SideintIndicates the side of the order: 1 for buy, -1 for sell.
symbol*stringThe instrument's unique identifier, e.g., "NSE:CHOLAFIN-EQ"
productType*stringThe product type for the order. Valid values: "CNC", "MARGIN", "MTF".
orderInfo*objectContains information about the GTT/OCO order legs.
orderInfo.leg1*objectDetails for GTT order leg. Mandatory for all orders.
orderInfo.leg1.price*floatPrice at which the order should be placed. Required for Limit. For Market, send 0 or leave it out.
orderInfo.leg1.triggerPricefloat
  • Trigger price for the GTT order.
  • NOTE: for OCO order this leg trigger price should be always above LTP
orderInfo.leg1.qty*intQuantity for the GTT order leg.
orderInfo.leg1.typeint
  • Order type for this leg:
  • 1: Limit (default if not provided).
  • 2: Market.
orderInfo.leg2*objectDetails for OCO order leg. Optional and included only for OCO orders.
orderInfo.leg2.price*floatPrice at which the second leg of the OCO order should be placed. Required for Limit. For Market, send 0 or leave it out.
orderInfo.leg2.triggerPrice*float
  • Trigger price for the second leg of the OCO order.
  • NOTE: for OCO order this leg trigger price should be always below LTP
orderInfo.leg2.qty*intQuantity for the second leg of the OCO order..
orderInfo.leg2.typeint
  • Order type for this leg:
  • 1: Limit (default if not provided).
  • 2: Market. The two legs can use different order types.

Response Attributes

AttributeData TypeDescription
codeint
  • Status code indicating the outcome of the request:
  • 1101: Order placed successfully.
  • 201: Order is in transit. Confirm details using the Orderbook API.
  • Other codes represent specific error conditions.
message*stringDescriptive message about the request status, e.g., "Successfully placed order".
s*stringRequest status indicator: "ok" for success, "error" for failure.
id*stringUnique identifier for the placed order, returned when the order is successfully processed.
Last updated on