Switch Cross/Isolated Margin
Select cross margin mode or isolated margin mode per symbol level
HTTP Request
POST /v5/position/switch-isolated
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
category | true | string | Product type |
symbol | true | string | Symbol name, like BTCUSDT , uppercase only |
tradeMode | true | integer | 0 : cross margin. 1 : isolated margin |
buyLeverage | true | string | The value must be equal to sellLeverage value |
sellLeverage | true | string | The value must be equal to buyLeverage value |
Response Parameters
None
Request Example
- 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);
});
Response Example
{
"retCode": 0,
"retMsg": "OK",
"result": {},
"retExtInfo": {},
"time": 1675248433635
}