Margin Account New Order (TRADE)
API Description
Post a new order for margin account.
HTTP Request
POST /sapi/v1/margin/order
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" |
side | ENUM | YES | BUY SELL |
type | ENUM | YES | |
quantity | DECIMAL | NO | |
quoteOrderQty | DECIMAL | NO | |
price | DECIMAL | NO | |
stopPrice | DECIMAL | NO | Used with STOP_LOSS , STOP_LOSS_LIMIT , TAKE_PROFIT , and TAKE_PROFIT_LIMIT orders. |
newClientOrderId | STRING | NO | A unique id among open orders. Automatically generated if not sent. |
icebergQty | DECIMAL | NO | Used with LIMIT , STOP_LOSS_LIMIT , and TAKE_PROFIT_LIMIT to create an iceberg order. |
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, AUTO_REPAY,AUTO_BORROW_REPAY; default NO_SIDE_EFFECT. More info in FAQ |
timeInForce | ENUM | NO | GTC,IOC,FOK |
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 or AUTO_BORROW_REPAY 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 |
recvWindow | LONG | NO | The value cannot be greater than 60000 |
timestamp | LONG | YES |
- autoRepayAtCancel is suggested to set as “FALSE” to keep liability unrepaid under high frequent new order/cancel order execution
Response Example
Response ACK:
{
"symbol": "BTCUSDT",
"orderId": 28,
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"isIsolated": true, // if isolated margin
"transactTime": 1507725176595
}
Response RESULT:
{
"symbol": "BTCUSDT",
"orderId": 26769564559,
"clientOrderId": "E156O3KP4gOif65bjuUK5V",
"transactTime": 1713873075893,
"price": "0",
"origQty": "0.001",
"executedQty": "0.001",
"cummulativeQuoteQty": "65982.53",
"status": "FILLED",
"timeInForce": "GTC",
"type": "MARKET",
"side": "SELL",
"isIsolated": false, // if isolated margin
"selfTradePreventionMode": "EXPIRE_MAKER"
}
Response FULL:
{
"symbol": "BTCUSDT",
"orderId": 26769564559,
"clientOrderId": "E156O3KP4gOif65bjuUK5V",
"transactTime": 1713873075893,
"price": "0",
"origQty": "0.001",
"executedQty": "0.001",
"cummulativeQuoteQty": "65.98253",
"status": "FILLED",
"timeInForce": "GTC",
"type": "MARKET",
"side": "SELL",
"marginBuyBorrowAmount": 5, // will not return if no margin trade happens
"marginBuyBorrowAsset": "BTC", // will not return if no margin trade happens
"isIsolated": true, // if isolated margin
"selfTradePreventionMode": "NONE",
"fills": [
{
"price": "65982.53",
"qty": "0.001",
"commission": "0.06598253",
"commissionAsset": "USDT",
"tradeId": 3570680726
}
],
"isIsolated": false,
"selfTradePreventionMode": "EXPIRE_MAKER"
}
Error Code Description:
-
ASSET_BAN_TRADE
This error {“code”: -3067, “msg”: “This asset is currently not a supported margin asset, please try another asset.”} indicates that the asset is currently restricted. This restriction can be due to various reasons, such as the asset may be subject to regulatory restrictions that prevent it from being borrowed, etc.
You can verify if there are any announcements or updates regarding the asset's borrowing status on Binance's official channels.
-
NOT_VALID_MARGIN_ASSET
This error {“code”: -3027, “msg”: “Not a valid margin asset.”} occurs when a user requests an asset that is either delisted or is not supported on the margin product. Users can check the margin symbol info (GET /sapi/v1/margin/allAssets) to find all supported margin assets before trading.
-
BALANCE_NOT_CLEARED
This error {“code”: -3041, “msg”: “Balance is not enough.”} indicates that your account balance is insufficient to complete the requested transaction.
-
TOO_MANY_ORDERS
This error {“code”: -1015, “msg”: “Too many new orders; current limit is %s orders per %s.”} means that you have reached the limit for the number of orders you can place within a certain timeframe. To address this issue:
- Review Open Orders: Check your current open orders and consider canceling any unnecessary ones to free up capacity.
- Space Out Orders: If possible, space out your order placements to prevent hitting the limit.
-
Filter failure: NOTIONAL
This error {“code”:-20204, “msg”: “Filter failure: NOTIONAL.”} occurs when your request is blocked before reaching the Matching Engine, often due to the order value not meeting the minimum notional value requirement. By carefully reviewing your order request, you can identify and correct the issues causing the request rejection.
-
NOT_VALID_MARGIN_PAIR
This error {“code”: -3028, “msg”: “Not a valid margin pair.”} occurs when a user requests an asset that is either delisted or is not supported on the margin product. Users can check the margin symbol info (GET /sapi/v1/margin/allAssets) to find all supported margin assets before trading.
-
NEW_ORDER_REJECTED
This error {“code”: -2010, “msg”: “NEW_ORDER_REJECTED”} often occurs for two reasons:
- When a limit order is placed at a price that would immediately execute as a market order. You can adjust your limit order price to ensure it does not match the current market price if you intend to avoid taker fees.
- Your account does not have enough funds to cover the order. You can resolve this by transferring additional funds if necessary or reduce the order size to fit your available balance.
-
EXCEED_PRICE_LIMIT
This error {“code”: -3064, “msg”: “Limit price needs to be within (-15%,15%) of current index price for this margin trading pair.”} often occurs when the limit price is not allowed. For certain low liquidity pairs or stablecoin to stablecoin pairs on Margin (e.g. USDT/DAI), there will be a price bracket of [-15%, 15%] (which is subject to changes).
That is, when a BUY Margin order’s limit price is more than 15% higher than the current index price or a SELL Margin order’s limit price is more than 15% lower than the current index price, it will trigger this error message.