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. |
List PositionGet (string filter = null, string columns = null, int? count = null)
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.
using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;
namespace Example
{
public class PositionGetExample
{
public void main()
{
// Configure API key authorization: apiExpires
Configuration.Default.AddApiKey("api-expires", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-expires", "Bearer");
// Configure API key authorization: apiKey
Configuration.Default.AddApiKey("api-key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-key", "Bearer");
// Configure API key authorization: apiSignature
Configuration.Default.AddApiKey("api-signature", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-signature", "Bearer");
var apiInstance = new PositionApi();
var filter = filter_example; // string | Table filter. For example, send {\"symbol\": \"XBTUSD\"}. (optional)
var columns = columns_example; // string | Which columns to fetch. For example, send [\"columnName\"]. (optional)
var count = 56; // int? | Number of rows to fetch. (optional)
try
{
// Get your positions.
List<Position> result = apiInstance.PositionGet(filter, columns, count);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling PositionApi.PositionGet: " + e.Message );
}
}
}
}
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 | int? | Number of rows to fetch. | [optional] |
apiExpires, apiKey, apiSignature
- Content-Type: application/json, application/x-www-form-urlencoded
- Accept: application/json, application/xml, text/xml, application/javascript, text/javascript
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Position PositionIsolateMargin (string symbol, bool? enabled = null)
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.
using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;
namespace Example
{
public class PositionIsolateMarginExample
{
public void main()
{
// Configure API key authorization: apiExpires
Configuration.Default.AddApiKey("api-expires", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-expires", "Bearer");
// Configure API key authorization: apiKey
Configuration.Default.AddApiKey("api-key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-key", "Bearer");
// Configure API key authorization: apiSignature
Configuration.Default.AddApiKey("api-signature", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-signature", "Bearer");
var apiInstance = new PositionApi();
var symbol = symbol_example; // string | Position symbol to isolate.
var enabled = true; // bool? | True for isolated margin, false for cross margin. (optional) (default to true)
try
{
// Enable isolated margin or cross margin per-position.
Position result = apiInstance.PositionIsolateMargin(symbol, enabled);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling PositionApi.PositionIsolateMargin: " + e.Message );
}
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
symbol | string | Position symbol to isolate. | |
enabled | bool? | True for isolated margin, false for cross margin. | [optional] [default to true] |
apiExpires, apiKey, apiSignature
- Content-Type: application/json, application/x-www-form-urlencoded
- Accept: application/json, application/xml, text/xml, application/javascript, text/javascript
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Position PositionTransferIsolatedMargin (string symbol, long? amount, double? targetAccountId = null)
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.
using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;
namespace Example
{
public class PositionTransferIsolatedMarginExample
{
public void main()
{
// Configure API key authorization: apiExpires
Configuration.Default.AddApiKey("api-expires", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-expires", "Bearer");
// Configure API key authorization: apiKey
Configuration.Default.AddApiKey("api-key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-key", "Bearer");
// Configure API key authorization: apiSignature
Configuration.Default.AddApiKey("api-signature", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-signature", "Bearer");
var apiInstance = new PositionApi();
var symbol = symbol_example; // string | Symbol of position to isolate.
var amount = 789; // long? | Amount to transfer, in Satoshis. May be negative.
var targetAccountId = 1.2; // double? | AccountId for the position that the margin would be transfered to, must be a paired account with main user. (optional)
try
{
// Transfer equity in or out of a position.
Position result = apiInstance.PositionTransferIsolatedMargin(symbol, amount, targetAccountId);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling PositionApi.PositionTransferIsolatedMargin: " + e.Message );
}
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
symbol | string | Symbol of position to isolate. | |
amount | long? | Amount to transfer, in Satoshis. May be negative. | |
targetAccountId | double? | AccountId for the position that the margin would be transfered to, must be a paired account with main user. | [optional] |
apiExpires, apiKey, apiSignature
- Content-Type: application/json, application/x-www-form-urlencoded
- Accept: application/json, application/xml, text/xml, application/javascript, text/javascript
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Position PositionUpdateLeverage (string symbol, double? leverage, double? targetAccountId = null)
Choose leverage for a position.
Users can choose an isolated leverage. This will automatically enable isolated margin.
using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;
namespace Example
{
public class PositionUpdateLeverageExample
{
public void main()
{
// Configure API key authorization: apiExpires
Configuration.Default.AddApiKey("api-expires", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-expires", "Bearer");
// Configure API key authorization: apiKey
Configuration.Default.AddApiKey("api-key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-key", "Bearer");
// Configure API key authorization: apiSignature
Configuration.Default.AddApiKey("api-signature", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-signature", "Bearer");
var apiInstance = new PositionApi();
var symbol = symbol_example; // string | Symbol of position to adjust.
var leverage = 1.2; // double? | 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 targetAccountId = 1.2; // double? | AccountId for the position that the leverage would be changed on, must be a paired account with main user. (optional)
try
{
// Choose leverage for a position.
Position result = apiInstance.PositionUpdateLeverage(symbol, leverage, targetAccountId);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling PositionApi.PositionUpdateLeverage: " + e.Message );
}
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
symbol | string | Symbol of position to adjust. | |
leverage | double? | 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 | double? | AccountId for the position that the leverage would be changed on, must be a paired account with main user. | [optional] |
apiExpires, apiKey, apiSignature
- Content-Type: application/json, application/x-www-form-urlencoded
- Accept: application/json, application/xml, text/xml, application/javascript, text/javascript
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Position PositionUpdateRiskLimit (string symbol, long? riskLimit, double? targetAccountId = null)
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.
using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;
namespace Example
{
public class PositionUpdateRiskLimitExample
{
public void main()
{
// Configure API key authorization: apiExpires
Configuration.Default.AddApiKey("api-expires", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-expires", "Bearer");
// Configure API key authorization: apiKey
Configuration.Default.AddApiKey("api-key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-key", "Bearer");
// Configure API key authorization: apiSignature
Configuration.Default.AddApiKey("api-signature", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api-signature", "Bearer");
var apiInstance = new PositionApi();
var symbol = symbol_example; // string | Symbol of position to update risk limit on.
var riskLimit = 789; // long? | New Risk Limit, in Satoshis.
var targetAccountId = 1.2; // double? | AccountId for the position that the risk limit would be updated on, must be a paired account with main user. (optional)
try
{
// Update your risk limit.
Position result = apiInstance.PositionUpdateRiskLimit(symbol, riskLimit, targetAccountId);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling PositionApi.PositionUpdateRiskLimit: " + e.Message );
}
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
symbol | string | Symbol of position to update risk limit on. | |
riskLimit | long? | New Risk Limit, in Satoshis. | |
targetAccountId | double? | AccountId for the position that the risk limit would be updated on, must be a paired account with main user. | [optional] |
apiExpires, apiKey, apiSignature
- Content-Type: application/json, application/x-www-form-urlencoded
- Accept: application/json, application/xml, text/xml, application/javascript, text/javascript
[Back to top] [Back to API list] [Back to Model list] [Back to README]