Set Auto Add Margin
Turn on/off auto-add-margin for isolated margin position
HTTP Request
POST /v5/position/set-auto-add-margin
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
category | true | string | Product type |
symbol | true | string | Symbol name, like BTCUSDT , uppercase only |
autoAddMargin | true | integer | Turn on/off. 0 : off. 1 : on |
positionIdx | false | integer | Used to identify positions in different position modes. For hedge mode position, this param is required
|
Response Parameters
None
Request Example
- 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);
});
Response Example
{
"retCode": 0,
"retMsg": "OK",
"result": {},
"retExtInfo": {},
"time": 1675255135069
}