Set Leverage
Set the user's maximum leverage in spot cross margin
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/set-leverage
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
leverage | true | string | Leverage. [2 , 10 ]. |
Response Parameters
None
Request Example
- HTTP
- Python
- Node.js
POST /v5/spot-margin-trade/set-leverage HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672299806626
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
{
"leverage": "4"
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.spot_margin_trade_set_leverage(
leverage="4",
))
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.setSpotMarginLeverage('4')
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
Response Example
{
"retCode": 0,
"retMsg": "OK",
"result": {},
"retExtInfo": {},
"time": 1672710944282
}