A standalone OCO (one-cancels-the-other) is a take-profit and a stop-loss over a quantity the account
already holds, created in one request. Both legs trade the same Pair, side, and quantity, and share
one reserve. When one leg's exit order has traded the whole quantity, the other leg is canceled with
cancel reason OCO.
Create one with CreateOco (POST /v1/triggers/oco) and cancel it with CancelOco (DELETE /v1/triggers/oco/{orderListId}).
The trade WebSocket takes the same requests; see Trade WebSocket.
Standalone OCO and attached legs
Attached take-profit and stop-loss legs belong to an order: they arm as it fills and protect what it filled. A standalone OCO has no parent order. It protects a balance already in the account, from the moment it is created:
- Both legs are
RUNNINGfrom the create, over the full quantity. - Its reserve is created at once and in full, not as fills settle.
- The legs are always linked as OCO. There is no
ocoswitch. - The legs carry
order_list_id, and noparent_order_id.
The legs otherwise follow the attached-leg rules for firing, switching, and ending.
Request
CreateOcoRequest carries an optional subaccount_id and one oco (OcoIntent):
Each OcoLeg has:
trigger_price_ticks(RESTtriggerPrice)
Required, positive, and on the Pair's tick size.child
Required:market_ioc, an empty object, orlimit_gtcwithprice_ticks(RESTprice), a resting limit exit. Post-only is not supported.trigger_price_source
Optional:LAST_PRICE(default) orINDEX_PRICE.
There is no fee asset field: each exit pays its fee in the quote Asset. Neither the quantity nor the side can change later; cancel the OCO and create a new one.
Trigger prices
Each leg compares its trigger price with the price its own trigger_price_source names. See The price a trigger watches.
- A take-profit at or past the stop-loss, at or below it for a
SELLor at or above it for aBUY, is refused withTRIGGER_PRICE_INVALIDand a violation onoco.take_profit.trigger_price_ticks(RESToco.takeProfit.triggerPrice). Nothing is created. - A leg whose trigger price the watched price has already reached is checked after the create is
acknowledged. Both legs then end
FAILEDwithTRIGGER_WOULD_TRIGGER_IMMEDIATELY, the reserve is released, and nothing is placed. Read the legs after a create to confirm they areRUNNING. - On a Pair without an index price, an OCO with an
INDEX_PRICEleg fails the same way, withINDEX_PRICE_UNAVAILABLEon both legs.
Funds reserved at creation
An OCO reserves funds once, for both legs, so the quantity can be sold or bought only once. A create
that the available balance cannot cover is rejected with INSUFFICIENT_FUNDS, and nothing is held.
SELL
The quantity, in the base Asset.BUY
The larger of the two legs' costs, in the quote Asset. A leg costs its maximum price times the quantity, plus the fee at the Pair'sreserveFeeRatePercent. A limit exit's maximum is its limit price. A market exit's maximum is its trigger price raised by the Pair'sdefaultMarketSlippageBpsBuy, on the tick size.
For a BUY with market exits, the stop-loss usually sets the reserve, because its trigger price is
the higher one. See Size a buy that pays its fee in quote for the fee reserve rate.
While the OCO lives, orders and withdrawals that would use the reserved funds are rejected with INSUFFICIENT_FUNDS. Each fire moves its exit's share of the reserve to the exit order. What an exit
does not use comes back to the reserve, and the reserve is released when the last leg ends.
Slippage of a market exit
market_ioc takes no slippage cap. A market exit uses the Pair's default market slippage for the
OCO's side, defaultMarketSlippageBpsBuy or defaultMarketSlippageBpsSell from GetSpotConfig,
measured from the fire price. On a price gap past that bound, the exit fills partly or not at all.
See Market order price protection.
Pair minimums
A create whose exit could never pass the Pair's order limits at the full quantity is refused with
that check's code: MIN_QTY, QTY_STEP_SIZE, MIN_NOTIONAL, or MAX_NOTIONAL. Each exit is valued
where its fire would value it: a buy at its maximum price, a sell at its limit price, or a market sell
at its trigger price lowered by defaultMarketSlippageBpsSell.
Examples
A sell OCO over 0.5 BTC on BTC-USDT: a take-profit at 72,000 that rests a limit sell at 72,000, and a stop-loss at 60,000 that sells at market.
POST /v1/triggers/oco
{
"oco": {
"symbol": "BTC-USDT",
"side": "SELL",
"qty": "0.5",
"clientListId": "oco-btc-1",
"takeProfit": {
"triggerPrice": "72000",
"child": { "limitGtc": { "price": "72000" } }
},
"stopLoss": {
"triggerPrice": "60000",
"triggerPriceSource": "LAST_PRICE",
"child": { "marketIoc": {} }
}
}
}/triggers.v1.TriggersService/CreateOco. The example assumes BTC-USDT has Pair ID 1 and a base_quantity_scale of 8; read both from GetSpotConfig.
{
"oco": {
"symbolId": 1,
"side": "SELL",
"qtyScaled": "50000000",
"clientListId": "oco-btc-1",
"takeProfit": {
"triggerPriceTicks": "72000000000000",
"child": { "limitGtc": { "priceTicks": "72000000000000" } }
},
"stopLoss": {
"triggerPriceTicks": "60000000000000",
"triggerPriceSource": "LAST_PRICE",
"child": { "marketIoc": {} }
}
}
}The response names the OCO, orderListId, and each leg's trigger ID. Over REST:
{
"orderListId": "2NEpo7TZRRrLZSi2X",
"clientListId": "oco-btc-1",
"takeProfitTriggerId": "2NEpo7TZRRrLZSi2Y",
"stopLossTriggerId": "2NEpo7TZRRrLZSi2Z",
"acceptedAt": "2026-11-03T09:15:02.481Z",
"acceptedAtTsNs": "1793697302481000000"
}Buys 0.5 BTC at market if the price dips to 62,000 or breaks out to 70,000. If the Pair's defaultMarketSlippageBpsBuy is 500 (5%), the stop-loss sets the reserve: 70,000 × 1.05 × 0.5 =
36,750 USDT, plus the fee. The take-profit would need 32,550 USDT.
{
"oco": {
"symbol": "BTC-USDT",
"side": "BUY",
"qty": "0.5",
"clientListId": "oco-btc-buy-1",
"takeProfit": { "triggerPrice": "62000", "child": { "marketIoc": {} } },
"stopLoss": { "triggerPrice": "70000", "child": { "marketIoc": {} } }
}
}When a leg fires
The first leg whose trigger price is reached fires: it records EVENT_FIRED and places one exit
order for the OCO's remaining quantity, rounded down to the Pair's step size. Only one exit works at a
time. Follow the exit as an ordinary order through child_order_id.
- The exit trades the whole quantity: the leg whose exit traded last ends
COMPLETED, and the other endsCANCELEDwith cancel reasonOCO. The reserve is released. - The exit trades only part, for example a resting limit exit or a market exit on a thin book: both legs keep protecting the rest. If the other leg's trigger price is reached, it cancels the working exit, whose fills stand, and fires for what is left.
- An exit ends unfilled for another cause, such as the end of an IOC or self-trade prevention: the legs stay live and protect the rest.
Cancel
CancelOco takes the order_list_id from the create. Canceling either leg with CancelTrigger does the same. Either way, both legs end CANCELED with USER_REQUEST in one step, so no price
between two cancels can fire the other leg. A working exit is canceled with them, its fills
standing, and the reserve is released. The answer's status is CANCELED.
DELETE https://api.testnet.polyester.com/v1/triggers/oco/2NEpo7TZRRrLZSi2X?subaccountId=45LUmqjT- An
order_list_idthat names no OCO of the account, such as a trigger ID, is refused withTRIGGER_NOT_FOUND, and nothing is canceled. - An OCO that has already ended answers
TRIGGER_STATUS_INVALID.
Cancel all orders and the dead-man switch stop an OCO only with include_triggers set. Then each leg ends CANCELED with cancel reason CANCEL_ALL, a working exit
is canceled with the account's other orders, and the reserve is released.
Without include_triggers, they cancel orders only, so an OCO with no working exit is untouched.
When a leg has fired, they cancel its working exit order like any open order, and canceling that
exit ends both legs CANCELED with USER_REQUEST. A cancel of the exit with CancelOrder does the
same. Cancel-on-disconnect cancels orders only, never triggers. If it cancels an OCO's working exit, that ends the OCO as
above; an OCO with no working exit survives.
Modify
ModifyTrigger changes one leg's trigger_price_ticks:
- A price that would cross the other leg, including a price that the other leg's pending modify
asks for, is refused with
TRIGGER_PRICE_INVALID. - A price the watched price has already reached is refused with
TRIGGER_WOULD_TRIGGER_IMMEDIATELY. - While an exit works, the change is refused with
ATTACHED_EXIT_WORKING.
A limit exit's price cannot change. A refused modify changes nothing.
Reads and events
Each leg is an ordinary trigger of type TAKE_PROFIT or STOP_LOSS. Read it with GetTrigger and ListTriggers like any trigger; see Read triggers.
order_list_id(RESTorderListId)
The OCO both legs belong to. Empty for every other trigger.client_list_id(RESTclientListId)
The OCO's client ID, on both legs. A leg'sclient_trigger_idis empty.ListTriggersfiltersorder_list_idandclient_list_id(RESTorderListIdandclientListId) list both legs of one OCO.
Each leg records its own events on the trigger events channel: EVENT_ARMED when it is created, EVENT_FIRED with child_order_id for each exit it places, then EVENT_CANCELED with OCO, USER_REQUEST, or CANCEL_ALL, or EVENT_FAILED.
Create once, retry safely
client_list_id is unique per account and Pair among OCOs, separately from client trigger IDs.
- While a leg is live, and for 60 seconds after both legs ended, the same request with the same ID
answers the same OCO. The same ID with a different request is refused with
CONFLICT_DUPLICATE_CLIENT_TRIGGER_ID. TRIGGER_CREATE_OUTCOME_UNKNOWNmeans the create was not confirmed in time and may have succeeded. List the triggers withclient_list_idbefore retrying.
Limits and rate limits
There is no separate OCO limit: each leg counts as one trigger toward the account's trigger limits. An OCO uses
two of the 100 triggers allowed on one Pair, so at most 50 OCOs fit on a Pair with no other triggers.
A create that would pass a limit is refused with MARKET_TRIGGER_LIMIT_EXCEEDED or TRIGGER_LIMIT_EXCEEDED, and nothing is created.
See Rate limits.
Trade WebSocket
The protobuf trade WebSocket takes create_oco and cancel_oco in ClientFrame, with the CreateOcoRequest and CancelOcoRequest messages above, and answers with create_oco or cancel_oco in its acknowledgement. The SBE WebSocket has CreateOco and CancelOco,
both answered by OcoAck, which carries orderListId and, for a create, both legs' trigger IDs.
Refusals arrive as CommandReject with the codes below.
Errors
TRIGGER_PRICE_INVALID· HTTP 400
A leg's trigger price is not positive, the take-profit is not on the profit side of the stop-loss, or a modify would cross the other leg.PRICE_TICK_SIZE· HTTP 400
A trigger or limit price is not on the Pair's tick size.STP_MODE_NOT_ALLOWED· HTTP 400self_trade_prevention_modeisDECREMENT.TRIGGER_PRICE_SOURCE_UNSUPPORTED· HTTP 400
A leg namesMARK_PRICE.INSUFFICIENT_FUNDS· HTTP 400
The available balance cannot cover the reserve.MIN_QTY,QTY_STEP_SIZE,MIN_NOTIONAL,MAX_NOTIONAL· HTTP 400
An exit could never pass the Pair's order limits at the full quantity.TRIGGER_QTY_INVALID· HTTP 400
The quantity is not positive, or over REST a malformed or negativeqty. The violation namesoco.qty_scaled(RESToco.qty). The trade WebSocket answers the same code.BAD_PRICE· HTTP 400
A leg's limit price is not positive.CLIENT_LIST_ID_INVALID· 318 · HTTP 400
Theclient_list_idis empty, longer than 36 characters, or has a character other than an ASCII letter, digit,.,_,:,/or-. Every API answers this code, the trade WebSockets included; ConnectRPC withinvalid_argument. TheListTriggersclient_list_idfilter answers it too. Nothing changed.VALIDATION_ERROR· HTTP 400
A required field is missing, such as a leg'schild. ConnectRPC answersinvalid_argument, and the trade WebSocketBAD_REQUEST.CONFLICT_DUPLICATE_CLIENT_TRIGGER_ID· HTTP 409
Theclient_list_idnames another OCO. List triggers byclient_list_id, then use a new ID.MARKET_TRIGGER_LIMIT_EXCEEDED,TRIGGER_LIMIT_EXCEEDED· HTTP 429
The two legs would pass the account's trigger limits.RATE_LIMIT_EXCEEDED· HTTP 429
Retry after theRetry-Afterdelay.TRIGGER_CREATE_OUTCOME_UNKNOWN· HTTP 504
List triggers byclient_list_idbefore retrying the create.TRIGGER_NOT_FOUND· HTTP 404CancelOconamed an ID that is not an OCO of the account.TRIGGER_STATUS_INVALID· HTTP 400
The OCO has already ended. Treat the cancel as done.
TRIGGER_WOULD_TRIGGER_IMMEDIATELY and INDEX_PRICE_UNAVAILABLE on a create are not errors: they
are the legs' failure_reason after the create was acknowledged. See Error codes for every code and its ConnectRPC
status.