Skip to content

Latest commit

 

History

History
345 lines (261 loc) · 13.9 KB

PositionApi.md

File metadata and controls

345 lines (261 loc) · 13.9 KB

bitmex_client.PositionApi

All URIs are relative to https://localhost/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.

position_get

list[Position] position_get(filter=filter, columns=columns, count=count)

Get your positions.

See <a href="http://www.onixs.biz/fix-dictionary/5.0.SP2/msgType_AP_6580.html\">the FIX Spec for explanations of these fields.

Example

from __future__ import print_function
import time
import bitmex_client
from bitmex_client.rest import ApiException
from pprint import pprint

# Configure API key authorization: apiKey
configuration = bitmex_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: apiNonce
configuration = bitmex_client.Configuration()
configuration.api_key['api-nonce'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-nonce'] = 'Bearer'
# Configure API key authorization: apiSignature
configuration = bitmex_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 = bitmex_client.PositionApi(bitmex_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 = 3.4 # 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)

Parameters

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

Return type

list[Position]

Authorization

apiKey, apiNonce, apiSignature

HTTP request headers

  • 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_isolate_margin

Position position_isolate_margin(symbol, enabled=enabled)

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

from __future__ import print_function
import time
import bitmex_client
from bitmex_client.rest import ApiException
from pprint import pprint

# Configure API key authorization: apiKey
configuration = bitmex_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: apiNonce
configuration = bitmex_client.Configuration()
configuration.api_key['api-nonce'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-nonce'] = 'Bearer'
# Configure API key authorization: apiSignature
configuration = bitmex_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 = bitmex_client.PositionApi(bitmex_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)

Parameters

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

Return type

Position

Authorization

apiKey, apiNonce, apiSignature

HTTP request headers

  • 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_transfer_isolated_margin

Position position_transfer_isolated_margin(symbol, amount)

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

from __future__ import print_function
import time
import bitmex_client
from bitmex_client.rest import ApiException
from pprint import pprint

# Configure API key authorization: apiKey
configuration = bitmex_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: apiNonce
configuration = bitmex_client.Configuration()
configuration.api_key['api-nonce'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-nonce'] = 'Bearer'
# Configure API key authorization: apiSignature
configuration = bitmex_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 = bitmex_client.PositionApi(bitmex_client.ApiClient(configuration))
symbol = 'symbol_example' # str | Symbol of position to isolate.
amount = 3.4 # 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)

Parameters

Name Type Description Notes
symbol str Symbol of position to isolate.
amount float Amount to transfer, in Satoshis. May be negative.

Return type

Position

Authorization

apiKey, apiNonce, apiSignature

HTTP request headers

  • 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_update_leverage

Position position_update_leverage(symbol, leverage)

Choose leverage for a position.

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

Example

from __future__ import print_function
import time
import bitmex_client
from bitmex_client.rest import ApiException
from pprint import pprint

# Configure API key authorization: apiKey
configuration = bitmex_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: apiNonce
configuration = bitmex_client.Configuration()
configuration.api_key['api-nonce'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-nonce'] = 'Bearer'
# Configure API key authorization: apiSignature
configuration = bitmex_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 = bitmex_client.PositionApi(bitmex_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)

Parameters

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.

Return type

Position

Authorization

apiKey, apiNonce, apiSignature

HTTP request headers

  • 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_update_risk_limit

Position position_update_risk_limit(symbol, risk_limit)

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

from __future__ import print_function
import time
import bitmex_client
from bitmex_client.rest import ApiException
from pprint import pprint

# Configure API key authorization: apiKey
configuration = bitmex_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: apiNonce
configuration = bitmex_client.Configuration()
configuration.api_key['api-nonce'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api-nonce'] = 'Bearer'
# Configure API key authorization: apiSignature
configuration = bitmex_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 = bitmex_client.PositionApi(bitmex_client.ApiClient(configuration))
symbol = 'symbol_example' # str | Symbol of position to isolate.
risk_limit = 3.4 # 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)

Parameters

Name Type Description Notes
symbol str Symbol of position to isolate.
risk_limit float New Risk Limit, in Satoshis.

Return type

Position

Authorization

apiKey, apiNonce, apiSignature

HTTP request headers

  • 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]