Latest commit

History

History
1417 lines (1068 loc) · 47.2 KB

File metadata and controls

1417 lines (1068 loc) · 47.2 KB

gate_api.CFDApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
query_mt5_account_infoGET /tradfi/users/mt5-accountQuery MT5 account information
query_categoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
query_symbol_commissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
query_symbolsGET /tradfi/symbolsQuery trading symbol list
query_symbol_detailGET /tradfi/symbols/detailQuery trading symbol details
query_symbol_klineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
query_symbol_tickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
create_trad_fi_userPOST /tradfi/usersCreate CFD user
query_user_assetsGET /tradfi/users/assetsQuery account assets
query_transactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
create_transactionPOST /tradfi/transactionsFund transfer
query_order_listGET /tradfi/ordersQuery active order list
create_trad_fi_orderPOST /tradfi/ordersCreate order
update_orderPUT /tradfi/orders/{order_id}Modify order
delete_orderDELETE /tradfi/orders/{order_id}Cancel order
query_order_history_listGET /tradfi/orders/historyQuery historical order list
query_order_logGET /tradfi/orders/log/{log_id}Get order details by log ID
query_position_listGET /tradfi/positionsQuery active position list
update_positionPUT /tradfi/positions/{position_id}Modify position
close_positionPOST /tradfi/positions/{position_id}/closeClose position
query_position_history_listGET /tradfi/positions/historyQuery historical position list

query_mt5_account_info

Mt5Account query_mt5_account_info()

Query MT5 account information

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query MT5 account informationapi_response=api_instance.query_mt5_account_info()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_mt5_account_info: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_categories

Categories query_categories()

Query trading symbol categories

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol categoriesapi_response=api_instance.query_categories()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_categories: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_commissions

SymbolCommissions query_symbol_commissions(symbols=symbols, category_code=category_code)

Query symbol commission rates

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='AUDUSD,XAUUSD'# str | List of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required (optional)category_code='forex-外汇,metal-金属,index-指数,commodity-大宗商品,stock-股票'# str | List of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required (optional)try:
# Query symbol commission ratesapi_response=api_instance.query_symbol_commissions(symbols=symbols, category_code=category_code)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_commissions: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
category_codestrList of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required[optional]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbols

Symbols query_symbols()

Query trading symbol list

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol listapi_response=api_instance.query_symbols()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbols: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_detail

ContractDetail query_symbol_detail(symbols)

Query trading symbol details

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='EURUSD,XAGUSD'# str | Trading symbol code list (comma-separated, max 10 symbols)try:
# Query trading symbol detailsapi_response=api_instance.query_symbol_detail(symbols)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_kline

Klines query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)

Query trading symbol klines

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codekline_type='1m'# str | Kline type (time period)begin_time=1769378400# int | Start time (Unix timestamp in seconds) (optional)end_time=1769464800# int | End time (Unix timestamp in seconds) (optional)limit=100# int | Kline limit (max 500, error if exceeded) (optional)try:
# Query trading symbol klinesapi_response=api_instance.query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_kline: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code
kline_typestrKline type (time period)
begin_timeintStart time (Unix timestamp in seconds)[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
limitintKline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_ticker

TradFiTicker query_symbol_ticker(symbol)

Query trading symbol ticker

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codetry:
# Query trading symbol tickerapi_response=api_instance.query_symbol_ticker(symbol)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_ticker: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_user

CreateUserResp create_trad_fi_user()

Create CFD user

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Create CFD userapi_response=api_instance.create_trad_fi_user()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_user: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_user_assets

UserAssetResp query_user_assets()

Query account assets

Query account assets

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query account assetsapi_response=api_instance.query_user_assets()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_user_assets: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_transaction

TransactionList query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)

Query Fund Transfer In/Out Records

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1704067200# int | Start Time (Second-level Timestamp) (optional)end_time=1706745599# int | End Time (Second-level Timestamp) (optional)type='withdraw'# str | Transaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance) (optional)page=1# int | page number (optional)page_size=20# int | Number per page, default 10, maximum 50 (optional)try:
# Query Fund Transfer In/Out Recordsapi_response=api_instance.query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart Time (Second-level Timestamp)[optional]
end_timeintEnd Time (Second-level Timestamp)[optional]
typestrTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageintpage number[optional]
page_sizeintNumber per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_transaction

CreateTransaction create_transaction(trad_fi_transaction_request)

Fund transfer

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_transaction_request=gate_api.TradFiTransactionRequest() # TradFiTransactionRequest | try:
# Fund transferapi_response=api_instance.create_transaction(trad_fi_transaction_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_transaction_requestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_list

OrderList query_order_list()

Query active order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active order listapi_response=api_instance.query_order_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_order

CreateOrder2 create_trad_fi_order(trad_fi_order_request)

Create order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_order_request=gate_api.TradFiOrderRequest() # TradFiOrderRequest | try:
# Create orderapi_response=api_instance.create_trad_fi_order(trad_fi_order_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_order_requestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_order

UpdateOrder update_order(order_id, trad_fi_order_update_request)

Modify order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtrad_fi_order_update_request=gate_api.TradFiOrderUpdateRequest() # TradFiOrderUpdateRequest | try:
# Modify orderapi_response=api_instance.update_order(order_id, trad_fi_order_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID
trad_fi_order_update_requestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

delete_order

object delete_order(order_id)

Cancel order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtry:
# Cancel orderapi_response=api_instance.delete_order(order_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->delete_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID

Return type

object

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_history_list

OrderHistoryList query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)

Query historical order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1769397000# int | Start time (Unix timestamp in seconds), earliest query is one month ago (optional)end_time=1769398000# int | End time (Unix timestamp in seconds) (optional)symbol='USDCAD'# str | Currency pair (optional)side=2# int | Side (1=sell, 2=buy) (optional)try:
# Query historical order listapi_response=api_instance.query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart time (Unix timestamp in seconds), earliest query is one month ago[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
symbolstrCurrency pair[optional]
sideintSide (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_log

OrderLog query_order_log(log_id)

Get order details by log ID

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
log_id=1223# int | log_id returned from the order placement APItry:
# Get order details by log IDapi_response=api_instance.query_order_log(log_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_log: %s\n"%e)

Parameters

NameTypeDescriptionNotes
log_idintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_list

PositionList query_position_list()

Query active position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active position listapi_response=api_instance.query_position_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_position

UpdatePosition update_position(position_id, trad_fi_position_update_request)

Modify position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_position_update_request=gate_api.TradFiPositionUpdateRequest() # TradFiPositionUpdateRequest | try:
# Modify positionapi_response=api_instance.update_position(position_id, trad_fi_position_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_position_update_requestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

close_position

DeletePosition close_position(position_id, trad_fi_close_position_request)

Close position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_close_position_request=gate_api.TradFiClosePositionRequest() # TradFiClosePositionRequest | try:
# Close positionapi_response=api_instance.close_position(position_id, trad_fi_close_position_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->close_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_close_position_requestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_history_list

PositionHistoryList query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)

Query historical position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
page=1# int | Page number; defaults to 1 if omitted. (optional)page_size=10# int | Page size; defaults to 10 if omitted. Maximum 100. (optional)begin_time=56# int | Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago (optional)end_time=56# int | End time (timestamp in seconds) (optional)symbol='symbol_example'# str | Trading symbol (e.g., EURUSD) (optional)position_dir='position_dir_example'# str | Position direction (Long=long position, Short=short position) (optional)try:
# Query historical position listapi_response=api_instance.query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
pageintPage number; defaults to 1 if omitted.[optional]
page_sizeintPage size; defaults to 10 if omitted. Maximum 100.[optional]
begin_timeintStart Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
end_timeintEnd time (timestamp in seconds)[optional]
symbolstrTrading symbol (e.g., EURUSD)[optional]
position_dirstrPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Latest commit

History

History
1417 lines (1068 loc) · 47.2 KB

File metadata and controls

1417 lines (1068 loc) · 47.2 KB

