Set Margin Mode
Default is regular margin mode
info
- UTA account can be switched between these 3 kinds of margin modes, which is across UID level, working for USDT Perp, USDC Perp, USDC Futures and Options (Option does not support ISOLATED_MARGIN)
- Classic account can be switched between
REGULAR_MARGIN
andPORTFOLIO_MARGIN
, only work for USDC Perp and Options trading.
HTTP Request
POST /v5/account/set-margin-mode
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
setMarginMode | true | string | ISOLATED_MARGIN , REGULAR_MARGIN (i.e. Cross margin), PORTFOLIO_MARGIN |
Response Parameters
Parameter | Type | Comments |
---|---|---|
reasons | array | Object. If requested successfully, it is an empty array |
> reasonCode | string | Fail reason code |
> reasonMsg | string | Fail reason msg |
Request Example
- HTTP
- Python
POST /v5/account/set-margin-mode HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672134396332
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
{
"setMarginMode": "PORTFOLIO_MARGIN"
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.set_margin_mode(
setMarginMode="PORTFOLIO_MARGIN",
))
Response Example
{
"retCode": 3400045,
"retMsg": "Set margin mode failed",
"result": {
"reasons": [
{
"reasonCode": "3400000",
"reasonMsg": "Equity needs to be equal to or greater than 1000 USDC"
}
]
}
}