設置自動追加保證金
開關自動追加保證金,僅適用於逐倉保證金模式
HTTP 請求
POST /v5/position/set-auto-add-margin
請求參數
參數 | 是否必需 | 類型 | 說明 |
---|---|---|---|
category | true | string | 產品類型 |
symbol | true | string | 合約名稱 |
autoAddMargin | true | integer | 是否自動追加保證金. 0 : 關閉. 1 : 開啟 |
positionIdx | false | integer | 倉位標識,用於標識不同倉位, 雙向持倉模式下,該字段必傳
|
響應參數
無
請求示例
- HTTP
- Python
- Java
- Node.js
POST /v5/position/set-auto-add-margin 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: 1675255134857
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
{
"category": "linear",
"symbol": "BTCUSDT",
"autoAddmargin": 1,
"positionIdx": null
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.set_auto_add_margin(
category="linear",
symbol="BTCUSDT",
autoAddmargin=1,
))
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 setAutoAddMarginRequest = PositionDataRequest.builder().category(CategoryType.LINEAR).symbol("BTCUSDT").autoAddMargin(AutoAddMargin.ON).build();
client.setAutoAddMargin(setAutoAddMarginRequest, System.out::println);
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.setAutoAddMargin({
category: 'linear',
symbol: 'BTCUSDT',
autoAddMargin: 1,
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
響應示例
{
"retCode": 0,
"retMsg": "OK",
"result": {},
"retExtInfo": {},
"time": 1675255135069
}