Skip to content

Latest commit

 

History

History
340 lines (258 loc) · 11.8 KB

PositionsApi.md

File metadata and controls

340 lines (258 loc) · 11.8 KB

PositionsApi

All URIs are relative to https://api-testnet.bybit.com

Method HTTP request Description
positionsChangeMargin POST /position/change-position-margin Update margin.
positionsMyPosition GET /position/list Get my position list.
positionsSaveLeverage POST /user/leverage/save Change user leverage.
positionsTradingStop POST /open-api/position/trading-stop Set Trading-Stop Condition.
positionsUserLeverage GET /user/leverage Get user leverage setting.

positionsChangeMargin

Object positionsChangeMargin(symbol, margin)

Update margin.

Example

// Import classes:
//import io.swagger.client.ApiClient;
//import io.swagger.client.ApiException;
//import io.swagger.client.Configuration;
//import io.swagger.client.auth.*;
//import io.swagger.client.api.PositionsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: apiKey
ApiKeyAuth apiKey = (ApiKeyAuth) defaultClient.getAuthentication("apiKey");
apiKey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.setApiKeyPrefix("Token");

// Configure API key authorization: apiSignature
ApiKeyAuth apiSignature = (ApiKeyAuth) defaultClient.getAuthentication("apiSignature");
apiSignature.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiSignature.setApiKeyPrefix("Token");

// Configure API key authorization: timestamp
ApiKeyAuth timestamp = (ApiKeyAuth) defaultClient.getAuthentication("timestamp");
timestamp.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//timestamp.setApiKeyPrefix("Token");

