Skip to content

Latest commit

 

History

History
368 lines (267 loc) · 16.1 KB

PositionApi.md

File metadata and controls

368 lines (267 loc) · 16.1 KB

BitMexApi.PositionApi

All URIs are relative to https://www.bitmex.com/api/v1

Method HTTP request Description
positionGet GET /position Get your positions.
positionIsolateMargin POST /position/isolate Enable isolated margin or cross margin per-position.
positionTransferIsolatedMargin POST /position/transferMargin Transfer equity in or out of a position.
positionUpdateLeverage POST /position/leverage Choose leverage for a position.
positionUpdateRiskLimit POST /position/riskLimit Update your risk limit.

positionGet

[Position] positionGet(opts)

Get your positions.

This endpoint is used for retrieving position information. The fields largely follow the FIX spec definitions. Some selected fields are explained in more detail below. The fields account, symbol, currency are unique to each position and form its key. Spot trading symbols returns a subset of the position fields, mainly the open order aggregates. - account: Your unique account ID. - symbol: The contract for this position. - currency: The margin currency for this position. - underlying: Meta data of the symbol. - quoteCurrency: Meta data of the symbol, All prices are in the quoteCurrency - commission: The maximum of the maker, taker, and settlement fee. - initMarginReq: The initial margin requirement. This will be at least the symbol's default initial maintenance margin, but can be higher if you choose lower leverage. - maintMarginReq: The maintenance margin requirement. This will be at least the symbol's default maintenance maintenance margin, but can be higher if you choose a higher risk limit. - riskLimit: This is a function of your maintMarginReq. - leverage: 1 / initMarginReq. - crossMargin: True/false depending on whether you set cross margin on this position. - deleveragePercentile: Indicates where your position is in the ADL queue. - rebalancedPnl: The value of realised PNL that has transferred to your wallet for this position. - prevRealisedPnl: The value of realised PNL that has transferred to your wallet for this position since the position was closed. - currentQty: The current position amount in contracts. - currentCost: The current cost of the position in the settlement currency of the symbol (currency). - currentComm: The current commission of the position in the settlement currency of the symbol (currency). - realisedCost: The realised cost of this position calculated with regard to average cost accounting. - unrealisedCost: currentCost - realisedCost. - grossOpenPremium: The amount your bidding above the mark price in the settlement currency of the symbol (currency). - markPrice: The mark price of the symbol in quoteCurrency. - markValue: The currentQty at the mark price in the settlement currency of the symbol (currency). - homeNotional: Value of position in units of underlying. - foreignNotional: Value of position in units of quoteCurrency. - realisedPnl: The negative of realisedCost. - unrealisedPnl: unrealisedGrossPnl. - liquidationPrice: Once markPrice reaches this price, this position will be liquidated. - bankruptPrice: Once markPrice reaches this price, this position will have no equity.

Example

var BitMexApi = require('bit_mex_api');
var defaultClient = BitMexApi.ApiClient.instance;

// Configure API key authorization: apiExpires
var apiExpires = defaultClient.authentications['apiExpires'];
apiExpires.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiExpires.apiKeyPrefix = 'Token';

// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix = 'Token';

// Configure API key authorization: apiSignature
var apiSignature = defaultClient.authentications['apiSignature'];
apiSignature.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiSignature.apiKeyPrefix = 'Token';

var apiInstance = new BitMexApi.PositionApi();

