All URIs are relative to https://api.gateio.ws/api/v4
Method | HTTP request | Description |
---|---|---|
list_futures_contracts | GET /futures/{settle}/contracts | List all futures contracts |
get_futures_contract | GET /futures/{settle}/contracts/{contract} | Get a single contract |
list_futures_order_book | GET /futures/{settle}/order_book | Futures order book |
list_futures_trades | GET /futures/{settle}/trades | Futures trading history |
list_futures_candlesticks | GET /futures/{settle}/candlesticks | Get futures candlesticks |
list_futures_tickers | GET /futures/{settle}/tickers | List futures tickers |
list_futures_funding_rate_history | GET /futures/{settle}/funding_rate | Funding rate history |
list_futures_insurance_ledger | GET /futures/{settle}/insurance | Futures insurance balance history |
list_contract_stats | GET /futures/{settle}/contract_stats | Futures stats |
list_liquidated_orders | GET /futures/{settle}/liq_orders | Retrieve liquidation history |
list_futures_accounts | GET /futures/{settle}/accounts | Query futures account |
list_futures_account_book | GET /futures/{settle}/account_book | Query account book |
list_positions | GET /futures/{settle}/positions | List all positions of a user |
get_position | GET /futures/{settle}/positions/{contract} | Get single position |
update_position_margin | POST /futures/{settle}/positions/{contract}/margin | Update position margin |
update_position_leverage | POST /futures/{settle}/positions/{contract}/leverage | Update position leverage |
update_position_risk_limit | POST /futures/{settle}/positions/{contract}/risk_limit | Update position risk limit |
set_dual_mode | POST /futures/{settle}/dual_mode | Enable or disable dual mode |
get_dual_mode_position | GET /futures/{settle}/dual_comp/positions/{contract} | Retrieve position detail in dual mode |
update_dual_mode_position_margin | POST /futures/{settle}/dual_comp/positions/{contract}/margin | Update position margin in dual mode |
update_dual_mode_position_leverage | POST /futures/{settle}/dual_comp/positions/{contract}/leverage | Update position leverage in dual mode |
update_dual_mode_position_risk_limit | POST /futures/{settle}/dual_comp/positions/{contract}/risk_limit | Update position risk limit in dual mode |
list_futures_orders | GET /futures/{settle}/orders | List futures orders |
create_futures_order | POST /futures/{settle}/orders | Create a futures order |
cancel_futures_orders | DELETE /futures/{settle}/orders | Cancel all `open` orders matched |
get_futures_order | GET /futures/{settle}/orders/{order_id} | Get a single order |
cancel_futures_order | DELETE /futures/{settle}/orders/{order_id} | Cancel a single order |
get_my_trades | GET /futures/{settle}/my_trades | List personal trading history |
list_position_close | GET /futures/{settle}/position_close | List position close history |
list_liquidates | GET /futures/{settle}/liquidates | List liquidation history |
list_price_triggered_orders | GET /futures/{settle}/price_orders | List all auto orders |
create_price_triggered_order | POST /futures/{settle}/price_orders | Create a price-triggered order |
cancel_price_triggered_order_list | DELETE /futures/{settle}/price_orders | Cancel all open orders |
get_price_triggered_order | GET /futures/{settle}/price_orders/{order_id} | Get a single order |
cancel_price_triggered_order | DELETE /futures/{settle}/price_orders/{order_id} | Cancel a single order |
list[Contract] list_futures_contracts(settle)
List all futures contracts
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
try:
# List all futures contracts
api_response = api_instance.list_futures_contracts(settle)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_futures_contracts: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Contract get_futures_contract(settle, contract)
Get a single contract
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
try:
# Get a single contract
api_response = api_instance.get_futures_contract(settle, contract)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->get_futures_contract: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Contract information | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
FuturesOrderBook list_futures_order_book(settle, contract, interval=interval, limit=limit, with_id=with_id)
Futures order book
Bids will be sorted by price from high to low, while asks sorted reversely
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
interval = '0' # str | Order depth. 0 means no aggregation is applied. default to 0 (optional) (default to '0')
limit = 10 # int | Maximum number of order depth data in asks or bids (optional) (default to 10)
with_id = False # bool | Whether the order book update ID will be returned. This ID increases by 1 on every order book update (optional) (default to False)
try:
# Futures order book
api_response = api_instance.list_futures_order_book(settle, contract, interval=interval, limit=limit, with_id=with_id)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_futures_order_book: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract | |
interval | str | Order depth. 0 means no aggregation is applied. default to 0 | [optional] [default to '0'] |
limit | int | Maximum number of order depth data in asks or bids | [optional] [default to 10] |
with_id | bool | Whether the order book update ID will be returned. This ID increases by 1 on every order book update | [optional] [default to False] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Order book retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[FuturesTrade] list_futures_trades(settle, contract, limit=limit, last_id=last_id, _from=_from, to=to)
Futures trading history
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
limit = 100 # int | Maximum number of records to be returned in a single list (optional) (default to 100)
last_id = '12345' # str | Specify the starting point for this list based on a previously retrieved id This parameter is deprecated. Use `from` and `to` instead to limit time range (optional)
_from = 1546905600 # int | Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. (optional)
to = 1546935600 # int | Specify end time in Unix seconds, default to current time (optional)
try:
# Futures trading history
api_response = api_instance.list_futures_trades(settle, contract, limit=limit, last_id=last_id, _from=_from, to=to)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_futures_trades: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract | |
limit | int | Maximum number of records to be returned in a single list | [optional] [default to 100] |
last_id | str | Specify the starting point for this list based on a previously retrieved id This parameter is deprecated. Use `from` and `to` instead to limit time range | [optional] |
_from | int | Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. | [optional] |
to | int | Specify end time in Unix seconds, default to current time | [optional] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[FuturesCandlestick] list_futures_candlesticks(settle, contract, _from=_from, to=to, limit=limit, interval=interval)
Get futures candlesticks
Return specified contract candlesticks. If prefix contract
with mark_
, the contract's mark price candlesticks are returned; if prefix with index_
, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying from
, to
and interval
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
_from = 1546905600 # int | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified (optional)
to = 1546935600 # int | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time (optional)
limit = 100 # int | Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. (optional) (default to 100)
interval = '5m' # str | Interval time between data points (optional) (default to '5m')
try:
# Get futures candlesticks
api_response = api_instance.list_futures_candlesticks(settle, contract, _from=_from, to=to, limit=limit, interval=interval)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_futures_candlesticks: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract | |
_from | int | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified | [optional] |
to | int | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time | [optional] |
limit | int | Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. | [optional] [default to 100] |
interval | str | Interval time between data points | [optional] [default to '5m'] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[FuturesTicker] list_futures_tickers(settle, contract=contract)
List futures tickers
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract, return related data only if specified (optional)
try:
# List futures tickers
api_response = api_instance.list_futures_tickers(settle, contract=contract)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_futures_tickers: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract, return related data only if specified | [optional] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[FundingRateRecord] list_futures_funding_rate_history(settle, contract, limit=limit)
Funding rate history
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
limit = 100 # int | Maximum number of records to be returned in a single list (optional) (default to 100)
try:
# Funding rate history
api_response = api_instance.list_futures_funding_rate_history(settle, contract, limit=limit)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_futures_funding_rate_history: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract | |
limit | int | Maximum number of records to be returned in a single list | [optional] [default to 100] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | History retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[InsuranceRecord] list_futures_insurance_ledger(settle, limit=limit)
Futures insurance balance history
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
limit = 100 # int | Maximum number of records to be returned in a single list (optional) (default to 100)
try:
# Futures insurance balance history
api_response = api_instance.list_futures_insurance_ledger(settle, limit=limit)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_futures_insurance_ledger: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
limit | int | Maximum number of records to be returned in a single list | [optional] [default to 100] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[ContractStat] list_contract_stats(settle, contract, _from=_from, interval=interval, limit=limit)
Futures stats
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
_from = 1604561000 # int | Start timestamp (optional)
interval = '5m' # str | (optional) (default to '5m')
limit = 30 # int | (optional) (default to 30)
try:
# Futures stats
api_response = api_instance.list_contract_stats(settle, contract, _from=_from, interval=interval, limit=limit)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_contract_stats: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract | |
_from | int | Start timestamp | [optional] |
interval | str | [optional] [default to '5m'] | |
limit | int | [optional] [default to 30] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[FuturesLiquidate] list_liquidated_orders(settle, contract=contract, _from=_from, to=to, limit=limit)
Retrieve liquidation history
Interval between from
and to
cannot exceeds 3600. Some private fields will not be returned in public endpoints. Refer to field description for detail.
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract, return related data only if specified (optional)
_from = 1547706332 # int | Start timestamp (optional)
to = 1547706332 # int | End timestamp (optional)
limit = 100 # int | Maximum number of records to be returned in a single list (optional) (default to 100)
try:
# Retrieve liquidation history
api_response = api_instance.list_liquidated_orders(settle, contract=contract, _from=_from, to=to, limit=limit)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_liquidated_orders: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract, return related data only if specified | [optional] |
_from | int | Start timestamp | [optional] |
to | int | End timestamp | [optional] |
limit | int | Maximum number of records to be returned in a single list | [optional] [default to 100] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
FuturesAccount list_futures_accounts(settle)
Query futures account
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
try:
# Query futures account
api_response = api_instance.list_futures_accounts(settle)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_futures_accounts: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[FuturesAccountBook] list_futures_account_book(settle, limit=limit, _from=_from, to=to, type=type)
Query account book
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
limit = 100 # int | Maximum number of records to be returned in a single list (optional) (default to 100)
_from = 1547706332 # int | Start timestamp (optional)
to = 1547706332 # int | End timestamp (optional)
type = 'dnw' # str | Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate (optional)
try:
# Query account book
api_response = api_instance.list_futures_account_book(settle, limit=limit, _from=_from, to=to, type=type)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_futures_account_book: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
limit | int | Maximum number of records to be returned in a single list | [optional] [default to 100] |
_from | int | Start timestamp | [optional] |
to | int | End timestamp | [optional] |
type | str | Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate | [optional] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[Position] list_positions(settle)
List all positions of a user
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
try:
# List all positions of a user
api_response = api_instance.list_positions(settle)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_positions: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Position get_position(settle, contract)
Get single position
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
try:
# Get single position
api_response = api_instance.get_position(settle, contract)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->get_position: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Position information | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Position update_position_margin(settle, contract, change)
Update position margin
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
change = '0.01' # str | Margin change. Use positive number to increase margin, negative number otherwise.
try:
# Update position margin
api_response = api_instance.update_position_margin(settle, contract, change)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->update_position_margin: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract | |
change | str | Margin change. Use positive number to increase margin, negative number otherwise. |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Position information | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Position update_position_leverage(settle, contract, leverage, cross_leverage_limit=cross_leverage_limit)
Update position leverage
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
leverage = '10' # str | New position leverage
cross_leverage_limit = '10' # str | Cross margin leverage(valid only when `leverage` is 0) (optional)
try:
# Update position leverage
api_response = api_instance.update_position_leverage(settle, contract, leverage, cross_leverage_limit=cross_leverage_limit)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->update_position_leverage: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract | |
leverage | str | New position leverage | |
cross_leverage_limit | str | Cross margin leverage(valid only when `leverage` is 0) | [optional] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Position information | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Position update_position_risk_limit(settle, contract, risk_limit)
Update position risk limit
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
risk_limit = '10' # str | New position risk limit
try:
# Update position risk limit
api_response = api_instance.update_position_risk_limit(settle, contract, risk_limit)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->update_position_risk_limit: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract | |
risk_limit | str | New position risk limit |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Position information | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
FuturesAccount set_dual_mode(settle, dual_mode)
Enable or disable dual mode
Before setting dual mode, make sure all positions are closed and no orders are open
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
dual_mode = true # bool | Whether to enable dual mode
try:
# Enable or disable dual mode
api_response = api_instance.set_dual_mode(settle, dual_mode)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->set_dual_mode: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
dual_mode | bool | Whether to enable dual mode |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Updated | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[Position] get_dual_mode_position(settle, contract)
Retrieve position detail in dual mode
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
try:
# Retrieve position detail in dual mode
api_response = api_instance.get_dual_mode_position(settle, contract)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->get_dual_mode_position: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[Position] update_dual_mode_position_margin(settle, contract, change, dual_side)
Update position margin in dual mode
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
change = '0.01' # str | Margin change. Use positive number to increase margin, negative number otherwise.
dual_side = 'dual_long' # str | Long or short position
try:
# Update position margin in dual mode
api_response = api_instance.update_dual_mode_position_margin(settle, contract, change, dual_side)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->update_dual_mode_position_margin: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract | |
change | str | Margin change. Use positive number to increase margin, negative number otherwise. | |
dual_side | str | Long or short position |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[Position] update_dual_mode_position_leverage(settle, contract, leverage)
Update position leverage in dual mode
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
leverage = '10' # str | New position leverage
try:
# Update position leverage in dual mode
api_response = api_instance.update_dual_mode_position_leverage(settle, contract, leverage)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->update_dual_mode_position_leverage: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract | |
leverage | str | New position leverage |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[Position] update_dual_mode_position_risk_limit(settle, contract, risk_limit)
Update position risk limit in dual mode
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
risk_limit = '10' # str | New position risk limit
try:
# Update position risk limit in dual mode
api_response = api_instance.update_dual_mode_position_risk_limit(settle, contract, risk_limit)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->update_dual_mode_position_risk_limit: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract | |
risk_limit | str | New position risk limit |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[FuturesOrder] list_futures_orders(settle, contract, status, limit=limit, offset=offset, last_id=last_id, count_total=count_total)
List futures orders
Zero-fill order cannot be retrieved for 60 seconds after cancellation
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
status = 'open' # str | Only list the orders with this status
limit = 100 # int | Maximum number of records to be returned in a single list (optional) (default to 100)
offset = 0 # int | List offset, starting from 0 (optional) (default to 0)
last_id = '12345' # str | Specify list staring point using the `id` of last record in previous list-query results (optional)
count_total = 0 # int | Whether to return total number matched. Default to 0(no return) (optional) (default to 0)
try:
# List futures orders
api_response = api_instance.list_futures_orders(settle, contract, status, limit=limit, offset=offset, last_id=last_id, count_total=count_total)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_futures_orders: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract | |
status | str | Only list the orders with this status | |
limit | int | Maximum number of records to be returned in a single list | [optional] [default to 100] |
offset | int | List offset, starting from 0 | [optional] [default to 0] |
last_id | str | Specify list staring point using the `id` of last record in previous list-query results | [optional] |
count_total | int | Whether to return total number matched. Default to 0(no return) | [optional] [default to 0] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | * X-Pagination-Limit - Request limit specified * X-Pagination-Offset - Request offset specified * X-Pagination-Total - Total number matched. Only returned if `count_total` set to 1 |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
FuturesOrder create_futures_order(settle, futures_order)
Create a futures order
Zero-fill order cannot be retrieved for 60 seconds after cancellation
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
futures_order = gate_api.FuturesOrder() # FuturesOrder |
try:
# Create a futures order
api_response = api_instance.create_futures_order(settle, futures_order)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->create_futures_order: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
futures_order | FuturesOrder |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
201 | Order details | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[FuturesOrder] cancel_futures_orders(settle, contract, side=side)
Cancel all open
orders matched
Zero-fill order cannot be retrieved for 60 seconds after cancellation
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
side = 'ask' # str | All bids or asks. Both included if not specified (optional)
try:
# Cancel all `open` orders matched
api_response = api_instance.cancel_futures_orders(settle, contract, side=side)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->cancel_futures_orders: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract | |
side | str | All bids or asks. Both included if not specified | [optional] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | All orders matched cancelled | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
FuturesOrder get_futures_order(settle, order_id)
Get a single order
Zero-fill order cannot be retrieved for 60 seconds after cancellation
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
order_id = '12345' # str | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted.
try:
# Get a single order
api_response = api_instance.get_futures_order(settle, order_id)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->get_futures_order: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
order_id | str | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted. |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Order details | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
FuturesOrder cancel_futures_order(settle, order_id)
Cancel a single order
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
order_id = '12345' # str | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted.
try:
# Cancel a single order
api_response = api_instance.cancel_futures_order(settle, order_id)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->cancel_futures_order: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
order_id | str | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted. |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Order details | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[MyFuturesTrade] get_my_trades(settle, contract=contract, order=order, limit=limit, offset=offset, last_id=last_id, count_total=count_total)
List personal trading history
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract, return related data only if specified (optional)
order = 12345 # int | Futures order ID, return related data only if specified (optional)
limit = 100 # int | Maximum number of records to be returned in a single list (optional) (default to 100)
offset = 0 # int | List offset, starting from 0 (optional) (default to 0)
last_id = '12345' # str | Specify list staring point using the `id` of last record in previous list-query results (optional)
count_total = 0 # int | Whether to return total number matched. Default to 0(no return) (optional) (default to 0)
try:
# List personal trading history
api_response = api_instance.get_my_trades(settle, contract=contract, order=order, limit=limit, offset=offset, last_id=last_id, count_total=count_total)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->get_my_trades: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract, return related data only if specified | [optional] |
order | int | Futures order ID, return related data only if specified | [optional] |
limit | int | Maximum number of records to be returned in a single list | [optional] [default to 100] |
offset | int | List offset, starting from 0 | [optional] [default to 0] |
last_id | str | Specify list staring point using the `id` of last record in previous list-query results | [optional] |
count_total | int | Whether to return total number matched. Default to 0(no return) | [optional] [default to 0] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | * X-Pagination-Limit - Request limit specified * X-Pagination-Offset - Request offset specified * X-Pagination-Total - Total number matched. Only returned if `count_total` set to 1 |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[PositionClose] list_position_close(settle, contract=contract, limit=limit, offset=offset, _from=_from, to=to)
List position close history
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract, return related data only if specified (optional)
limit = 100 # int | Maximum number of records to be returned in a single list (optional) (default to 100)
offset = 0 # int | List offset, starting from 0 (optional) (default to 0)
_from = 1547706332 # int | Start timestamp (optional)
to = 1547706332 # int | End timestamp (optional)
try:
# List position close history
api_response = api_instance.list_position_close(settle, contract=contract, limit=limit, offset=offset, _from=_from, to=to)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_position_close: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract, return related data only if specified | [optional] |
limit | int | Maximum number of records to be returned in a single list | [optional] [default to 100] |
offset | int | List offset, starting from 0 | [optional] [default to 0] |
_from | int | Start timestamp | [optional] |
to | int | End timestamp | [optional] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[FuturesLiquidate] list_liquidates(settle, contract=contract, limit=limit, at=at)
List liquidation history
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract, return related data only if specified (optional)
limit = 100 # int | Maximum number of records to be returned in a single list (optional) (default to 100)
at = 0 # int | Specify a liquidation timestamp (optional) (default to 0)
try:
# List liquidation history
api_response = api_instance.list_liquidates(settle, contract=contract, limit=limit, at=at)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_liquidates: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract, return related data only if specified | [optional] |
limit | int | Maximum number of records to be returned in a single list | [optional] [default to 100] |
at | int | Specify a liquidation timestamp | [optional] [default to 0] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[FuturesPriceTriggeredOrder] list_price_triggered_orders(settle, status, contract=contract, limit=limit, offset=offset)
List all auto orders
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
status = 'status_example' # str | Only list the orders with this status
contract = 'BTC_USDT' # str | Futures contract, return related data only if specified (optional)
limit = 100 # int | Maximum number of records to be returned in a single list (optional) (default to 100)
offset = 0 # int | List offset, starting from 0 (optional) (default to 0)
try:
# List all auto orders
api_response = api_instance.list_price_triggered_orders(settle, status, contract=contract, limit=limit, offset=offset)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->list_price_triggered_orders: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
status | str | Only list the orders with this status | |
contract | str | Futures contract, return related data only if specified | [optional] |
limit | int | Maximum number of records to be returned in a single list | [optional] [default to 100] |
offset | int | List offset, starting from 0 | [optional] [default to 0] |
list[FuturesPriceTriggeredOrder]
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
TriggerOrderResponse create_price_triggered_order(settle, futures_price_triggered_order)
Create a price-triggered order
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
futures_price_triggered_order = gate_api.FuturesPriceTriggeredOrder() # FuturesPriceTriggeredOrder |
try:
# Create a price-triggered order
api_response = api_instance.create_price_triggered_order(settle, futures_price_triggered_order)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->create_price_triggered_order: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
futures_price_triggered_order | FuturesPriceTriggeredOrder |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
201 | Order created | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[FuturesPriceTriggeredOrder] cancel_price_triggered_order_list(settle, contract)
Cancel all open orders
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
try:
# Cancel all open orders
api_response = api_instance.cancel_price_triggered_order_list(settle, contract)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->cancel_price_triggered_order_list: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
contract | str | Futures contract |
list[FuturesPriceTriggeredOrder]
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Batch cancellation request accepted. Query order status by listing orders | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
FuturesPriceTriggeredOrder get_price_triggered_order(settle, order_id)
Get a single order
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
order_id = 'order_id_example' # str | Retrieve the data of the order with the specified ID
try:
# Get a single order
api_response = api_instance.get_price_triggered_order(settle, order_id)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->get_price_triggered_order: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
order_id | str | Retrieve the data of the order with the specified ID |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Auto order detail | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
FuturesPriceTriggeredOrder cancel_price_triggered_order(settle, order_id)
Cancel a single order
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure APIv4 key authorization
configuration = gate_api.Configuration(
host = "https://api.gateio.ws/api/v4",
key = "YOU_API_KEY",
secret = "YOUR_API_SECRET"
)
api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
order_id = 'order_id_example' # str | Retrieve the data of the order with the specified ID
try:
# Cancel a single order
api_response = api_instance.cancel_price_triggered_order(settle, order_id)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling FuturesApi->cancel_price_triggered_order: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
settle | str | Settle currency | |
order_id | str | Retrieve the data of the order with the specified ID |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Auto order detail | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]