設置槓桿
信息
根據風險限額, 槓桿影響最大可開數量, 即槓桿越大, 最大可開倉數量越小, 反之亦然。了解更多
HTTP 請求
POST /v5/position/set-leverage
請求參數
參數 | 是否必需 | 類型 | 說明 |
---|---|---|---|
category | true | string | 產品類型 |
symbol | true | string | 合約名稱 |
buyLeverage | true | string | [1 , 最大槓桿數]
|
sellLeverage | true | string | [1 , 最大槓桿數] |
響應參數
無
請求示例
- HTTP
- Python
- Java
- Node.js
POST /v5/position/set-leverage HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672281605082
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
{
"category": "linear",
"symbol": "BTCUSDT",
"buyLeverage": "6",
"sellLeverage": "6"
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.set_leverage(
category="linear",
symbol="BTCUSDT",
buyLeverage="6",
sellLeverage="6",
))
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 setLeverageRequest = PositionDataRequest.builder().category(CategoryType.LINEAR).symbol("BTCUSDT").buyLeverage("5").sellLeverage("5").build();
client.setPositionLeverage(setLeverageRequest, System.out::println);
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.setLeverage({
category: 'linear',
symbol: 'BTCUSDT',
buyLeverage: '6',
sellLeverage: '6',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
響應示例
{
"retCode": 0,
"retMsg": "OK",
"result": {},
"retExtInfo": {},
"time": 1672281607343
}