幣安槓桿為所有全倉和逐倉用戶提供四個不同的下單交易介面:
其中參數sideEffectType為訂單介面設定以下四種交易模式:
參數sideEffectType設定不同交易模式舉例:
用戶A持有 1 BTC 資產和 10,000 USDC負債,調用 POST /sapi/v1/margin/order 介面,設定sideEffectType為NO_SIDE_EFFECT。以價格 40,000 USDC下單賣出 1 BTC後,用戶持有40,000 USDC資產和10,000 USDC負債。接口呼叫參數和返回參數如下:
呼叫參數:
Parameter | Value |
symbol | BTCUSDC |
isIsolated | FALSE |
side | SELL |
type | Limit |
quantity | 1 |
quoteOrderQty | |
price | 40,000 |
stopPrice | |
newClientOrderId | |
icebergQty | |
newOrderRespType | |
sideEffectType | NO_SIDE_EFFECT |
timeInForce | GTC |
selfTradePreventionMode | NONE |
autoRepayAtCancel | |
recvWindow | |
timestamp | 1507725176595 |
返回參數:
{
"symbol": "BTCUSDC",
"orderId": 28,
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"transactTime": 1507725176595,
"price": "40000.00000000",
"origQty": "1.00000000",
"executedQty": "1.00000000",
"cummulativeQuoteQty": "1.00000000",
"status": "FILLED",
"timeInForce": "GTC",
"type": "Limit",
"side": "SELL",
"isIsolated": false, // 是否是逐倉symbol交易
"selfTradePreventionMode": "NONE",
"fills": [
{
"price": "40000.00000000",
"qty": "1.00000000",
"commission": "40.00000000",
"commissionAsset": "USDC"
}
]
}
用戶B持有 1 BTC資產和10,000 USDC負債,調用 POST /sapi/v1/margin/order 介面,設定sideEffectType為MARGIN_BUY。以價格40,000 USDT下單買入0.5 BTC後,系統自動借入20,000 USDC負債。最後用戶持有1.5 BTC資產和30,000 USDC負債。
呼叫參數:
Parameter | Value |
symbol | BTCUSDC |
isIsolated | FALSE |
side | BUY |
type | Limit |
quantity | 0.5 |
quoteOrderQty | |
price | 40,000 |
stopPrice | |
newClientOrderId | |
icebergQty | |
newOrderRespType | |
sideEffectType | MARGIN_BUY |
timeInForce | GTC |
selfTradePreventionMode | NONE |
autoRepayAtCancel | TRUE |
recvWindow | |
timestamp | 1507725176595 |
返回參數:
{
"symbol": "BTCUSDC",
"orderId": 29,
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"transactTime": 1507725176595,
"price": "40000.00000000",
"origQty": "0.50000000",
"executedQty": "0.50000000",
"cummulativeQuoteQty": "0.50000000",
"status": "FILLED",
"timeInForce": "GTC",
"type": "Limit",
"side": "BUY",
"marginBuyBorrowAmount": 20000, // 下單後沒有發生借款則不返回該字段
"marginBuyBorrowAsset": "USDC", // 下單後沒有發生借款則不返回該字段
"isIsolated": false, // 是否是逐倉symbol交易
"selfTradePreventionMode": "NONE",
"fills": [
{
"price": "40000.00000000",
"qty": "0.50000000",
"commission": "20.00000000",
"commissionAsset": "USDC"
}
]
}
用戶C持有1 BTC資產和10,000 USDC負債,調用 POST /sapi/v1/margin/order 介面,設定sideEffectType為AUTO_REPAY。以價格 40,000 USDT下單賣出 1 BTC後,系統自動歸還10,000 USDC負債(忽略所產生的利息)。最後用戶持有30,000 USDC資產,沒有負債。
呼叫參數:
Parameter | Value |
symbol | BTCUSDC |
isIsolated | FALSE |
side | SELL |
type | Limit |
quantity | 1 |
quoteOrderQty | |
price | 40,000 |
stopPrice | |
newClientOrderId | |
icebergQty | |
newOrderRespType | |
sideEffectType | AUTO_REPAY |
timeInForce | GTC |
selfTradePreventionMode | NONE |
autoRepayAtCancel | |
recvWindow | |
timestamp | 1507725176595 |
返回參數:
{
"symbol": "BTCUSDC",
"orderId": 30,
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"transactTime": 1507725176595,
"price": "40000.00000000",
"origQty": "1.00000000",
"executedQty": "1.00000000",
"cummulativeQuoteQty": "1.00000000",
"status": "FILLED",
"timeInForce": "GTC",
"type": "Limit",
"side": "SELL",
"isIsolated": false, // 是否是逐倉symbol交易
"selfTradePreventionMode": "NONE",
"fills": [
{
"price": "40000.00000000",
"qty": "1.00000000",
"commission": "40.00000000",
"commissionAsset": "USDC"
}
]
}
用戶D持有1 BTC資產和10,000 USDC負債,調用 POST /sapi/v1/margin/order 介面,設定sideEffectType為AUTO_BORROW_REPAY。以價格 2,500 USDC下單賣出 4 ETH,系統自動借入4 ETH負債,同時歸還10,000 USDC負債(忽略所產生的利息)。最後用戶持有1 BTC 資產和4 ETH負債。
呼叫參數:
Parameter | Value |
symbol | ETHUSDC |
isIsolated | FALSE |
side | SELL |
type | Limit |
quantity | 4 |
quoteOrderQty | |
price | 2,500 |
stopPrice | |
newClientOrderId | |
icebergQty | |
newOrderRespType | |
sideEffectType | AUTO_BORROW_REPAY |
timeInForce | GTC |
selfTradePreventionMode | NONE |
autoRepayAtCancel | TRUE |
recvWindow | |
timestamp | 1507725176595 |
返回參數:
{
"symbol": "ETHUSDC",
"orderId": 31,
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"transactTime": 1507725176595,
"price": "2500.00000000",
"origQty": "4.00000000",
"executedQty": "4.00000000",
"cummulativeQuoteQty": "4.00000000",
"status": "FILLED",
"timeInForce": "GTC",
"type": "Limit",
"side": "SELL",
"marginBuyBorrowAmount": 4, // 下單後沒有發生借款則不返回該字段
"marginBuyBorrowAsset": "ETH", // 下單後沒有發生借款則不返回該字段
"isIsolated": false, // 是否是逐倉symbol交易
"selfTradePreventionMode": "NONE",
"fills": [
{
"price": "2500.00000000",
"qty": "4.00000000",
"commission": "10.00000000",
"commissionAsset": "USDC"
}
]
}
用戶可前往 槓桿帳戶和交易介面 查看所有介面說明。