gate_api.CFDApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
query_mt5_account_infoGET /tradfi/users/mt5-accountQuery MT5 account information
query_categoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
query_symbol_commissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
query_symbolsGET /tradfi/symbolsQuery trading symbol list
query_symbol_detailGET /tradfi/symbols/detailQuery trading symbol details
query_symbol_klineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
query_symbol_tickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
create_trad_fi_userPOST /tradfi/usersCreate CFD user
query_user_assetsGET /tradfi/users/assetsQuery account assets
query_transactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
create_transactionPOST /tradfi/transactionsFund transfer
query_order_listGET /tradfi/ordersQuery active order list
create_trad_fi_orderPOST /tradfi/ordersCreate order
update_orderPUT /tradfi/orders/{order_id}Modify order
delete_orderDELETE /tradfi/orders/{order_id}Cancel order
query_order_history_listGET /tradfi/orders/historyQuery historical order list
query_order_logGET /tradfi/orders/log/{log_id}Get order details by log ID
query_position_listGET /tradfi/positionsQuery active position list
update_positionPUT /tradfi/positions/{position_id}Modify position
close_positionPOST /tradfi/positions/{position_id}/closeClose position
query_position_history_listGET /tradfi/positions/historyQuery historical position list

query_mt5_account_info

Mt5Account query_mt5_account_info()

Query MT5 account information

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query MT5 account informationapi_response=api_instance.query_mt5_account_info()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_mt5_account_info: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_categories

Categories query_categories()

Query trading symbol categories

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol categoriesapi_response=api_instance.query_categories()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_categories: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_commissions

SymbolCommissions query_symbol_commissions(symbols=symbols, category_code=category_code)

Query symbol commission rates

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='AUDUSD,XAUUSD'# str | List of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required (optional)category_code='forex-外汇,metal-金属,index-指数,commodity-大宗商品,stock-股票'# str | List of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required (optional)try:
# Query symbol commission ratesapi_response=api_instance.query_symbol_commissions(symbols=symbols, category_code=category_code)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_commissions: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
category_codestrList of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required[optional]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbols

Symbols query_symbols()

Query trading symbol list

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol listapi_response=api_instance.query_symbols()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbols: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_detail

ContractDetail query_symbol_detail(symbols)

Query trading symbol details

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='EURUSD,XAGUSD'# str | Trading symbol code list (comma-separated, max 10 symbols)try:
# Query trading symbol detailsapi_response=api_instance.query_symbol_detail(symbols)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_kline

Klines query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)

Query trading symbol klines

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codekline_type='1m'# str | Kline type (time period)begin_time=1769378400# int | Start time (Unix timestamp in seconds) (optional)end_time=1769464800# int | End time (Unix timestamp in seconds) (optional)limit=100# int | Kline limit (max 500, error if exceeded) (optional)try:
# Query trading symbol klinesapi_response=api_instance.query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_kline: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code
kline_typestrKline type (time period)
begin_timeintStart time (Unix timestamp in seconds)[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
limitintKline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_ticker

TradFiTicker query_symbol_ticker(symbol)

Query trading symbol ticker

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codetry:
# Query trading symbol tickerapi_response=api_instance.query_symbol_ticker(symbol)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_ticker: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_user

CreateUserResp create_trad_fi_user()

Create CFD user

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Create CFD userapi_response=api_instance.create_trad_fi_user()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_user: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_user_assets

UserAssetResp query_user_assets()

Query account assets

Query account assets

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query account assetsapi_response=api_instance.query_user_assets()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_user_assets: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_transaction

TransactionList query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)

Query Fund Transfer In/Out Records

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1704067200# int | Start Time (Second-level Timestamp) (optional)end_time=1706745599# int | End Time (Second-level Timestamp) (optional)type='withdraw'# str | Transaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance) (optional)page=1# int | page number (optional)page_size=20# int | Number per page, default 10, maximum 50 (optional)try:
# Query Fund Transfer In/Out Recordsapi_response=api_instance.query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart Time (Second-level Timestamp)[optional]
end_timeintEnd Time (Second-level Timestamp)[optional]
typestrTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageintpage number[optional]
page_sizeintNumber per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_transaction

CreateTransaction create_transaction(trad_fi_transaction_request)

Fund transfer

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_transaction_request=gate_api.TradFiTransactionRequest() # TradFiTransactionRequest | try:
# Fund transferapi_response=api_instance.create_transaction(trad_fi_transaction_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_transaction_requestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_list

OrderList query_order_list()

Query active order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active order listapi_response=api_instance.query_order_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_order

CreateOrder2 create_trad_fi_order(trad_fi_order_request)

Create order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_order_request=gate_api.TradFiOrderRequest() # TradFiOrderRequest | try:
# Create orderapi_response=api_instance.create_trad_fi_order(trad_fi_order_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_order_requestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_order

UpdateOrder update_order(order_id, trad_fi_order_update_request)

Modify order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtrad_fi_order_update_request=gate_api.TradFiOrderUpdateRequest() # TradFiOrderUpdateRequest | try:
# Modify orderapi_response=api_instance.update_order(order_id, trad_fi_order_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID
trad_fi_order_update_requestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

delete_order

object delete_order(order_id)

Cancel order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtry:
# Cancel orderapi_response=api_instance.delete_order(order_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->delete_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID

Return type

object

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_history_list

OrderHistoryList query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)

Query historical order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1769397000# int | Start time (Unix timestamp in seconds), earliest query is one month ago (optional)end_time=1769398000# int | End time (Unix timestamp in seconds) (optional)symbol='USDCAD'# str | Currency pair (optional)side=2# int | Side (1=sell, 2=buy) (optional)try:
# Query historical order listapi_response=api_instance.query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart time (Unix timestamp in seconds), earliest query is one month ago[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
symbolstrCurrency pair[optional]
sideintSide (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_log

OrderLog query_order_log(log_id)

Get order details by log ID

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
log_id=1223# int | log_id returned from the order placement APItry:
# Get order details by log IDapi_response=api_instance.query_order_log(log_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_log: %s\n"%e)

Parameters

NameTypeDescriptionNotes
log_idintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_list

PositionList query_position_list()

Query active position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active position listapi_response=api_instance.query_position_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_position

UpdatePosition update_position(position_id, trad_fi_position_update_request)

Modify position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_position_update_request=gate_api.TradFiPositionUpdateRequest() # TradFiPositionUpdateRequest | try:
# Modify positionapi_response=api_instance.update_position(position_id, trad_fi_position_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_position_update_requestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

close_position

DeletePosition close_position(position_id, trad_fi_close_position_request)

Close position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_close_position_request=gate_api.TradFiClosePositionRequest() # TradFiClosePositionRequest | try:
# Close positionapi_response=api_instance.close_position(position_id, trad_fi_close_position_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->close_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_close_position_requestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_history_list

PositionHistoryList query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)

Query historical position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
page=1# int | Page number; defaults to 1 if omitted. (optional)page_size=10# int | Page size; defaults to 10 if omitted. Maximum 100. (optional)begin_time=56# int | Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago (optional)end_time=56# int | End time (timestamp in seconds) (optional)symbol='symbol_example'# str | Trading symbol (e.g., EURUSD) (optional)position_dir='position_dir_example'# str | Position direction (Long=long position, Short=short position) (optional)try:
# Query historical position listapi_response=api_instance.query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
pageintPage number; defaults to 1 if omitted.[optional]
page_sizeintPage size; defaults to 10 if omitted. Maximum 100.[optional]
begin_timeintStart Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
end_timeintEnd time (timestamp in seconds)[optional]
symbolstrTrading symbol (e.g., EURUSD)[optional]
position_dirstrPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

History
1417 lines (1068 loc) · 47.2 KB

File metadata and controls

1417 lines (1068 loc) · 47.2 KB

