Toggle Margin Trade
Turn on / off spot margin trade
Covers: Margin trade (Unified Account)
caution
Your account needs to activate spot margin first; i.e., you must have finished the quiz on web / app.
HTTP Request
POST /v5/spot-margin-trade/switch-mode
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
spotMarginMode | true | string | 1 : on, 0 : off |
Response Parameters
Parameter | Type | Comments |
---|---|---|
spotMarginMode | string | Spot margin status. 1 : on, 0 : off |
Request Example
- HTTP
- Python
- Node.js
POST /v5/spot-margin-trade/switch-mode HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672297794480
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
{
"spotMarginMode": "0"
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.spot_margin_trade_toggle_margin_trade(
spotMarginMode="0",
))
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.toggleSpotMarginTrade('0')
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
Response Example
{
"retCode": 0,
"retMsg": "OK",
"result": {
"spotMarginMode": "0"
},
"retExtInfo": {},
"time": 1672297795542
}