Skip to main content

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 LIMIT or LIMIT_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 MARKET orders using parameter quoteOrderQty. 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 FILLED but the pending order will still appear as PENDING_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_ORDERS filter and MAX_NUM_ORDERS filter.

HTTP Request

POST /sapi/v1/margin/order/oto

Request Weight

6(UID)

Request Parameters

NameTypeMandatoryDescription
symbolSTRINGYES
isIsolatedSTRINGNOfor isolated margin or not, "TRUE", "FALSE",default "FALSE"
listClientOrderIdSTRINGNOArbitrary 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.
newOrderRespTypeENUMNOSet the response JSON. ACK, RESULT, or FULL; MARKET and LIMIT order types default to FULL, all other orders default to ACK.
sideEffectTypeENUMNONO_SIDE_EFFECT, MARGIN_BUY. More info in FAQ
selfTradePreventionModeENUMNOThe allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE
autoRepayAtCancelBOOLEANNOOnly 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
workingTypeENUMYESSupported values: LIMIT,LIMIT_MAKER
workingSideENUMYESBUY, SELL
workingClientOrderIdSTRINGNOArbitrary unique ID among open orders for the working order. Automatically generated if not sent.
workingPriceDECIMALYES
workingQuantityDECIMALYESSets the quantity for the working order.
workingIcebergQtyDECIMALYESThis can only be used if workingTimeInForce is GTC.
workingTimeInForceENUMNOGTC,IOC,FOK
pendingTypeENUMYESSupported values: Order Types Note that MARKET orders using quoteOrderQty are not supported.
pendingSideENUMYESBUY, SELL
pendingClientOrderIdSTRINGNOArbitrary unique ID among open orders for the pending order. Automatically generated if not sent.
pendingPriceDECIMALNO
pendingStopPriceDECIMALNO
pendingTrailingDeltaDECIMALNO
pendingQuantityDECIMALYESSets the quantity for the pending order.
pendingIcebergQtyDECIMALNOThis can only be used if pendingTimeInForce is GTC.
pendingTimeInForceENUMNOGTC,IOC,FOK
  • autoRepayAtCancel is suggested to set as “FALSE” to keep liability unrepaid under high frequent new order/cancel order execution

  • Depending on the pendingType or workingType, some optional parameters will become mandatory:

    TypeAdditional mandatory parametersAdditional information
    workingType = LIMITworkingTimeInForce
    pendingType = LIMITpendingPrice, pendingTimeInForce
    pendingType = STOP_LOSS or TAKE_PROFITpendingStopPrice and/or pendingTrailingDelta
    pendingType = STOP_LOSS_LIMIT or TAKE_PROFIT_LIMITpendingPrice, pendingStopPrice and/or pendingTrailingDelta, 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"
}
]
}