切換全倉/逐倉保證金(交易對)
選擇全倉保證金或者是逐倉保證金,請參閱這裡了解關於全倉/逐倉保證金模式。
HTTP 請求
POST /v5/position/switch-isolated
請求參數
參數 | 是否必需 | 類型 | 說明 |
---|---|---|---|
category | true | string | 產品類型 |
symbol | true | string | 合約名稱 |
tradeMode | true | integer | 0 : 全倉. 1 : 逐倉 |
buyLeverage | true | string | 買側槓桿倍數. 必須與sellLeverage 的值保持相同 |
sellLeverage | true | string | 賣側槓桿倍數. 必須與buyLeverage 的值保持相同 |
響應參數
無
請求示例
- HTTP
- Python
- Java
- Node.js
POST /v5/position/switch-isolated HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN-TYPE: 2
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1675248447965
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
Content-Length: 121
{
"category": "linear",
"symbol": "ETHUSDT",
"tradeMode": 1,
"buyLeverage": "10",
"sellLeverage": "10"
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.switch_margin_mode(
category="linear",
symbol="ETHUSDT",
tradeMode=1,
buyLeverage="10",
sellLeverage="10",
))
import com.bybit.api.client.domain.*;
import com.bybit.api.client.domain.position.*;
import com.bybit.api.client.domain.position.request.*;
import com.bybit.api.client.service.BybitApiClientFactory;
var client = BybitApiClientFactory.newInstance().newAsyncPositionRestClient();
var switchMarginRequest = PositionDataRequest.builder().category(CategoryType.LINEAR).symbol("BTC-31MAR23").tradeMode(MarginMode.CROSS_MARGIN).buyLeverage("5").sellLeverage("5").build();
client.swithMarginRequest(switchMarginRequest, System.out::println);
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.switchIsolatedMargin({
category: 'linear',
symbol: 'ETHUSDT',
tradeMode: 1,
buyLeverage: '10',
sellLeverage: '10',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
響應示例
{
"retCode": 0,
"retMsg": "OK",
"result": {},
"retExtInfo": {},
"time": 1675248433635
}