PositionsApi apiInstance = new PositionsApi();
String symbol = "symbol_example"; // String | Contract type which you want update its margin
String margin = "margin_example"; // String | New margin you want set
try {
    Object result = apiInstance.positionsChangeMargin(symbol, margin);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PositionsApi#positionsChangeMargin");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
symbol String Contract type which you want update its margin
margin String New margin you want set

Return type

Object

Authorization

apiKey, apiSignature, timestamp

HTTP request headers

  • Content-Type: application/json, application/x-www-form-urlencoded
  • Accept: application/json

positionsMyPosition

Object positionsMyPosition()

Get my position list.

Example

// Import classes:
//import io.swagger.client.ApiClient;
//import io.swagger.client.ApiException;
//import io.swagger.client.Configuration;
//import io.swagger.client.auth.*;
//import io.swagger.client.api.PositionsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: apiKey
ApiKeyAuth apiKey = (ApiKeyAuth) defaultClient.getAuthentication("apiKey");
apiKey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.setApiKeyPrefix("Token");

// Configure API key authorization: apiSignature
ApiKeyAuth apiSignature = (ApiKeyAuth) defaultClient.getAuthentication("apiSignature");
apiSignature.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiSignature.setApiKeyPrefix("Token");

// Configure API key authorization: timestamp
ApiKeyAuth timestamp = (ApiKeyAuth) defaultClient.getAuthentication("timestamp");
timestamp.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//timestamp.setApiKeyPrefix("Token");

PositionsApi apiInstance = new PositionsApi();
try {
    Object result = apiInstance.positionsMyPosition();
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PositionsApi#positionsMyPosition");
    e.printStackTrace();
}

Parameters

This endpoint does not need any parameter.

Return type

Object

Authorization

apiKey, apiSignature, timestamp

HTTP request headers

  • Content-Type: application/json, application/x-www-form-urlencoded
  • Accept: application/json

positionsSaveLeverage

Object positionsSaveLeverage(symbol, leverage)

Change user leverage.

Example

// Import classes:
//import io.swagger.client.ApiClient;
//import io.swagger.client.ApiException;
//import io.swagger.client.Configuration;
//import io.swagger.client.auth.*;
//import io.swagger.client.api.PositionsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: apiKey
ApiKeyAuth apiKey = (ApiKeyAuth) defaultClient.getAuthentication("apiKey");
apiKey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.setApiKeyPrefix("Token");

// Configure API key authorization: apiSignature
ApiKeyAuth apiSignature = (ApiKeyAuth) defaultClient.getAuthentication("apiSignature");
apiSignature.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiSignature.setApiKeyPrefix("Token");

// Configure API key authorization: timestamp
ApiKeyAuth timestamp = (ApiKeyAuth) defaultClient.getAuthentication("timestamp");
timestamp.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//timestamp.setApiKeyPrefix("Token");

PositionsApi apiInstance = new PositionsApi();
String symbol = "symbol_example"; // String | A symbol which you want change its leverage
String leverage = "leverage_example"; // String | New leverage you want set
try {
    Object result = apiInstance.positionsSaveLeverage(symbol, leverage);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PositionsApi#positionsSaveLeverage");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
symbol String A symbol which you want change its leverage
leverage String New leverage you want set

Return type

Object

Authorization

apiKey, apiSignature, timestamp

HTTP request headers

  • Content-Type: application/json, application/x-www-form-urlencoded
  • Accept: application/json

positionsTradingStop

Object positionsTradingStop(symbol, takeProfit, stopLoss, trailingStop)

Set Trading-Stop Condition.

Example

// Import classes:
//import io.swagger.client.ApiClient;
//import io.swagger.client.ApiException;
//import io.swagger.client.Configuration;
//import io.swagger.client.auth.*;
//import io.swagger.client.api.PositionsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: apiKey
ApiKeyAuth apiKey = (ApiKeyAuth) defaultClient.getAuthentication("apiKey");
apiKey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.setApiKeyPrefix("Token");

// Configure API key authorization: apiSignature
ApiKeyAuth apiSignature = (ApiKeyAuth) defaultClient.getAuthentication("apiSignature");
apiSignature.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiSignature.setApiKeyPrefix("Token");

// Configure API key authorization: timestamp
ApiKeyAuth timestamp = (ApiKeyAuth) defaultClient.getAuthentication("timestamp");
timestamp.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//timestamp.setApiKeyPrefix("Token");

PositionsApi apiInstance = new PositionsApi();
String symbol = "symbol_example"; // String | Contract type
String takeProfit = "takeProfit_example"; // String | Not less than 0, 0 means cancel TP
String stopLoss = "stopLoss_example"; // String | Not less than 0, 0 means cancel SL
String trailingStop = "trailingStop_example"; // String | Not less than 0, 0 means cancel TS
try {
    Object result = apiInstance.positionsTradingStop(symbol, takeProfit, stopLoss, trailingStop);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PositionsApi#positionsTradingStop");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
symbol String Contract type
takeProfit String Not less than 0, 0 means cancel TP [optional]
stopLoss String Not less than 0, 0 means cancel SL [optional]
trailingStop String Not less than 0, 0 means cancel TS [optional]

Return type

Object

Authorization

apiKey, apiSignature, timestamp

HTTP request headers

  • Content-Type: application/json, application/x-www-form-urlencoded
  • Accept: application/json

positionsUserLeverage

Object positionsUserLeverage()

Get user leverage setting.

Example

// Import classes:
//import io.swagger.client.ApiClient;
//import io.swagger.client.ApiException;
//import io.swagger.client.Configuration;
//import io.swagger.client.auth.*;
//import io.swagger.client.api.PositionsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: apiKey
ApiKeyAuth apiKey = (ApiKeyAuth) defaultClient.getAuthentication("apiKey");
apiKey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.setApiKeyPrefix("Token");

// Configure API key authorization: apiSignature
ApiKeyAuth apiSignature = (ApiKeyAuth) defaultClient.getAuthentication("apiSignature");
apiSignature.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiSignature.setApiKeyPrefix("Token");

// Configure API key authorization: timestamp
ApiKeyAuth timestamp = (ApiKeyAuth) defaultClient.getAuthentication("timestamp");
timestamp.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//timestamp.setApiKeyPrefix("Token");

PositionsApi apiInstance = new PositionsApi();
try {
    Object result = apiInstance.positionsUserLeverage();
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PositionsApi#positionsUserLeverage");
    e.printStackTrace();
}

Parameters

This endpoint does not need any parameter.

Return type

Object

Authorization

apiKey, apiSignature, timestamp

HTTP request headers

  • Content-Type: application/json, application/x-www-form-urlencoded
  • Accept: application/json