gate_api.CFDApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
query_mt5_account_infoGET /tradfi/users/mt5-accountQuery MT5 account information
query_categoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
query_symbol_commissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
query_symbolsGET /tradfi/symbolsQuery trading symbol list
query_symbol_detailGET /tradfi/symbols/detailQuery trading symbol details
query_symbol_klineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
query_symbol_tickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
create_trad_fi_userPOST /tradfi/usersCreate CFD user
query_user_assetsGET /tradfi/users/assetsQuery account assets
query_transactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
create_transactionPOST /tradfi/transactionsFund transfer
query_order_listGET /tradfi/ordersQuery active order list
create_trad_fi_orderPOST /tradfi/ordersCreate order
update_orderPUT /tradfi/orders/{order_id}Modify order
delete_orderDELETE /tradfi/orders/{order_id}Cancel order
query_order_history_listGET /tradfi/orders/historyQuery historical order list
query_order_logGET /tradfi/orders/log/{log_id}Get order details by log ID
query_position_listGET /tradfi/positionsQuery active position list
update_positionPUT /tradfi/positions/{position_id}Modify position
close_positionPOST /tradfi/positions/{position_id}/closeClose position
query_position_history_listGET /tradfi/positions/historyQuery historical position list

query_mt5_account_info

Mt5Account query_mt5_account_info()

Query MT5 account information

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query MT5 account informationapi_response=api_instance.query_mt5_account_info()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_mt5_account_info: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_categories

Categories query_categories()

Query trading symbol categories

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol categoriesapi_response=api_instance.query_categories()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_categories: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_commissions

SymbolCommissions query_symbol_commissions(symbols=symbols, category_code=category_code)

Query symbol commission rates

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='AUDUSD,XAUUSD'# str | List of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required (optional)category_code='forex-外汇,metal-金属,index-指数,commodity-大宗商品,stock-股票'# str | List of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required (optional)try:
# Query symbol commission ratesapi_response=api_instance.query_symbol_commissions(symbols=symbols, category_code=category_code)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_commissions: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
category_codestrList of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required[optional]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbols

Symbols query_symbols()

Query trading symbol list

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol listapi_response=api_instance.query_symbols()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbols: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_detail

ContractDetail query_symbol_detail(symbols)

Query trading symbol details

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='EURUSD,XAGUSD'# str | Trading symbol code list (comma-separated, max 10 symbols)try:
# Query trading symbol detailsapi_response=api_instance.query_symbol_detail(symbols)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_kline

Klines query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)

Query trading symbol klines

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codekline_type='1m'# str | Kline type (time period)begin_time=1769378400# int | Start time (Unix timestamp in seconds) (optional)end_time=1769464800# int | End time (Unix timestamp in seconds) (optional)limit=100# int | Kline limit (max 500, error if exceeded) (optional)try:
# Query trading symbol klinesapi_response=api_instance.query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_kline: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code
kline_typestrKline type (time period)
begin_timeintStart time (Unix timestamp in seconds)[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
limitintKline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_ticker

TradFiTicker query_symbol_ticker(symbol)

Query trading symbol ticker

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codetry:
# Query trading symbol tickerapi_response=api_instance.query_symbol_ticker(symbol)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_ticker: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_user

CreateUserResp create_trad_fi_user()

Create CFD user

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Create CFD userapi_response=api_instance.create_trad_fi_user()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_user: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_user_assets

UserAssetResp query_user_assets()

Query account assets

Query account assets

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query account assetsapi_response=api_instance.query_user_assets()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_user_assets: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_transaction

TransactionList query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)

Query Fund Transfer In/Out Records

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1704067200# int | Start Time (Second-level Timestamp) (optional)end_time=1706745599# int | End Time (Second-level Timestamp) (optional)type='withdraw'# str | Transaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance) (optional)page=1# int | page number (optional)page_size=20# int | Number per page, default 10, maximum 50 (optional)try:
# Query Fund Transfer In/Out Recordsapi_response=api_instance.query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart Time (Second-level Timestamp)[optional]
end_timeintEnd Time (Second-level Timestamp)[optional]
typestrTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageintpage number[optional]
page_sizeintNumber per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_transaction

CreateTransaction create_transaction(trad_fi_transaction_request)

Fund transfer

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_transaction_request=gate_api.TradFiTransactionRequest() # TradFiTransactionRequest | try:
# Fund transferapi_response=api_instance.create_transaction(trad_fi_transaction_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_transaction_requestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_list

OrderList query_order_list()

Query active order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active order listapi_response=api_instance.query_order_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_order

CreateOrder2 create_trad_fi_order(trad_fi_order_request)

Create order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_order_request=gate_api.TradFiOrderRequest() # TradFiOrderRequest | try:
# Create orderapi_response=api_instance.create_trad_fi_order(trad_fi_order_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_order_requestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_order

UpdateOrder update_order(order_id, trad_fi_order_update_request)

Modify order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtrad_fi_order_update_request=gate_api.TradFiOrderUpdateRequest() # TradFiOrderUpdateRequest | try:
# Modify orderapi_response=api_instance.update_order(order_id, trad_fi_order_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID
trad_fi_order_update_requestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

delete_order

object delete_order(order_id)

Cancel order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtry:
# Cancel orderapi_response=api_instance.delete_order(order_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->delete_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID

Return type

object

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_history_list

OrderHistoryList query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)

Query historical order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1769397000# int | Start time (Unix timestamp in seconds), earliest query is one month ago (optional)end_time=1769398000# int | End time (Unix timestamp in seconds) (optional)symbol='USDCAD'# str | Currency pair (optional)side=2# int | Side (1=sell, 2=buy) (optional)try:
# Query historical order listapi_response=api_instance.query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart time (Unix timestamp in seconds), earliest query is one month ago[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
symbolstrCurrency pair[optional]
sideintSide (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_log

OrderLog query_order_log(log_id)

Get order details by log ID

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
log_id=1223# int | log_id returned from the order placement APItry:
# Get order details by log IDapi_response=api_instance.query_order_log(log_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_log: %s\n"%e)

Parameters

NameTypeDescriptionNotes
log_idintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_list

PositionList query_position_list()

Query active position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active position listapi_response=api_instance.query_position_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_position

UpdatePosition update_position(position_id, trad_fi_position_update_request)

Modify position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_position_update_request=gate_api.TradFiPositionUpdateRequest() # TradFiPositionUpdateRequest | try:
# Modify positionapi_response=api_instance.update_position(position_id, trad_fi_position_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_position_update_requestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

close_position

DeletePosition close_position(position_id, trad_fi_close_position_request)

Close position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_close_position_request=gate_api.TradFiClosePositionRequest() # TradFiClosePositionRequest | try:
# Close positionapi_response=api_instance.close_position(position_id, trad_fi_close_position_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->close_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_close_position_requestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_history_list

PositionHistoryList query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)

Query historical position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
page=1# int | Page number; defaults to 1 if omitted. (optional)page_size=10# int | Page size; defaults to 10 if omitted. Maximum 100. (optional)begin_time=56# int | Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago (optional)end_time=56# int | End time (timestamp in seconds) (optional)symbol='symbol_example'# str | Trading symbol (e.g., EURUSD) (optional)position_dir='position_dir_example'# str | Position direction (Long=long position, Short=short position) (optional)try:
# Query historical position listapi_response=api_instance.query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
pageintPage number; defaults to 1 if omitted.[optional]
page_sizeintPage size; defaults to 10 if omitted. Maximum 100.[optional]
begin_timeintStart Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
end_timeintEnd time (timestamp in seconds)[optional]
symbolstrTrading symbol (e.g., EURUSD)[optional]
position_dirstrPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

History
1417 lines (1068 loc) · 47.2 KB

File metadata and controls

1417 lines (1068 loc) · 47.2 KB

