Margin Account New OTO (TRADE)
API Description
Post a new OTO order for margin account:
- An OTO (One-Triggers-the-Other) is an order list comprised of 2 orders.
- The first order is called the working order and must be
LIMITorLIMIT_MAKER. Initially, only the working order goes on the order book. - The second order is called the pending order. It can be any order type except for
MARKETorders using parameterquoteOrderQty. The pending order is only placed on the order book when the working order gets fully filled. - If either the working order or the pending order is cancelled individually, the other order in the order list will also be canceled or expired.
- When the order list is placed, if the working order gets immediately fully filled, the placement response will show the working order as
FILLEDbut the pending order will still appear asPENDING_NEW. You need to query the status of the pending order again to see its updated status. - OTOs add 2 orders to the unfilled order count,
EXCHANGE_MAX_NUM_ORDERSfilter andMAX_NUM_ORDERSfilter.
HTTP Request
POST /sapi/v1/margin/order/oto
Request Weight
6(UID)
Request Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| isIsolated | STRING | NO | for isolated margin or not, "TRUE", "FALSE",default "FALSE" |
| listClientOrderId | STRING | NO | Arbitrary unique ID among open order lists. Automatically generated if not sent. A new order list with the same listClientOrderId is accepted only when the previous one is filled or completely expired. listClientOrderId is distinct from the workingClientOrderId and the pendingClientOrderId. |
| newOrderRespType | ENUM | NO | Set the response JSON. ACK, RESULT, or FULL; MARKET and LIMIT order types default to FULL, all other orders default to ACK. |
| sideEffectType | ENUM | NO | NO_SIDE_EFFECT, MARGIN_BUY. More info in FAQ |
| selfTradePreventionMode | ENUM | NO | The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE |
| autoRepayAtCancel | BOOLEAN | NO | Only when MARGIN_BUY order takes effect, true means that the debt generated by the order needs to be repay after the order is cancelled. The default is true |
| workingType | ENUM | YES | Supported values: LIMIT,LIMIT_MAKER |
| workingSide | ENUM | YES | BUY, SELL |
| workingClientOrderId | STRING | NO | Arbitrary unique ID among open orders for the working order. Automatically generated if not sent. |
| workingPrice | DECIMAL | YES | |
| workingQuantity | DECIMAL | YES | Sets the quantity for the working order. |
| workingIcebergQty | DECIMAL | YES | This can only be used if workingTimeInForce is GTC. |
| workingTimeInForce | ENUM | NO | GTC,IOC,FOK |
| pendingType | ENUM | YES | Supported values: Order Types Note that MARKET orders using quoteOrderQty are not supported. |
| pendingSide | ENUM | YES | BUY, SELL |
| pendingClientOrderId | STRING | NO | Arbitrary unique ID among open orders for the pending order. Automatically generated if not sent. |
| pendingPrice | DECIMAL | NO | |
| pendingStopPrice | DECIMAL | NO | |
| pendingTrailingDelta | DECIMAL | NO | |
| pendingQuantity | DECIMAL | YES | Sets the quantity for the pending order. |
| pendingIcebergQty | DECIMAL | NO | This can only be used if pendingTimeInForce is GTC. |
| pendingTimeInForce | ENUM | NO | GTC,IOC,FOK |
-
autoRepayAtCancel is suggested to set as “FALSE” to keep liability unrepaid under high frequent new order/cancel order execution
-
Depending on the
pendingTypeorworkingType, some optional parameters will become mandatory:Type Additional mandatory parameters Additional information workingType=LIMITworkingTimeInForcependingType=LIMITpendingPrice,pendingTimeInForcependingType=STOP_LOSSorTAKE_PROFITpendingStopPriceand/orpendingTrailingDeltapendingType=STOP_LOSS_LIMITorTAKE_PROFIT_LIMITpendingPrice,pendingStopPriceand/orpendingTrailingDelta,pendingTimeInForce
Response Example
Response Example:
{
"orderListId": 13551,
"contingencyType": "OTO",
"listStatusType": "EXEC_STARTED",
"listOrderStatus": "EXECUTING",
"listClientOrderId": "JDuOrsu0Ge8GTyvx8J7VTD",
"transactionTime": 1725521998054,
"symbol": "BTCUSDT",
"isIsolated": false,
"orders": [
{
"symbol": "BTCUSDT",
"orderId": 29896699,
"clientOrderId": "y8RB6tQEMuHUXybqbtzTxk"
},
{
"symbol": "BTCUSDT",
"orderId": 29896700,
"clientOrderId": "dKQEdh5HhXb7Lpp85jz1dQ"
}
],
"orderReports": [
{
"symbol": "BTCUSDT",
"orderId": 29896699,
"orderListId": 13551,
"clientOrderId": "y8RB6tQEMuHUXybqbtzTxk",
"transactTime": 1725521998054,
"price": "80000.00000000",
"origQty": "0.02000000",
"executedQty": "0",
"cummulativeQuoteQty": "0",
"status": "NEW",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "SELL",
"selfTradePreventionMode": "NONE"
},
{
"symbol": "BTCUSDT",
"orderId": 29896700,
"orderListId": 13551,
"clientOrderId": "dKQEdh5HhXb7Lpp85jz1dQ",
"transactTime": 1725521998054,
"price": "50000.00000000",
"origQty": "0.02000000",
"executedQty": "0",
"cummulativeQuoteQty": "0",
"status": "PENDING_NEW",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"selfTradePreventionMode": "NONE"
}
]
}