All URIs are relative to https://www.bitmex.com/api/v1
Method | HTTP request | Description |
---|---|---|
position_get | GET /position | Get your positions. |
position_isolate_margin | POST /position/isolate | Enable isolated margin or cross margin per-position. |
position_transfer_isolated_margin | POST /position/transferMargin | Transfer equity in or out of a position. |
position_update_leverage | POST /position/leverage | Choose leverage for a position. |
position_update_risk_limit | POST /position/riskLimit | Update your risk limit. |
list[Position] position_get(filter=filter, columns=columns, count=count)
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. - 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. - grossOpenCost: The absolute value of your open orders for this symbol. - 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. - unrealisedGrossPnl: markValue - unrealisedCost. - 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.
from __future__ import print_function
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: apiExpires
configuration = swagger_client.Configuration()
configuration.api_key['api-expires'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-expires'] = 'Bearer'
# Configure API key authorization: apiKey
configuration = swagger_client.Configuration()
configuration.api_key['api-key'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-key'] = 'Bearer'
# Configure API key authorization: apiSignature
configuration = swagger_client.Configuration()
configuration.api_key['api-signature'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-signature'] = 'Bearer'
# create an instance of the API class
api_instance = swagger_client.PositionApi(swagger_client.ApiClient(configuration))
filter = 'filter_example' # str | Table filter. For example, send {\"symbol\": \"XBTUSD\"}. (optional)
columns = 'columns_example' # str | Which columns to fetch. For example, send [\"columnName\"]. (optional)
count = 8.14 # float | Number of rows to fetch. (optional)
try:
# Get your positions.
api_response = api_instance.position_get(filter=filter, columns=columns, count=count)
pprint(api_response)
except ApiException as e:
print("Exception when calling PositionApi->position_get: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
filter | str | Table filter. For example, send {"symbol": "XBTUSD"}. | [optional] |
columns | str | Which columns to fetch. For example, send ["columnName"]. | [optional] |
count | float | 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 position_isolate_margin(symbol, enabled=enabled)
Enable isolated margin or cross margin per-position.
from __future__ import print_function
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: apiExpires
configuration = swagger_client.Configuration()
configuration.api_key['api-expires'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-expires'] = 'Bearer'
# Configure API key authorization: apiKey
configuration = swagger_client.Configuration()
configuration.api_key['api-key'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-key'] = 'Bearer'
# Configure API key authorization: apiSignature
configuration = swagger_client.Configuration()
configuration.api_key['api-signature'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-signature'] = 'Bearer'
# create an instance of the API class
api_instance = swagger_client.PositionApi(swagger_client.ApiClient(configuration))
symbol = 'symbol_example' # str | Position symbol to isolate.
enabled = true # bool | True for isolated margin, false for cross margin. (optional) (default to true)
try:
# Enable isolated margin or cross margin per-position.
api_response = api_instance.position_isolate_margin(symbol, enabled=enabled)
pprint(api_response)
except ApiException as e:
print("Exception when calling PositionApi->position_isolate_margin: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
symbol | str | 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 position_transfer_isolated_margin(symbol, amount)
Transfer equity in or out of a position.
from __future__ import print_function
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: apiExpires
configuration = swagger_client.Configuration()
configuration.api_key['api-expires'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-expires'] = 'Bearer'
# Configure API key authorization: apiKey
configuration = swagger_client.Configuration()
configuration.api_key['api-key'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-key'] = 'Bearer'
# Configure API key authorization: apiSignature
configuration = swagger_client.Configuration()
configuration.api_key['api-signature'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-signature'] = 'Bearer'
# create an instance of the API class
api_instance = swagger_client.PositionApi(swagger_client.ApiClient(configuration))
symbol = 'symbol_example' # str | Symbol of position to isolate.
amount = 8.14 # float | Amount to transfer, in Satoshis. May be negative.
try:
# Transfer equity in or out of a position.
api_response = api_instance.position_transfer_isolated_margin(symbol, amount)
pprint(api_response)
except ApiException as e:
print("Exception when calling PositionApi->position_transfer_isolated_margin: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
symbol | str | Symbol of position to isolate. | |
amount | float | Amount to transfer, in Satoshis. May be negative. |
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 position_update_leverage(symbol, leverage)
Choose leverage for a position.
from __future__ import print_function
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: apiExpires
configuration = swagger_client.Configuration()
configuration.api_key['api-expires'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-expires'] = 'Bearer'
# Configure API key authorization: apiKey
configuration = swagger_client.Configuration()
configuration.api_key['api-key'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-key'] = 'Bearer'
# Configure API key authorization: apiSignature
configuration = swagger_client.Configuration()
configuration.api_key['api-signature'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-signature'] = 'Bearer'
# create an instance of the API class
api_instance = swagger_client.PositionApi(swagger_client.ApiClient(configuration))
symbol = 'symbol_example' # str | Symbol of position to adjust.
leverage = 1.2 # float | Leverage value. Send a number between 0.01 and 100 to enable isolated margin with a fixed leverage. Send 0 to enable cross margin.
try:
# Choose leverage for a position.
api_response = api_instance.position_update_leverage(symbol, leverage)
pprint(api_response)
except ApiException as e:
print("Exception when calling PositionApi->position_update_leverage: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
symbol | str | Symbol of position to adjust. | |
leverage | float | Leverage value. Send a number between 0.01 and 100 to enable isolated margin with a fixed leverage. Send 0 to enable cross margin. |
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 position_update_risk_limit(symbol, risk_limit)
Update your risk limit.
from __future__ import print_function
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: apiExpires
configuration = swagger_client.Configuration()
configuration.api_key['api-expires'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-expires'] = 'Bearer'
# Configure API key authorization: apiKey
configuration = swagger_client.Configuration()
configuration.api_key['api-key'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-key'] = 'Bearer'
# Configure API key authorization: apiSignature
configuration = swagger_client.Configuration()
configuration.api_key['api-signature'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-signature'] = 'Bearer'
# create an instance of the API class
api_instance = swagger_client.PositionApi(swagger_client.ApiClient(configuration))
symbol = 'symbol_example' # str | Symbol of position to update risk limit on.
risk_limit = 8.14 # float | New Risk Limit, in Satoshis.
try:
# Update your risk limit.
api_response = api_instance.position_update_risk_limit(symbol, risk_limit)
pprint(api_response)
except ApiException as e:
print("Exception when calling PositionApi->position_update_risk_limit: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
symbol | str | Symbol of position to update risk limit on. | |
risk_limit | float | New Risk Limit, in Satoshis. |
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]