gate_api.CFDApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
query_mt5_account_infoGET /tradfi/users/mt5-accountQuery MT5 account information
query_categoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
query_symbol_commissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
query_symbolsGET /tradfi/symbolsQuery trading symbol list
query_symbol_detailGET /tradfi/symbols/detailQuery trading symbol details
query_symbol_klineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
query_symbol_tickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
create_trad_fi_userPOST /tradfi/usersCreate CFD user
query_user_assetsGET /tradfi/users/assetsQuery account assets
query_transactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
create_transactionPOST /tradfi/transactionsFund transfer
query_order_listGET /tradfi/ordersQuery active order list
create_trad_fi_orderPOST /tradfi/ordersCreate order
update_orderPUT /tradfi/orders/{order_id}Modify order
delete_orderDELETE /tradfi/orders/{order_id}Cancel order
query_order_history_listGET /tradfi/orders/historyQuery historical order list
query_order_logGET /tradfi/orders/log/{log_id}Get order details by log ID
query_position_listGET /tradfi/positionsQuery active position list
update_positionPUT /tradfi/positions/{position_id}Modify position
close_positionPOST /tradfi/positions/{position_id}/closeClose position
query_position_history_listGET /tradfi/positions/historyQuery historical position list

query_mt5_account_info

Mt5Account query_mt5_account_info()

Query MT5 account information

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query MT5 account informationapi_response=api_instance.query_mt5_account_info()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_mt5_account_info: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_categories

Categories query_categories()

Query trading symbol categories

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol categoriesapi_response=api_instance.query_categories()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_categories: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_commissions

SymbolCommissions query_symbol_commissions(symbols=symbols, category_code=category_code)

Query symbol commission rates

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='AUDUSD,XAUUSD'# str | List of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required (optional)category_code='forex-外汇,metal-金属,index-指数,commodity-大宗商品,stock-股票'# str | List of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required (optional)try:
# Query symbol commission ratesapi_response=api_instance.query_symbol_commissions(symbols=symbols, category_code=category_code)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_commissions: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
category_codestrList of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required[optional]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbols

Symbols query_symbols()

Query trading symbol list

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol listapi_response=api_instance.query_symbols()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbols: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_detail

ContractDetail query_symbol_detail(symbols)

Query trading symbol details

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='EURUSD,XAGUSD'# str | Trading symbol code list (comma-separated, max 10 symbols)try:
# Query trading symbol detailsapi_response=api_instance.query_symbol_detail(symbols)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_kline

Klines query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)

Query trading symbol klines

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codekline_type='1m'# str | Kline type (time period)begin_time=1769378400# int | Start time (Unix timestamp in seconds) (optional)end_time=1769464800# int | End time (Unix timestamp in seconds) (optional)limit=100# int | Kline limit (max 500, error if exceeded) (optional)try:
# Query trading symbol klinesapi_response=api_instance.query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_kline: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code
kline_typestrKline type (time period)
begin_timeintStart time (Unix timestamp in seconds)[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
limitintKline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_ticker

TradFiTicker query_symbol_ticker(symbol)

Query trading symbol ticker

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codetry:
# Query trading symbol tickerapi_response=api_instance.query_symbol_ticker(symbol)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_ticker: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_user

CreateUserResp create_trad_fi_user()

Create CFD user

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Create CFD userapi_response=api_instance.create_trad_fi_user()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_user: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_user_assets

UserAssetResp query_user_assets()

Query account assets

Query account assets

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query account assetsapi_response=api_instance.query_user_assets()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_user_assets: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_transaction

TransactionList query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)

Query Fund Transfer In/Out Records

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1704067200# int | Start Time (Second-level Timestamp) (optional)end_time=1706745599# int | End Time (Second-level Timestamp) (optional)type='withdraw'# str | Transaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance) (optional)page=1# int | page number (optional)page_size=20# int | Number per page, default 10, maximum 50 (optional)try:
# Query Fund Transfer In/Out Recordsapi_response=api_instance.query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart Time (Second-level Timestamp)[optional]
end_timeintEnd Time (Second-level Timestamp)[optional]
typestrTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageintpage number[optional]
page_sizeintNumber per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_transaction

CreateTransaction create_transaction(trad_fi_transaction_request)

Fund transfer

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_transaction_request=gate_api.TradFiTransactionRequest() # TradFiTransactionRequest | try:
# Fund transferapi_response=api_instance.create_transaction(trad_fi_transaction_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_transaction_requestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_list

OrderList query_order_list()

Query active order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active order listapi_response=api_instance.query_order_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_order

CreateOrder2 create_trad_fi_order(trad_fi_order_request)

Create order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_order_request=gate_api.TradFiOrderRequest() # TradFiOrderRequest | try:
# Create orderapi_response=api_instance.create_trad_fi_order(trad_fi_order_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_order_requestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_order

UpdateOrder update_order(order_id, trad_fi_order_update_request)

Modify order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtrad_fi_order_update_request=gate_api.TradFiOrderUpdateRequest() # TradFiOrderUpdateRequest | try:
# Modify orderapi_response=api_instance.update_order(order_id, trad_fi_order_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID
trad_fi_order_update_requestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

delete_order

object delete_order(order_id)

Cancel order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtry:
# Cancel orderapi_response=api_instance.delete_order(order_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->delete_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID

Return type

object

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_history_list

OrderHistoryList query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)

Query historical order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1769397000# int | Start time (Unix timestamp in seconds), earliest query is one month ago (optional)end_time=1769398000# int | End time (Unix timestamp in seconds) (optional)symbol='USDCAD'# str | Currency pair (optional)side=2# int | Side (1=sell, 2=buy) (optional)try:
# Query historical order listapi_response=api_instance.query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart time (Unix timestamp in seconds), earliest query is one month ago[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
symbolstrCurrency pair[optional]
sideintSide (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_log

OrderLog query_order_log(log_id)

Get order details by log ID

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
log_id=1223# int | log_id returned from the order placement APItry:
# Get order details by log IDapi_response=api_instance.query_order_log(log_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_log: %s\n"%e)

Parameters

NameTypeDescriptionNotes
log_idintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_list

PositionList query_position_list()

Query active position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active position listapi_response=api_instance.query_position_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_position

UpdatePosition update_position(position_id, trad_fi_position_update_request)

Modify position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_position_update_request=gate_api.TradFiPositionUpdateRequest() # TradFiPositionUpdateRequest | try:
# Modify positionapi_response=api_instance.update_position(position_id, trad_fi_position_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_position_update_requestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

close_position

DeletePosition close_position(position_id, trad_fi_close_position_request)

Close position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_close_position_request=gate_api.TradFiClosePositionRequest() # TradFiClosePositionRequest | try:
# Close positionapi_response=api_instance.close_position(position_id, trad_fi_close_position_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->close_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_close_position_requestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_history_list

PositionHistoryList query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)

Query historical position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
page=1# int | Page number; defaults to 1 if omitted. (optional)page_size=10# int | Page size; defaults to 10 if omitted. Maximum 100. (optional)begin_time=56# int | Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago (optional)end_time=56# int | End time (timestamp in seconds) (optional)symbol='symbol_example'# str | Trading symbol (e.g., EURUSD) (optional)position_dir='position_dir_example'# str | Position direction (Long=long position, Short=short position) (optional)try:
# Query historical position listapi_response=api_instance.query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
pageintPage number; defaults to 1 if omitted.[optional]
page_sizeintPage size; defaults to 10 if omitted. Maximum 100.[optional]
begin_timeintStart Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
end_timeintEnd time (timestamp in seconds)[optional]
symbolstrTrading symbol (e.g., EURUSD)[optional]
position_dirstrPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Latest commit

History

History
1417 lines (1068 loc) · 47.2 KB

File metadata and controls

1417 lines (1068 loc) · 47.2 KB