var opts = { 
  'filter': "filter_example", // String | Table filter. For example, send {\"symbol\": \"XBTUSD\"}.
  'columns': "columns_example", // String | Which columns to fetch. For example, send [\"columnName\"].
  'count': 56 // Number | Number of rows to fetch.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.positionGet(opts, callback);

Parameters

Name Type Description Notes
filter String Table filter. For example, send {"symbol": "XBTUSD"}. [optional]
columns String Which columns to fetch. For example, send ["columnName"]. [optional]
count Number Number of rows to fetch. [optional]

Return type

[Position]

Authorization

apiExpires, apiKey, apiSignature

HTTP request headers

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

positionIsolateMargin

Position positionIsolateMargin(symbol, opts)

Enable isolated margin or cross margin per-position.

Users can switch isolate margin per-position. This function allows switching margin isolation (aka fixed margin) on and off.

Example

var BitMexApi = require('bit_mex_api');
var defaultClient = BitMexApi.ApiClient.instance;

// Configure API key authorization: apiExpires
var apiExpires = defaultClient.authentications['apiExpires'];
apiExpires.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiExpires.apiKeyPrefix = 'Token';

// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix = 'Token';

// Configure API key authorization: apiSignature
var apiSignature = defaultClient.authentications['apiSignature'];
apiSignature.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiSignature.apiKeyPrefix = 'Token';

var apiInstance = new BitMexApi.PositionApi();

var symbol = "symbol_example"; // String | Position symbol to isolate.

var opts = { 
  'enabled': true // Boolean | True for isolated margin, false for cross margin.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.positionIsolateMargin(symbol, opts, callback);

Parameters

Name Type Description Notes
symbol String Position symbol to isolate.
enabled Boolean True for isolated margin, false for cross margin. [optional] [default to true]

Return type

Position

Authorization

apiExpires, apiKey, apiSignature

HTTP request headers

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

positionTransferIsolatedMargin

Position positionTransferIsolatedMargin(symbol, amount, opts)

Transfer equity in or out of a position.

When margin is isolated on a position, use this function to add or remove margin from the position. Note that you cannot remove margin below the initial margin threshold.

Example

var BitMexApi = require('bit_mex_api');
var defaultClient = BitMexApi.ApiClient.instance;

// Configure API key authorization: apiExpires
var apiExpires = defaultClient.authentications['apiExpires'];
apiExpires.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiExpires.apiKeyPrefix = 'Token';

// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix = 'Token';

// Configure API key authorization: apiSignature
var apiSignature = defaultClient.authentications['apiSignature'];
apiSignature.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiSignature.apiKeyPrefix = 'Token';

var apiInstance = new BitMexApi.PositionApi();

var symbol = "symbol_example"; // String | Symbol of position to isolate.

var amount = 789; // Number | Amount to transfer, in Satoshis. May be negative.

var opts = { 
  'targetAccountId': 1.2 // Number | AccountId for the position that the margin would be transfered to, must be a paired account with main user.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.positionTransferIsolatedMargin(symbol, amount, opts, callback);

Parameters

Name Type Description Notes
symbol String Symbol of position to isolate.
amount Number Amount to transfer, in Satoshis. May be negative.
targetAccountId Number AccountId for the position that the margin would be transfered to, must be a paired account with main user. [optional]

Return type

Position

Authorization

apiExpires, apiKey, apiSignature

HTTP request headers

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

positionUpdateLeverage

Position positionUpdateLeverage(symbol, leverage, opts)

Choose leverage for a position.

Users can choose an isolated leverage. This will automatically enable isolated margin.

Example

var BitMexApi = require('bit_mex_api');
var defaultClient = BitMexApi.ApiClient.instance;

// Configure API key authorization: apiExpires
var apiExpires = defaultClient.authentications['apiExpires'];
apiExpires.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiExpires.apiKeyPrefix = 'Token';

// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix = 'Token';

// Configure API key authorization: apiSignature
var apiSignature = defaultClient.authentications['apiSignature'];
apiSignature.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiSignature.apiKeyPrefix = 'Token';

var apiInstance = new BitMexApi.PositionApi();

var symbol = "symbol_example"; // String | Symbol of position to adjust.

var leverage = 1.2; // Number | Leverage value. Send a number between 0.01 and 100 to enable isolated margin with a fixed leverage. Send 0 to enable cross margin.

var opts = { 
  'targetAccountId': 1.2 // Number | AccountId for the position that the leverage would be changed on, must be a paired account with main user.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.positionUpdateLeverage(symbol, leverage, opts, callback);

Parameters

Name Type Description Notes
symbol String Symbol of position to adjust.
leverage Number Leverage value. Send a number between 0.01 and 100 to enable isolated margin with a fixed leverage. Send 0 to enable cross margin.
targetAccountId Number AccountId for the position that the leverage would be changed on, must be a paired account with main user. [optional]

Return type

Position

Authorization

apiExpires, apiKey, apiSignature

HTTP request headers

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

positionUpdateRiskLimit

Position positionUpdateRiskLimit(symbol, riskLimit, opts)

Update your risk limit.

Risk Limits limit the size of positions you can trade at various margin levels. Larger positions require more margin. Please see the Risk Limit documentation for more details.

Example

var BitMexApi = require('bit_mex_api');
var defaultClient = BitMexApi.ApiClient.instance;

// Configure API key authorization: apiExpires
var apiExpires = defaultClient.authentications['apiExpires'];
apiExpires.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiExpires.apiKeyPrefix = 'Token';

// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix = 'Token';

// Configure API key authorization: apiSignature
var apiSignature = defaultClient.authentications['apiSignature'];
apiSignature.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiSignature.apiKeyPrefix = 'Token';

var apiInstance = new BitMexApi.PositionApi();

var symbol = "symbol_example"; // String | Symbol of position to update risk limit on.

var riskLimit = 789; // Number | New Risk Limit, in Satoshis.

var opts = { 
  'targetAccountId': 1.2 // Number | AccountId for the position that the risk limit would be updated on, must be a paired account with main user.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.positionUpdateRiskLimit(symbol, riskLimit, opts, callback);

Parameters

Name Type Description Notes
symbol String Symbol of position to update risk limit on.
riskLimit Number New Risk Limit, in Satoshis.
targetAccountId Number AccountId for the position that the risk limit would be updated on, must be a paired account with main user. [optional]

Return type

Position

Authorization

apiExpires, apiKey, apiSignature

HTTP request headers

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