NeoCharts
Trading

OCO Orders

Stop-loss + target bracket pairs, and adjusting a position via the option chain.

Stop-loss + target pairs — SL and TP legs that cancel each other once one fires.

hasOCO

Whether the broker supports OCO (One Cancels Other) orders. false disables target/take-profit order placement entirely — everything on this page becomes unreachable from the chart's own UI.

bool get hasOCO => true;

placeOCOOrder / modifyOCOOrder / cancelOCOOrder

void placeOCOOrder(String params);
void modifyOCOOrder(String params);
void cancelOCOOrder(String groupId);
void groupAdjustOrders(String params);

placeOCOOrder/modifyOCOOrder params:

{
  "side": "buy", "productType": "normal", "stopPrice": 2350.0, "stopQty": 10,
  "symID": "RELIANCE", "targetPrice": 2450.0, "targetQty": 10,
  "targetTriggerPrice": 2440.0, "groupId": "OCO001"
}
FieldTypeAccepted values
sideStringrequired; "buy" / "sell", case-insensitive
productTypeStringrequired; "normal" or "intraday" — top-level, not nested per leg; both legs of one pair always protect the same position
stopPricedoublerequired; stop-loss leg price
stopQtyintrequired; stop-loss leg quantity
symIDStringrequired; the symbol
targetPricedoublerequired; target leg price
targetQtyintrequired; target leg quantity
targetTriggerPricedoublerequired; target leg trigger price
groupIdStringoptional on placeOCOOrder; required on modifyOCOOrder

cancelOCOOrder's groupId is the plain string, no leg data needed.

groupAdjustOrders params — simultaneously exit held legs and add new ones from the option chain:

{
  "exit": [
    { "action": "Buy", "id": "NIFTY2560023000PE", "ordType": "market", "price": 120.5, "quantity": 50 }
  ],
  "add": [
    { "action": "Sell", "id": "NIFTY2560024000CE", "ordType": "limit", "price": 85.0, "quantity": 50 }
  ]
}
FieldTypeAccepted values
exit[].action / add[].actionStringrequired; "Buy" / "Sell"
exit[].ordType / add[].ordTypeStringrequired; "market" / "limit" — a smaller set than placeOrder's orderType, no stop variants
idStringrequired; the option contract's symbol id
pricedoublerequired; leg price
quantityintrequired; leg quantity

exit — exit legs for currently-held positions (action inverted from the position side, e.g. a long position exits with "Sell"). add — new entry legs selected from the option chain.

ocoOrdersStreamer

Pending trigger pairs only — SL+TP legs not yet real orders. Once a leg fires, the broker reports it on ordersStreamer instead, as a plain order.

Stream<String> get ocoOrdersStreamer;

Must be a broadcast stream.

[
  {
    "groupId": "OCO001", "symID": "RELIANCE", "name": "Reliance Industries",
    "exchange": "NSE",   "side": "sell",       "productType": "normal",
    "stopLoss": { "type": "stoploss", "side": "sell", "triggerPrice": 2350.0, "qty": 10, "price": 2340.0, "fillQty": 0 },
    "target":   { "type": "limit",    "side": "sell", "triggerPrice": 0.0,    "qty": 10, "price": 2450.0, "fillQty": 0 }
  }
]
FieldTypeAccepted values
groupIdStringrequired; the pair's own identifier
symIDStringrequired; the symbol
nameStringoptional; display name — note the key is name, not displayName; falls back to symID if omitted
exchangeStringrequired; exchange identifier
sideStringrequired; "buy" / "sell", case-insensitive
productTypeStringrequired; "normal" or "intraday" — top-level, shared by both legs
stopLoss / targetobjectrequired; one OCOLeg each (see below) — both always populated; there's no unpaired form

OCOLeg shape (used for both stopLoss and target):

FieldTypeAccepted values
typeStringrequired; "stoploss" or "limit" — lowercase, same values as Orders' type/orderType
sideStringrequired; "buy" / "sell"
triggerPricedoublerequired; leg trigger price
qtyintrequired; leg quantity
pricedoublerequired; leg price
fillQtyintrequired; quantity filled so far, 0 if none

On this page