gate_api.CFDApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
query_mt5_account_infoGET /tradfi/users/mt5-accountQuery MT5 account information
query_categoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
query_symbol_commissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
query_symbolsGET /tradfi/symbolsQuery trading symbol list
query_symbol_detailGET /tradfi/symbols/detailQuery trading symbol details
query_symbol_klineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
query_symbol_tickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
create_trad_fi_userPOST /tradfi/usersCreate CFD user
query_user_assetsGET /tradfi/users/assetsQuery account assets
query_transactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
create_transactionPOST /tradfi/transactionsFund transfer
query_order_listGET /tradfi/ordersQuery active order list
create_trad_fi_orderPOST /tradfi/ordersCreate order
update_orderPUT /tradfi/orders/{order_id}Modify order
delete_orderDELETE /tradfi/orders/{order_id}Cancel order
query_order_history_listGET /tradfi/orders/historyQuery historical order list
query_order_logGET /tradfi/orders/log/{log_id}Get order details by log ID
query_position_listGET /tradfi/positionsQuery active position list
update_positionPUT /tradfi/positions/{position_id}Modify position
close_positionPOST /tradfi/positions/{position_id}/closeClose position
query_position_history_listGET /tradfi/positions/historyQuery historical position list

query_mt5_account_info

Mt5Account query_mt5_account_info()

Query MT5 account information

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query MT5 account informationapi_response=api_instance.query_mt5_account_info()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_mt5_account_info: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_categories

Categories query_categories()

Query trading symbol categories

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol categoriesapi_response=api_instance.query_categories()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_categories: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_commissions

SymbolCommissions query_symbol_commissions(symbols=symbols, category_code=category_code)

Query symbol commission rates

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='AUDUSD,XAUUSD'# str | List of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required (optional)category_code='forex-外汇,metal-金属,index-指数,commodity-大宗商品,stock-股票'# str | List of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required (optional)try:
# Query symbol commission ratesapi_response=api_instance.query_symbol_commissions(symbols=symbols, category_code=category_code)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_commissions: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
category_codestrList of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required[optional]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbols

Symbols query_symbols()

Query trading symbol list

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol listapi_response=api_instance.query_symbols()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbols: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_detail

ContractDetail query_symbol_detail(symbols)

Query trading symbol details

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='EURUSD,XAGUSD'# str | Trading symbol code list (comma-separated, max 10 symbols)try:
# Query trading symbol detailsapi_response=api_instance.query_symbol_detail(symbols)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_kline

Klines query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)

Query trading symbol klines

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codekline_type='1m'# str | Kline type (time period)begin_time=1769378400# int | Start time (Unix timestamp in seconds) (optional)end_time=1769464800# int | End time (Unix timestamp in seconds) (optional)limit=100# int | Kline limit (max 500, error if exceeded) (optional)try:
# Query trading symbol klinesapi_response=api_instance.query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_kline: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code
kline_typestrKline type (time period)
begin_timeintStart time (Unix timestamp in seconds)[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
limitintKline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_ticker

TradFiTicker query_symbol_ticker(symbol)

Query trading symbol ticker

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codetry:
# Query trading symbol tickerapi_response=api_instance.query_symbol_ticker(symbol)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_ticker: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_user

CreateUserResp create_trad_fi_user()

Create CFD user

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Create CFD userapi_response=api_instance.create_trad_fi_user()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_user: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_user_assets

UserAssetResp query_user_assets()

Query account assets

Query account assets

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query account assetsapi_response=api_instance.query_user_assets()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_user_assets: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_transaction

TransactionList query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)

Query Fund Transfer In/Out Records

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1704067200# int | Start Time (Second-level Timestamp) (optional)end_time=1706745599# int | End Time (Second-level Timestamp) (optional)type='withdraw'# str | Transaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance) (optional)page=1# int | page number (optional)page_size=20# int | Number per page, default 10, maximum 50 (optional)try:
# Query Fund Transfer In/Out Recordsapi_response=api_instance.query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart Time (Second-level Timestamp)[optional]
end_timeintEnd Time (Second-level Timestamp)[optional]
typestrTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageintpage number[optional]
page_sizeintNumber per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_transaction

CreateTransaction create_transaction(trad_fi_transaction_request)

Fund transfer

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_transaction_request=gate_api.TradFiTransactionRequest() # TradFiTransactionRequest | try:
# Fund transferapi_response=api_instance.create_transaction(trad_fi_transaction_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_transaction_requestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_list

OrderList query_order_list()

Query active order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active order listapi_response=api_instance.query_order_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_order

CreateOrder2 create_trad_fi_order(trad_fi_order_request)

Create order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_order_request=gate_api.TradFiOrderRequest() # TradFiOrderRequest | try:
# Create orderapi_response=api_instance.create_trad_fi_order(trad_fi_order_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_order_requestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_order

UpdateOrder update_order(order_id, trad_fi_order_update_request)

Modify order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtrad_fi_order_update_request=gate_api.TradFiOrderUpdateRequest() # TradFiOrderUpdateRequest | try:
# Modify orderapi_response=api_instance.update_order(order_id, trad_fi_order_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID
trad_fi_order_update_requestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

delete_order

object delete_order(order_id)

Cancel order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtry:
# Cancel orderapi_response=api_instance.delete_order(order_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->delete_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID

Return type

object

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_history_list

OrderHistoryList query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)

Query historical order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1769397000# int | Start time (Unix timestamp in seconds), earliest query is one month ago (optional)end_time=1769398000# int | End time (Unix timestamp in seconds) (optional)symbol='USDCAD'# str | Currency pair (optional)side=2# int | Side (1=sell, 2=buy) (optional)try:
# Query historical order listapi_response=api_instance.query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart time (Unix timestamp in seconds), earliest query is one month ago[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
symbolstrCurrency pair[optional]
sideintSide (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_log

OrderLog query_order_log(log_id)

Get order details by log ID

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
log_id=1223# int | log_id returned from the order placement APItry:
# Get order details by log IDapi_response=api_instance.query_order_log(log_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_log: %s\n"%e)

Parameters

NameTypeDescriptionNotes
log_idintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_list

PositionList query_position_list()

Query active position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active position listapi_response=api_instance.query_position_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_position

UpdatePosition update_position(position_id, trad_fi_position_update_request)

Modify position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_position_update_request=gate_api.TradFiPositionUpdateRequest() # TradFiPositionUpdateRequest | try:
# Modify positionapi_response=api_instance.update_position(position_id, trad_fi_position_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_position_update_requestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

close_position

DeletePosition close_position(position_id, trad_fi_close_position_request)

Close position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_close_position_request=gate_api.TradFiClosePositionRequest() # TradFiClosePositionRequest | try:
# Close positionapi_response=api_instance.close_position(position_id, trad_fi_close_position_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->close_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_close_position_requestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_history_list

PositionHistoryList query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)

Query historical position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
page=1# int | Page number; defaults to 1 if omitted. (optional)page_size=10# int | Page size; defaults to 10 if omitted. Maximum 100. (optional)begin_time=56# int | Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago (optional)end_time=56# int | End time (timestamp in seconds) (optional)symbol='symbol_example'# str | Trading symbol (e.g., EURUSD) (optional)position_dir='position_dir_example'# str | Position direction (Long=long position, Short=short position) (optional)try:
# Query historical position listapi_response=api_instance.query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
pageintPage number; defaults to 1 if omitted.[optional]
page_sizeintPage size; defaults to 10 if omitted. Maximum 100.[optional]
begin_timeintStart Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
end_timeintEnd time (timestamp in seconds)[optional]
symbolstrTrading symbol (e.g., EURUSD)[optional]
position_dirstrPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

History
1417 lines (1068 loc) · 47.2 KB

File metadata and controls

1417 lines (1068 loc) · 47.2 KB

gate_api.CFDApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
query_mt5_account_infoGET /tradfi/users/mt5-accountQuery MT5 account information
query_categoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
query_symbol_commissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
query_symbolsGET /tradfi/symbolsQuery trading symbol list
query_symbol_detailGET /tradfi/symbols/detailQuery trading symbol details
query_symbol_klineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
query_symbol_tickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
create_trad_fi_userPOST /tradfi/usersCreate CFD user
query_user_assetsGET /tradfi/users/assetsQuery account assets
query_transactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
create_transactionPOST /tradfi/transactionsFund transfer
query_order_listGET /tradfi/ordersQuery active order list
create_trad_fi_orderPOST /tradfi/ordersCreate order
update_orderPUT /tradfi/orders/{order_id}Modify order
delete_orderDELETE /tradfi/orders/{order_id}Cancel order
query_order_history_listGET /tradfi/orders/historyQuery historical order list
query_order_logGET /tradfi/orders/log/{log_id}Get order details by log ID
query_position_listGET /tradfi/positionsQuery active position list
update_positionPUT /tradfi/positions/{position_id}Modify position
close_positionPOST /tradfi/positions/{position_id}/closeClose position
query_position_history_listGET /tradfi/positions/historyQuery historical position list

query_mt5_account_info

Mt5Account query_mt5_account_info()

Query MT5 account information

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query MT5 account informationapi_response=api_instance.query_mt5_account_info()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_mt5_account_info: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_categories

Categories query_categories()

Query trading symbol categories

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol categoriesapi_response=api_instance.query_categories()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_categories: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_commissions

SymbolCommissions query_symbol_commissions(symbols=symbols, category_code=category_code)

Query symbol commission rates

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='AUDUSD,XAUUSD'# str | List of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required (optional)category_code='forex-外汇,metal-金属,index-指数,commodity-大宗商品,stock-股票'# str | List of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required (optional)try:
# Query symbol commission ratesapi_response=api_instance.query_symbol_commissions(symbols=symbols, category_code=category_code)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_commissions: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
category_codestrList of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required[optional]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbols

Symbols query_symbols()

Query trading symbol list

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol listapi_response=api_instance.query_symbols()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbols: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_detail

ContractDetail query_symbol_detail(symbols)

Query trading symbol details

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='EURUSD,XAGUSD'# str | Trading symbol code list (comma-separated, max 10 symbols)try:
# Query trading symbol detailsapi_response=api_instance.query_symbol_detail(symbols)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_kline

Klines query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)

Query trading symbol klines

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codekline_type='1m'# str | Kline type (time period)begin_time=1769378400# int | Start time (Unix timestamp in seconds) (optional)end_time=1769464800# int | End time (Unix timestamp in seconds) (optional)limit=100# int | Kline limit (max 500, error if exceeded) (optional)try:
# Query trading symbol klinesapi_response=api_instance.query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_kline: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code
kline_typestrKline type (time period)
begin_timeintStart time (Unix timestamp in seconds)[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
limitintKline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_ticker

TradFiTicker query_symbol_ticker(symbol)

Query trading symbol ticker

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codetry:
# Query trading symbol tickerapi_response=api_instance.query_symbol_ticker(symbol)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_ticker: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_user

CreateUserResp create_trad_fi_user()

Create CFD user

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Create CFD userapi_response=api_instance.create_trad_fi_user()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_user: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_user_assets

UserAssetResp query_user_assets()

Query account assets

Query account assets

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query account assetsapi_response=api_instance.query_user_assets()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_user_assets: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_transaction

TransactionList query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)

Query Fund Transfer In/Out Records

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1704067200# int | Start Time (Second-level Timestamp) (optional)end_time=1706745599# int | End Time (Second-level Timestamp) (optional)type='withdraw'# str | Transaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance) (optional)page=1# int | page number (optional)page_size=20# int | Number per page, default 10, maximum 50 (optional)try:
# Query Fund Transfer In/Out Recordsapi_response=api_instance.query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart Time (Second-level Timestamp)[optional]
end_timeintEnd Time (Second-level Timestamp)[optional]
typestrTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageintpage number[optional]
page_sizeintNumber per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_transaction

CreateTransaction create_transaction(trad_fi_transaction_request)

Fund transfer

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_transaction_request=gate_api.TradFiTransactionRequest() # TradFiTransactionRequest | try:
# Fund transferapi_response=api_instance.create_transaction(trad_fi_transaction_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_transaction_requestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_list

OrderList query_order_list()

Query active order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active order listapi_response=api_instance.query_order_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_order

CreateOrder2 create_trad_fi_order(trad_fi_order_request)

Create order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_order_request=gate_api.TradFiOrderRequest() # TradFiOrderRequest | try:
# Create orderapi_response=api_instance.create_trad_fi_order(trad_fi_order_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_order_requestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_order

UpdateOrder update_order(order_id, trad_fi_order_update_request)

Modify order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtrad_fi_order_update_request=gate_api.TradFiOrderUpdateRequest() # TradFiOrderUpdateRequest | try:
# Modify orderapi_response=api_instance.update_order(order_id, trad_fi_order_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID
trad_fi_order_update_requestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

delete_order

object delete_order(order_id)

Cancel order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtry:
# Cancel orderapi_response=api_instance.delete_order(order_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->delete_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID

Return type

object

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_history_list

OrderHistoryList query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)

Query historical order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1769397000# int | Start time (Unix timestamp in seconds), earliest query is one month ago (optional)end_time=1769398000# int | End time (Unix timestamp in seconds) (optional)symbol='USDCAD'# str | Currency pair (optional)side=2# int | Side (1=sell, 2=buy) (optional)try:
# Query historical order listapi_response=api_instance.query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart time (Unix timestamp in seconds), earliest query is one month ago[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
symbolstrCurrency pair[optional]
sideintSide (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_log

OrderLog query_order_log(log_id)

Get order details by log ID

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
log_id=1223# int | log_id returned from the order placement APItry:
# Get order details by log IDapi_response=api_instance.query_order_log(log_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_log: %s\n"%e)

Parameters

NameTypeDescriptionNotes
log_idintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_list

PositionList query_position_list()

Query active position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active position listapi_response=api_instance.query_position_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_position

UpdatePosition update_position(position_id, trad_fi_position_update_request)

Modify position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_position_update_request=gate_api.TradFiPositionUpdateRequest() # TradFiPositionUpdateRequest | try:
# Modify positionapi_response=api_instance.update_position(position_id, trad_fi_position_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_position_update_requestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

close_position

DeletePosition close_position(position_id, trad_fi_close_position_request)

Close position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_close_position_request=gate_api.TradFiClosePositionRequest() # TradFiClosePositionRequest | try:
# Close positionapi_response=api_instance.close_position(position_id, trad_fi_close_position_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->close_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_close_position_requestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_history_list

PositionHistoryList query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)

Query historical position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
page=1# int | Page number; defaults to 1 if omitted. (optional)page_size=10# int | Page size; defaults to 10 if omitted. Maximum 100. (optional)begin_time=56# int | Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago (optional)end_time=56# int | End time (timestamp in seconds) (optional)symbol='symbol_example'# str | Trading symbol (e.g., EURUSD) (optional)position_dir='position_dir_example'# str | Position direction (Long=long position, Short=short position) (optional)try:
# Query historical position listapi_response=api_instance.query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
pageintPage number; defaults to 1 if omitted.[optional]
page_sizeintPage size; defaults to 10 if omitted. Maximum 100.[optional]
begin_timeintStart Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
end_timeintEnd time (timestamp in seconds)[optional]
symbolstrTrading symbol (e.g., EURUSD)[optional]
position_dirstrPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

History
1417 lines (1068 loc) · 47.2 KB

File metadata and controls

1417 lines (1068 loc) · 47.2 KB

gate_api.CFDApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
query_mt5_account_infoGET /tradfi/users/mt5-accountQuery MT5 account information
query_categoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
query_symbol_commissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
query_symbolsGET /tradfi/symbolsQuery trading symbol list
query_symbol_detailGET /tradfi/symbols/detailQuery trading symbol details
query_symbol_klineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
query_symbol_tickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
create_trad_fi_userPOST /tradfi/usersCreate CFD user
query_user_assetsGET /tradfi/users/assetsQuery account assets
query_transactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
create_transactionPOST /tradfi/transactionsFund transfer
query_order_listGET /tradfi/ordersQuery active order list
create_trad_fi_orderPOST /tradfi/ordersCreate order
update_orderPUT /tradfi/orders/{order_id}Modify order
delete_orderDELETE /tradfi/orders/{order_id}Cancel order
query_order_history_listGET /tradfi/orders/historyQuery historical order list
query_order_logGET /tradfi/orders/log/{log_id}Get order details by log ID
query_position_listGET /tradfi/positionsQuery active position list
update_positionPUT /tradfi/positions/{position_id}Modify position
close_positionPOST /tradfi/positions/{position_id}/closeClose position
query_position_history_listGET /tradfi/positions/historyQuery historical position list

query_mt5_account_info

Mt5Account query_mt5_account_info()

Query MT5 account information

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query MT5 account informationapi_response=api_instance.query_mt5_account_info()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_mt5_account_info: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_categories

Categories query_categories()

Query trading symbol categories

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol categoriesapi_response=api_instance.query_categories()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_categories: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_commissions

SymbolCommissions query_symbol_commissions(symbols=symbols, category_code=category_code)

Query symbol commission rates

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='AUDUSD,XAUUSD'# str | List of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required (optional)category_code='forex-外汇,metal-金属,index-指数,commodity-大宗商品,stock-股票'# str | List of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required (optional)try:
# Query symbol commission ratesapi_response=api_instance.query_symbol_commissions(symbols=symbols, category_code=category_code)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_commissions: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
category_codestrList of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required[optional]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbols

Symbols query_symbols()

Query trading symbol list

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol listapi_response=api_instance.query_symbols()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbols: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_detail

ContractDetail query_symbol_detail(symbols)

Query trading symbol details

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='EURUSD,XAGUSD'# str | Trading symbol code list (comma-separated, max 10 symbols)try:
# Query trading symbol detailsapi_response=api_instance.query_symbol_detail(symbols)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_kline

Klines query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)

Query trading symbol klines

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codekline_type='1m'# str | Kline type (time period)begin_time=1769378400# int | Start time (Unix timestamp in seconds) (optional)end_time=1769464800# int | End time (Unix timestamp in seconds) (optional)limit=100# int | Kline limit (max 500, error if exceeded) (optional)try:
# Query trading symbol klinesapi_response=api_instance.query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_kline: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code
kline_typestrKline type (time period)
begin_timeintStart time (Unix timestamp in seconds)[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
limitintKline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_ticker

TradFiTicker query_symbol_ticker(symbol)

Query trading symbol ticker

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codetry:
# Query trading symbol tickerapi_response=api_instance.query_symbol_ticker(symbol)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_ticker: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_user

CreateUserResp create_trad_fi_user()

Create CFD user

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Create CFD userapi_response=api_instance.create_trad_fi_user()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_user: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_user_assets

UserAssetResp query_user_assets()

Query account assets

Query account assets

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query account assetsapi_response=api_instance.query_user_assets()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_user_assets: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_transaction

TransactionList query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)

Query Fund Transfer In/Out Records

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1704067200# int | Start Time (Second-level Timestamp) (optional)end_time=1706745599# int | End Time (Second-level Timestamp) (optional)type='withdraw'# str | Transaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance) (optional)page=1# int | page number (optional)page_size=20# int | Number per page, default 10, maximum 50 (optional)try:
# Query Fund Transfer In/Out Recordsapi_response=api_instance.query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart Time (Second-level Timestamp)[optional]
end_timeintEnd Time (Second-level Timestamp)[optional]
typestrTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageintpage number[optional]
page_sizeintNumber per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_transaction

CreateTransaction create_transaction(trad_fi_transaction_request)

Fund transfer

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_transaction_request=gate_api.TradFiTransactionRequest() # TradFiTransactionRequest | try:
# Fund transferapi_response=api_instance.create_transaction(trad_fi_transaction_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_transaction_requestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_list

OrderList query_order_list()

Query active order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active order listapi_response=api_instance.query_order_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_order

CreateOrder2 create_trad_fi_order(trad_fi_order_request)

Create order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_order_request=gate_api.TradFiOrderRequest() # TradFiOrderRequest | try:
# Create orderapi_response=api_instance.create_trad_fi_order(trad_fi_order_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_order_requestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_order

UpdateOrder update_order(order_id, trad_fi_order_update_request)

Modify order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtrad_fi_order_update_request=gate_api.TradFiOrderUpdateRequest() # TradFiOrderUpdateRequest | try:
# Modify orderapi_response=api_instance.update_order(order_id, trad_fi_order_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID
trad_fi_order_update_requestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

delete_order

object delete_order(order_id)

Cancel order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtry:
# Cancel orderapi_response=api_instance.delete_order(order_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->delete_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID

Return type

object

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_history_list

OrderHistoryList query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)

Query historical order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1769397000# int | Start time (Unix timestamp in seconds), earliest query is one month ago (optional)end_time=1769398000# int | End time (Unix timestamp in seconds) (optional)symbol='USDCAD'# str | Currency pair (optional)side=2# int | Side (1=sell, 2=buy) (optional)try:
# Query historical order listapi_response=api_instance.query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart time (Unix timestamp in seconds), earliest query is one month ago[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
symbolstrCurrency pair[optional]
sideintSide (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_log

OrderLog query_order_log(log_id)

Get order details by log ID

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
log_id=1223# int | log_id returned from the order placement APItry:
# Get order details by log IDapi_response=api_instance.query_order_log(log_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_log: %s\n"%e)

Parameters

NameTypeDescriptionNotes
log_idintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_list

PositionList query_position_list()

Query active position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active position listapi_response=api_instance.query_position_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_position

UpdatePosition update_position(position_id, trad_fi_position_update_request)

Modify position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_position_update_request=gate_api.TradFiPositionUpdateRequest() # TradFiPositionUpdateRequest | try:
# Modify positionapi_response=api_instance.update_position(position_id, trad_fi_position_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_position_update_requestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

close_position

DeletePosition close_position(position_id, trad_fi_close_position_request)

Close position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_close_position_request=gate_api.TradFiClosePositionRequest() # TradFiClosePositionRequest | try:
# Close positionapi_response=api_instance.close_position(position_id, trad_fi_close_position_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->close_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_close_position_requestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_history_list

PositionHistoryList query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)

Query historical position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
page=1# int | Page number; defaults to 1 if omitted. (optional)page_size=10# int | Page size; defaults to 10 if omitted. Maximum 100. (optional)begin_time=56# int | Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago (optional)end_time=56# int | End time (timestamp in seconds) (optional)symbol='symbol_example'# str | Trading symbol (e.g., EURUSD) (optional)position_dir='position_dir_example'# str | Position direction (Long=long position, Short=short position) (optional)try:
# Query historical position listapi_response=api_instance.query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
pageintPage number; defaults to 1 if omitted.[optional]
page_sizeintPage size; defaults to 10 if omitted. Maximum 100.[optional]
begin_timeintStart Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
end_timeintEnd time (timestamp in seconds)[optional]
symbolstrTrading symbol (e.g., EURUSD)[optional]
position_dirstrPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Latest commit

History

History
1417 lines (1068 loc) · 47.2 KB

File metadata and controls

1417 lines (1068 loc) · 47.2 KB

gate_api.CFDApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
query_mt5_account_infoGET /tradfi/users/mt5-accountQuery MT5 account information
query_categoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
query_symbol_commissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
query_symbolsGET /tradfi/symbolsQuery trading symbol list
query_symbol_detailGET /tradfi/symbols/detailQuery trading symbol details
query_symbol_klineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
query_symbol_tickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
create_trad_fi_userPOST /tradfi/usersCreate CFD user
query_user_assetsGET /tradfi/users/assetsQuery account assets
query_transactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
create_transactionPOST /tradfi/transactionsFund transfer
query_order_listGET /tradfi/ordersQuery active order list
create_trad_fi_orderPOST /tradfi/ordersCreate order
update_orderPUT /tradfi/orders/{order_id}Modify order
delete_orderDELETE /tradfi/orders/{order_id}Cancel order
query_order_history_listGET /tradfi/orders/historyQuery historical order list
query_order_logGET /tradfi/orders/log/{log_id}Get order details by log ID
query_position_listGET /tradfi/positionsQuery active position list
update_positionPUT /tradfi/positions/{position_id}Modify position
close_positionPOST /tradfi/positions/{position_id}/closeClose position
query_position_history_listGET /tradfi/positions/historyQuery historical position list

query_mt5_account_info

Mt5Account query_mt5_account_info()

Query MT5 account information

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query MT5 account informationapi_response=api_instance.query_mt5_account_info()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_mt5_account_info: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_categories

Categories query_categories()

Query trading symbol categories

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol categoriesapi_response=api_instance.query_categories()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_categories: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_commissions

SymbolCommissions query_symbol_commissions(symbols=symbols, category_code=category_code)

Query symbol commission rates

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='AUDUSD,XAUUSD'# str | List of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required (optional)category_code='forex-外汇,metal-金属,index-指数,commodity-大宗商品,stock-股票'# str | List of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required (optional)try:
# Query symbol commission ratesapi_response=api_instance.query_symbol_commissions(symbols=symbols, category_code=category_code)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_commissions: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
category_codestrList of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required[optional]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbols

Symbols query_symbols()

Query trading symbol list

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query trading symbol listapi_response=api_instance.query_symbols()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbols: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_detail

ContractDetail query_symbol_detail(symbols)

Query trading symbol details

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbols='EURUSD,XAGUSD'# str | Trading symbol code list (comma-separated, max 10 symbols)try:
# Query trading symbol detailsapi_response=api_instance.query_symbol_detail(symbols)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolsstrTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_kline

Klines query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)

Query trading symbol klines

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codekline_type='1m'# str | Kline type (time period)begin_time=1769378400# int | Start time (Unix timestamp in seconds) (optional)end_time=1769464800# int | End time (Unix timestamp in seconds) (optional)limit=100# int | Kline limit (max 500, error if exceeded) (optional)try:
# Query trading symbol klinesapi_response=api_instance.query_symbol_kline(symbol, kline_type, begin_time=begin_time, end_time=end_time, limit=limit)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_kline: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code
kline_typestrKline type (time period)
begin_timeintStart time (Unix timestamp in seconds)[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
limitintKline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_symbol_ticker

TradFiTicker query_symbol_ticker(symbol)

Query trading symbol ticker

Example

from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 classapi_instance=gate_api.CFDApi(api_client)
symbol='EURUSD'# str | Trading symbol codetry:
# Query trading symbol tickerapi_response=api_instance.query_symbol_ticker(symbol)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_symbol_ticker: %s\n"%e)

Parameters

NameTypeDescriptionNotes
symbolstrTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_user

CreateUserResp create_trad_fi_user()

Create CFD user

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Create CFD userapi_response=api_instance.create_trad_fi_user()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_user: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_user_assets

UserAssetResp query_user_assets()

Query account assets

Query account assets

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query account assetsapi_response=api_instance.query_user_assets()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_user_assets: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_transaction

TransactionList query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)

Query Fund Transfer In/Out Records

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1704067200# int | Start Time (Second-level Timestamp) (optional)end_time=1706745599# int | End Time (Second-level Timestamp) (optional)type='withdraw'# str | Transaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance) (optional)page=1# int | page number (optional)page_size=20# int | Number per page, default 10, maximum 50 (optional)try:
# Query Fund Transfer In/Out Recordsapi_response=api_instance.query_transaction(begin_time=begin_time, end_time=end_time, type=type, page=page, page_size=page_size)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart Time (Second-level Timestamp)[optional]
end_timeintEnd Time (Second-level Timestamp)[optional]
typestrTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageintpage number[optional]
page_sizeintNumber per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_transaction

CreateTransaction create_transaction(trad_fi_transaction_request)

Fund transfer

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_transaction_request=gate_api.TradFiTransactionRequest() # TradFiTransactionRequest | try:
# Fund transferapi_response=api_instance.create_transaction(trad_fi_transaction_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_transaction: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_transaction_requestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_list

OrderList query_order_list()

Query active order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active order listapi_response=api_instance.query_order_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

create_trad_fi_order

CreateOrder2 create_trad_fi_order(trad_fi_order_request)

Create order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
trad_fi_order_request=gate_api.TradFiOrderRequest() # TradFiOrderRequest | try:
# Create orderapi_response=api_instance.create_trad_fi_order(trad_fi_order_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->create_trad_fi_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
trad_fi_order_requestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_order

UpdateOrder update_order(order_id, trad_fi_order_update_request)

Modify order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtrad_fi_order_update_request=gate_api.TradFiOrderUpdateRequest() # TradFiOrderUpdateRequest | try:
# Modify orderapi_response=api_instance.update_order(order_id, trad_fi_order_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID
trad_fi_order_update_requestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

delete_order

object delete_order(order_id)

Cancel order

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
order_id=1223# int | Order IDtry:
# Cancel orderapi_response=api_instance.delete_order(order_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->delete_order: %s\n"%e)

Parameters

NameTypeDescriptionNotes
order_idintOrder ID

Return type

object

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_history_list

OrderHistoryList query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)

Query historical order list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
begin_time=1769397000# int | Start time (Unix timestamp in seconds), earliest query is one month ago (optional)end_time=1769398000# int | End time (Unix timestamp in seconds) (optional)symbol='USDCAD'# str | Currency pair (optional)side=2# int | Side (1=sell, 2=buy) (optional)try:
# Query historical order listapi_response=api_instance.query_order_history_list(begin_time=begin_time, end_time=end_time, symbol=symbol, side=side)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
begin_timeintStart time (Unix timestamp in seconds), earliest query is one month ago[optional]
end_timeintEnd time (Unix timestamp in seconds)[optional]
symbolstrCurrency pair[optional]
sideintSide (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_order_log

OrderLog query_order_log(log_id)

Get order details by log ID

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
log_id=1223# int | log_id returned from the order placement APItry:
# Get order details by log IDapi_response=api_instance.query_order_log(log_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_order_log: %s\n"%e)

Parameters

NameTypeDescriptionNotes
log_idintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_list

PositionList query_position_list()

Query active position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
try:
# Query active position listapi_response=api_instance.query_position_list()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_list: %s\n"%e)

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

update_position

UpdatePosition update_position(position_id, trad_fi_position_update_request)

Modify position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_position_update_request=gate_api.TradFiPositionUpdateRequest() # TradFiPositionUpdateRequest | try:
# Modify positionapi_response=api_instance.update_position(position_id, trad_fi_position_update_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->update_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_position_update_requestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

close_position

DeletePosition close_position(position_id, trad_fi_close_position_request)

Close position

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
position_id=1223# int | Position IDtrad_fi_close_position_request=gate_api.TradFiClosePositionRequest() # TradFiClosePositionRequest | try:
# Close positionapi_response=api_instance.close_position(position_id, trad_fi_close_position_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->close_position: %s\n"%e)

Parameters

NameTypeDescriptionNotes
position_idintPosition ID
trad_fi_close_position_requestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

query_position_history_list

PositionHistoryList query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)

Query historical position list

Example

  • Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, 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 authorizationconfiguration=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 classapi_instance=gate_api.CFDApi(api_client)
page=1# int | Page number; defaults to 1 if omitted. (optional)page_size=10# int | Page size; defaults to 10 if omitted. Maximum 100. (optional)begin_time=56# int | Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago (optional)end_time=56# int | End time (timestamp in seconds) (optional)symbol='symbol_example'# str | Trading symbol (e.g., EURUSD) (optional)position_dir='position_dir_example'# str | Position direction (Long=long position, Short=short position) (optional)try:
# Query historical position listapi_response=api_instance.query_position_history_list(page=page, page_size=page_size, begin_time=begin_time, end_time=end_time, symbol=symbol, position_dir=position_dir)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling CFDApi->query_position_history_list: %s\n"%e)

Parameters

NameTypeDescriptionNotes
pageintPage number; defaults to 1 if omitted.[optional]
page_sizeintPage size; defaults to 10 if omitted. Maximum 100.[optional]
begin_timeintStart Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
end_timeintEnd time (timestamp in seconds)[optional]
symbolstrTrading symbol (e.g., EURUSD)[optional]
position_dirstrPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]