Skip to content

Latest commit

History

History
812 lines (628 loc) · 39.9 KB

File metadata and controls

812 lines (628 loc) · 39.9 KB

gate_api.BotApi

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

MethodHTTP requestDescription
get_ai_hub_strategy_recommendGET /bot/strategy/recommendGet AIHub strategy recommendations
post_ai_hub_spot_grid_createPOST /bot/spot-grid/createCreate spot grid
post_ai_hub_margin_grid_createPOST /bot/margin-grid/createCreate a lever grid
post_ai_hub_infinite_grid_createPOST /bot/infinite-grid/createCreate infinite grid
post_ai_hub_futures_grid_createPOST /bot/futures-grid/createCreate a contract grid
post_ai_hub_spot_martingale_createPOST /bot/spot-martingale/createCreate Spot Martin
post_ai_hub_contract_martingale_createPOST /bot/contract-martingale/createCreate contract martin
get_ai_hub_portfolio_runningGET /bot/portfolio/runningQuery the list of running policies
get_ai_hub_portfolio_detailGET /bot/portfolio/detailQuery order policy details
post_ai_hub_portfolio_stopPOST /bot/portfolio/stopTerminate a single running policy

get_ai_hub_strategy_recommend

AIHubDiscoverSuccessResponse get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Get AIHub strategy recommendations

The only formal interface for the discover domain. Support scenarios: - top1 - bundle - filter - refresh Constraints: - The active recommendation pool only contains spot_grid, futures_grid, spot_martingale - Can return but do not actively recommend infinite_grid, margin_grid - contract_martingale, smart-position, spot-future-arbitrage must not be returned - When scene=filter is used, only filtering by market, backtest_apr_gte, max_drawdown_lte is allowed - scene=refresh inherits the refresh context through refresh_recommendation_id; the official minimum format only requires strategy_type|market - If the upstream directly transmits the previous recommendation recommendation_id, the third paragraph backtest_id will currently be ignored.

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.BotApi(api_client)
market='market_example'# str | Trading pair, such as `BTC_USDT` (optional)strategy_type='strategy_type_example'# str | Recommended target policy type; `contract_martingale` not allowed (optional)direction='direction_example'# str | Market direction (optional)invest_amount='invest_amount_example'# str | Investment amount, string transparent transmission (optional)scene='scene_example'# str | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic. (optional)refresh_recommendation_id='refresh_recommendation_id_example'# str | It is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_type|market`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored. (optional)limit=56# int | Return quantity; when `scene=filter` is used, the actual results are up to 10 (optional)max_drawdown_lte='max_drawdown_lte_example'# str | Maximum drawdown limit (optional)backtest_apr_gte='backtest_apr_gte_example'# str | Backtest annualized lower limit (optional)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Get AIHub strategy recommendationsapi_response=api_instance.get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_strategy_recommend: %s\n"%e)

Parameters

NameTypeDescriptionNotes
marketstrTrading pair, such as `BTC_USDT`[optional]
strategy_typestrRecommended target policy type; `contract_martingale` not allowed[optional]
directionstrMarket direction[optional]
invest_amountstrInvestment amount, string transparent transmission[optional]
scenestrRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional]
refresh_recommendation_idstrIt is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_typemarket`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored.
limitintReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
max_drawdown_ltestrMaximum drawdown limit[optional]
backtest_apr_gtestrBacktest annualized lower limit[optional]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubDiscoverSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_grid_create

AIHubCreateSuccessResponse post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

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.BotApi(api_client)
spot_grid_create_request=gate_api.SpotGridCreateRequest() # SpotGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create spot gridapi_response=api_instance.post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_grid_create_requestSpotGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_margin_grid_create

AIHubCreateSuccessResponse post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

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.BotApi(api_client)
margin_grid_create_request=gate_api.MarginGridCreateRequest() # MarginGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a lever gridapi_response=api_instance.post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_margin_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
margin_grid_create_requestMarginGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_infinite_grid_create

AIHubCreateSuccessResponse post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

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.BotApi(api_client)
infinite_grid_create_request=gate_api.InfiniteGridCreateRequest() # InfiniteGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create infinite gridapi_response=api_instance.post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_infinite_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
infinite_grid_create_requestInfiniteGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_futures_grid_create

AIHubCreateSuccessResponse post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

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.BotApi(api_client)
futures_grid_create_request=gate_api.FuturesGridCreateRequest() # FuturesGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a contract gridapi_response=api_instance.post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_futures_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
futures_grid_create_requestFuturesGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_martingale_create

AIHubCreateSuccessResponse post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create Spot Martin

Create a spot martingale strategy from the given parameters. Stop-loss semantics match the app / MartingaleBot: - Use create_params.stop_loss_per_cycle (ratio per round as a decimal string) for creation-side stop-loss; do not use stop_loss_price for creation logic. - Stop-loss prices shown on detail pages are computed per round by the engine; creation accepts optional create_params.trigger_price (trigger price).

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.BotApi(api_client)
spot_martingale_create_request=gate_api.SpotMartingaleCreateRequest() # SpotMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create Spot Martinapi_response=api_instance.post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_martingale_create_requestSpotMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_contract_martingale_create

AIHubCreateSuccessResponse post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create contract martin

Create a contract Martin strategy based on the input parameters.

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.BotApi(api_client)
contract_martingale_create_request=gate_api.ContractMartingaleCreateRequest() # ContractMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create contract martinapi_response=api_instance.post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_contract_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
contract_martingale_create_requestContractMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_running

AIHubPortfolioRunningSuccessResponse get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query the list of running policies

Query the list of AIHub strategies currently running by the user, and support filtering by strategy type, trading pair and paging conditions.

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.BotApi(api_client)
strategy_type='strategy_type_example'# str | Filter by policy type (optional)market='market_example'# str | Filter by trading pair (optional)page=1# int | Page number, default 1 (optional) (default to 1)page_size=20# int | Paging size, default 20, maximum 50 (optional) (default to 20)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query the list of running policiesapi_response=api_instance.get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_running: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_typestrFilter by policy type[optional]
marketstrFilter by trading pair[optional]
pageintPage number, default 1[optional] [default to 1]
page_sizeintPaging size, default 20, maximum 50[optional] [default to 20]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioRunningSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_detail

AIHubPortfolioDetailSuccessResponse get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query order policy details

Both strategy_id and strategy_type must be passed in the request, where strategy_type is used to distribute to the underlying detailed implementation by strategy type.

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.BotApi(api_client)
strategy_id='strategy_id_example'# str | Policy IDstrategy_type='strategy_type_example'# str | Policy type; used for underlying detail distributionx_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query order policy detailsapi_response=api_instance.get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_idstrPolicy ID
strategy_typestrPolicy type; used for underlying detail distribution
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioDetailSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_portfolio_stop

AIHubPortfolioStopSuccessResponse post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Terminate a single running policy

Only one policy is allowed to be terminated per request. Risk warning and secondary confirmation are borne by the upper layer of OpenClaw; this interface is only responsible for executing stop.

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.BotApi(api_client)
ai_hub_portfolio_stop_request=gate_api.AIHubPortfolioStopRequest() # AIHubPortfolioStopRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Terminate a single running policyapi_response=api_instance.post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_portfolio_stop: %s\n"%e)

Parameters

NameTypeDescriptionNotes
ai_hub_portfolio_stop_requestAIHubPortfolioStopRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioStopSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
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;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
gateapi-python/docs/BotApi.md at master · gate/gateapi-python · GitHub
Skip to content

Latest commit

History

History
812 lines (628 loc) · 39.9 KB

File metadata and controls

812 lines (628 loc) · 39.9 KB

gate_api.BotApi

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

MethodHTTP requestDescription
get_ai_hub_strategy_recommendGET /bot/strategy/recommendGet AIHub strategy recommendations
post_ai_hub_spot_grid_createPOST /bot/spot-grid/createCreate spot grid
post_ai_hub_margin_grid_createPOST /bot/margin-grid/createCreate a lever grid
post_ai_hub_infinite_grid_createPOST /bot/infinite-grid/createCreate infinite grid
post_ai_hub_futures_grid_createPOST /bot/futures-grid/createCreate a contract grid
post_ai_hub_spot_martingale_createPOST /bot/spot-martingale/createCreate Spot Martin
post_ai_hub_contract_martingale_createPOST /bot/contract-martingale/createCreate contract martin
get_ai_hub_portfolio_runningGET /bot/portfolio/runningQuery the list of running policies
get_ai_hub_portfolio_detailGET /bot/portfolio/detailQuery order policy details
post_ai_hub_portfolio_stopPOST /bot/portfolio/stopTerminate a single running policy

get_ai_hub_strategy_recommend

AIHubDiscoverSuccessResponse get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Get AIHub strategy recommendations

The only formal interface for the discover domain. Support scenarios: - top1 - bundle - filter - refresh Constraints: - The active recommendation pool only contains spot_grid, futures_grid, spot_martingale - Can return but do not actively recommend infinite_grid, margin_grid - contract_martingale, smart-position, spot-future-arbitrage must not be returned - When scene=filter is used, only filtering by market, backtest_apr_gte, max_drawdown_lte is allowed - scene=refresh inherits the refresh context through refresh_recommendation_id; the official minimum format only requires strategy_type|market - If the upstream directly transmits the previous recommendation recommendation_id, the third paragraph backtest_id will currently be ignored.

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.BotApi(api_client)
market='market_example'# str | Trading pair, such as `BTC_USDT` (optional)strategy_type='strategy_type_example'# str | Recommended target policy type; `contract_martingale` not allowed (optional)direction='direction_example'# str | Market direction (optional)invest_amount='invest_amount_example'# str | Investment amount, string transparent transmission (optional)scene='scene_example'# str | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic. (optional)refresh_recommendation_id='refresh_recommendation_id_example'# str | It is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_type|market`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored. (optional)limit=56# int | Return quantity; when `scene=filter` is used, the actual results are up to 10 (optional)max_drawdown_lte='max_drawdown_lte_example'# str | Maximum drawdown limit (optional)backtest_apr_gte='backtest_apr_gte_example'# str | Backtest annualized lower limit (optional)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Get AIHub strategy recommendationsapi_response=api_instance.get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_strategy_recommend: %s\n"%e)

Parameters

NameTypeDescriptionNotes
marketstrTrading pair, such as `BTC_USDT`[optional]
strategy_typestrRecommended target policy type; `contract_martingale` not allowed[optional]
directionstrMarket direction[optional]
invest_amountstrInvestment amount, string transparent transmission[optional]
scenestrRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional]
refresh_recommendation_idstrIt is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_typemarket`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored.
limitintReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
max_drawdown_ltestrMaximum drawdown limit[optional]
backtest_apr_gtestrBacktest annualized lower limit[optional]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubDiscoverSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_grid_create

AIHubCreateSuccessResponse post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

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.BotApi(api_client)
spot_grid_create_request=gate_api.SpotGridCreateRequest() # SpotGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create spot gridapi_response=api_instance.post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_grid_create_requestSpotGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_margin_grid_create

AIHubCreateSuccessResponse post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

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.BotApi(api_client)
margin_grid_create_request=gate_api.MarginGridCreateRequest() # MarginGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a lever gridapi_response=api_instance.post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_margin_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
margin_grid_create_requestMarginGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_infinite_grid_create

AIHubCreateSuccessResponse post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

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.BotApi(api_client)
infinite_grid_create_request=gate_api.InfiniteGridCreateRequest() # InfiniteGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create infinite gridapi_response=api_instance.post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_infinite_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
infinite_grid_create_requestInfiniteGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_futures_grid_create

AIHubCreateSuccessResponse post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

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.BotApi(api_client)
futures_grid_create_request=gate_api.FuturesGridCreateRequest() # FuturesGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a contract gridapi_response=api_instance.post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_futures_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
futures_grid_create_requestFuturesGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_martingale_create

AIHubCreateSuccessResponse post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create Spot Martin

Create a spot martingale strategy from the given parameters. Stop-loss semantics match the app / MartingaleBot: - Use create_params.stop_loss_per_cycle (ratio per round as a decimal string) for creation-side stop-loss; do not use stop_loss_price for creation logic. - Stop-loss prices shown on detail pages are computed per round by the engine; creation accepts optional create_params.trigger_price (trigger price).

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.BotApi(api_client)
spot_martingale_create_request=gate_api.SpotMartingaleCreateRequest() # SpotMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create Spot Martinapi_response=api_instance.post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_martingale_create_requestSpotMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_contract_martingale_create

AIHubCreateSuccessResponse post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create contract martin

Create a contract Martin strategy based on the input parameters.

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.BotApi(api_client)
contract_martingale_create_request=gate_api.ContractMartingaleCreateRequest() # ContractMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create contract martinapi_response=api_instance.post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_contract_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
contract_martingale_create_requestContractMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_running

AIHubPortfolioRunningSuccessResponse get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query the list of running policies

Query the list of AIHub strategies currently running by the user, and support filtering by strategy type, trading pair and paging conditions.

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.BotApi(api_client)
strategy_type='strategy_type_example'# str | Filter by policy type (optional)market='market_example'# str | Filter by trading pair (optional)page=1# int | Page number, default 1 (optional) (default to 1)page_size=20# int | Paging size, default 20, maximum 50 (optional) (default to 20)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query the list of running policiesapi_response=api_instance.get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_running: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_typestrFilter by policy type[optional]
marketstrFilter by trading pair[optional]
pageintPage number, default 1[optional] [default to 1]
page_sizeintPaging size, default 20, maximum 50[optional] [default to 20]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioRunningSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_detail

AIHubPortfolioDetailSuccessResponse get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query order policy details

Both strategy_id and strategy_type must be passed in the request, where strategy_type is used to distribute to the underlying detailed implementation by strategy type.

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.BotApi(api_client)
strategy_id='strategy_id_example'# str | Policy IDstrategy_type='strategy_type_example'# str | Policy type; used for underlying detail distributionx_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query order policy detailsapi_response=api_instance.get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_idstrPolicy ID
strategy_typestrPolicy type; used for underlying detail distribution
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioDetailSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_portfolio_stop

AIHubPortfolioStopSuccessResponse post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Terminate a single running policy

Only one policy is allowed to be terminated per request. Risk warning and secondary confirmation are borne by the upper layer of OpenClaw; this interface is only responsible for executing stop.

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.BotApi(api_client)
ai_hub_portfolio_stop_request=gate_api.AIHubPortfolioStopRequest() # AIHubPortfolioStopRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Terminate a single running policyapi_response=api_instance.post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_portfolio_stop: %s\n"%e)

Parameters

NameTypeDescriptionNotes
ai_hub_portfolio_stop_requestAIHubPortfolioStopRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioStopSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

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

Latest commit

History

History
812 lines (628 loc) · 39.9 KB

File metadata and controls

812 lines (628 loc) · 39.9 KB

gate_api.BotApi

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

MethodHTTP requestDescription
get_ai_hub_strategy_recommendGET /bot/strategy/recommendGet AIHub strategy recommendations
post_ai_hub_spot_grid_createPOST /bot/spot-grid/createCreate spot grid
post_ai_hub_margin_grid_createPOST /bot/margin-grid/createCreate a lever grid
post_ai_hub_infinite_grid_createPOST /bot/infinite-grid/createCreate infinite grid
post_ai_hub_futures_grid_createPOST /bot/futures-grid/createCreate a contract grid
post_ai_hub_spot_martingale_createPOST /bot/spot-martingale/createCreate Spot Martin
post_ai_hub_contract_martingale_createPOST /bot/contract-martingale/createCreate contract martin
get_ai_hub_portfolio_runningGET /bot/portfolio/runningQuery the list of running policies
get_ai_hub_portfolio_detailGET /bot/portfolio/detailQuery order policy details
post_ai_hub_portfolio_stopPOST /bot/portfolio/stopTerminate a single running policy

get_ai_hub_strategy_recommend

AIHubDiscoverSuccessResponse get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Get AIHub strategy recommendations

The only formal interface for the discover domain. Support scenarios: - top1 - bundle - filter - refresh Constraints: - The active recommendation pool only contains spot_grid, futures_grid, spot_martingale - Can return but do not actively recommend infinite_grid, margin_grid - contract_martingale, smart-position, spot-future-arbitrage must not be returned - When scene=filter is used, only filtering by market, backtest_apr_gte, max_drawdown_lte is allowed - scene=refresh inherits the refresh context through refresh_recommendation_id; the official minimum format only requires strategy_type|market - If the upstream directly transmits the previous recommendation recommendation_id, the third paragraph backtest_id will currently be ignored.

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.BotApi(api_client)
market='market_example'# str | Trading pair, such as `BTC_USDT` (optional)strategy_type='strategy_type_example'# str | Recommended target policy type; `contract_martingale` not allowed (optional)direction='direction_example'# str | Market direction (optional)invest_amount='invest_amount_example'# str | Investment amount, string transparent transmission (optional)scene='scene_example'# str | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic. (optional)refresh_recommendation_id='refresh_recommendation_id_example'# str | It is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_type|market`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored. (optional)limit=56# int | Return quantity; when `scene=filter` is used, the actual results are up to 10 (optional)max_drawdown_lte='max_drawdown_lte_example'# str | Maximum drawdown limit (optional)backtest_apr_gte='backtest_apr_gte_example'# str | Backtest annualized lower limit (optional)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Get AIHub strategy recommendationsapi_response=api_instance.get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_strategy_recommend: %s\n"%e)

Parameters

NameTypeDescriptionNotes
marketstrTrading pair, such as `BTC_USDT`[optional]
strategy_typestrRecommended target policy type; `contract_martingale` not allowed[optional]
directionstrMarket direction[optional]
invest_amountstrInvestment amount, string transparent transmission[optional]
scenestrRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional]
refresh_recommendation_idstrIt is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_typemarket`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored.
limitintReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
max_drawdown_ltestrMaximum drawdown limit[optional]
backtest_apr_gtestrBacktest annualized lower limit[optional]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubDiscoverSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_grid_create

AIHubCreateSuccessResponse post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

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.BotApi(api_client)
spot_grid_create_request=gate_api.SpotGridCreateRequest() # SpotGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create spot gridapi_response=api_instance.post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_grid_create_requestSpotGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_margin_grid_create

AIHubCreateSuccessResponse post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

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.BotApi(api_client)
margin_grid_create_request=gate_api.MarginGridCreateRequest() # MarginGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a lever gridapi_response=api_instance.post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_margin_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
margin_grid_create_requestMarginGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_infinite_grid_create

AIHubCreateSuccessResponse post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

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.BotApi(api_client)
infinite_grid_create_request=gate_api.InfiniteGridCreateRequest() # InfiniteGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create infinite gridapi_response=api_instance.post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_infinite_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
infinite_grid_create_requestInfiniteGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_futures_grid_create

AIHubCreateSuccessResponse post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

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.BotApi(api_client)
futures_grid_create_request=gate_api.FuturesGridCreateRequest() # FuturesGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a contract gridapi_response=api_instance.post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_futures_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
futures_grid_create_requestFuturesGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_martingale_create

AIHubCreateSuccessResponse post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create Spot Martin

Create a spot martingale strategy from the given parameters. Stop-loss semantics match the app / MartingaleBot: - Use create_params.stop_loss_per_cycle (ratio per round as a decimal string) for creation-side stop-loss; do not use stop_loss_price for creation logic. - Stop-loss prices shown on detail pages are computed per round by the engine; creation accepts optional create_params.trigger_price (trigger price).

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.BotApi(api_client)
spot_martingale_create_request=gate_api.SpotMartingaleCreateRequest() # SpotMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create Spot Martinapi_response=api_instance.post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_martingale_create_requestSpotMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_contract_martingale_create

AIHubCreateSuccessResponse post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create contract martin

Create a contract Martin strategy based on the input parameters.

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.BotApi(api_client)
contract_martingale_create_request=gate_api.ContractMartingaleCreateRequest() # ContractMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create contract martinapi_response=api_instance.post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_contract_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
contract_martingale_create_requestContractMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_running

AIHubPortfolioRunningSuccessResponse get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query the list of running policies

Query the list of AIHub strategies currently running by the user, and support filtering by strategy type, trading pair and paging conditions.

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.BotApi(api_client)
strategy_type='strategy_type_example'# str | Filter by policy type (optional)market='market_example'# str | Filter by trading pair (optional)page=1# int | Page number, default 1 (optional) (default to 1)page_size=20# int | Paging size, default 20, maximum 50 (optional) (default to 20)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query the list of running policiesapi_response=api_instance.get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_running: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_typestrFilter by policy type[optional]
marketstrFilter by trading pair[optional]
pageintPage number, default 1[optional] [default to 1]
page_sizeintPaging size, default 20, maximum 50[optional] [default to 20]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioRunningSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_detail

AIHubPortfolioDetailSuccessResponse get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query order policy details

Both strategy_id and strategy_type must be passed in the request, where strategy_type is used to distribute to the underlying detailed implementation by strategy type.

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.BotApi(api_client)
strategy_id='strategy_id_example'# str | Policy IDstrategy_type='strategy_type_example'# str | Policy type; used for underlying detail distributionx_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query order policy detailsapi_response=api_instance.get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_idstrPolicy ID
strategy_typestrPolicy type; used for underlying detail distribution
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioDetailSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_portfolio_stop

AIHubPortfolioStopSuccessResponse post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Terminate a single running policy

Only one policy is allowed to be terminated per request. Risk warning and secondary confirmation are borne by the upper layer of OpenClaw; this interface is only responsible for executing stop.

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.BotApi(api_client)
ai_hub_portfolio_stop_request=gate_api.AIHubPortfolioStopRequest() # AIHubPortfolioStopRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Terminate a single running policyapi_response=api_instance.post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_portfolio_stop: %s\n"%e)

Parameters

NameTypeDescriptionNotes
ai_hub_portfolio_stop_requestAIHubPortfolioStopRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioStopSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

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

Latest commit

History

History
812 lines (628 loc) · 39.9 KB

File metadata and controls

812 lines (628 loc) · 39.9 KB

gate_api.BotApi

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

MethodHTTP requestDescription
get_ai_hub_strategy_recommendGET /bot/strategy/recommendGet AIHub strategy recommendations
post_ai_hub_spot_grid_createPOST /bot/spot-grid/createCreate spot grid
post_ai_hub_margin_grid_createPOST /bot/margin-grid/createCreate a lever grid
post_ai_hub_infinite_grid_createPOST /bot/infinite-grid/createCreate infinite grid
post_ai_hub_futures_grid_createPOST /bot/futures-grid/createCreate a contract grid
post_ai_hub_spot_martingale_createPOST /bot/spot-martingale/createCreate Spot Martin
post_ai_hub_contract_martingale_createPOST /bot/contract-martingale/createCreate contract martin
get_ai_hub_portfolio_runningGET /bot/portfolio/runningQuery the list of running policies
get_ai_hub_portfolio_detailGET /bot/portfolio/detailQuery order policy details
post_ai_hub_portfolio_stopPOST /bot/portfolio/stopTerminate a single running policy

get_ai_hub_strategy_recommend

AIHubDiscoverSuccessResponse get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Get AIHub strategy recommendations

The only formal interface for the discover domain. Support scenarios: - top1 - bundle - filter - refresh Constraints: - The active recommendation pool only contains spot_grid, futures_grid, spot_martingale - Can return but do not actively recommend infinite_grid, margin_grid - contract_martingale, smart-position, spot-future-arbitrage must not be returned - When scene=filter is used, only filtering by market, backtest_apr_gte, max_drawdown_lte is allowed - scene=refresh inherits the refresh context through refresh_recommendation_id; the official minimum format only requires strategy_type|market - If the upstream directly transmits the previous recommendation recommendation_id, the third paragraph backtest_id will currently be ignored.

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.BotApi(api_client)
market='market_example'# str | Trading pair, such as `BTC_USDT` (optional)strategy_type='strategy_type_example'# str | Recommended target policy type; `contract_martingale` not allowed (optional)direction='direction_example'# str | Market direction (optional)invest_amount='invest_amount_example'# str | Investment amount, string transparent transmission (optional)scene='scene_example'# str | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic. (optional)refresh_recommendation_id='refresh_recommendation_id_example'# str | It is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_type|market`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored. (optional)limit=56# int | Return quantity; when `scene=filter` is used, the actual results are up to 10 (optional)max_drawdown_lte='max_drawdown_lte_example'# str | Maximum drawdown limit (optional)backtest_apr_gte='backtest_apr_gte_example'# str | Backtest annualized lower limit (optional)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Get AIHub strategy recommendationsapi_response=api_instance.get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_strategy_recommend: %s\n"%e)

Parameters

NameTypeDescriptionNotes
marketstrTrading pair, such as `BTC_USDT`[optional]
strategy_typestrRecommended target policy type; `contract_martingale` not allowed[optional]
directionstrMarket direction[optional]
invest_amountstrInvestment amount, string transparent transmission[optional]
scenestrRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional]
refresh_recommendation_idstrIt is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_typemarket`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored.
limitintReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
max_drawdown_ltestrMaximum drawdown limit[optional]
backtest_apr_gtestrBacktest annualized lower limit[optional]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubDiscoverSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_grid_create

AIHubCreateSuccessResponse post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

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.BotApi(api_client)
spot_grid_create_request=gate_api.SpotGridCreateRequest() # SpotGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create spot gridapi_response=api_instance.post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_grid_create_requestSpotGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_margin_grid_create

AIHubCreateSuccessResponse post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

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.BotApi(api_client)
margin_grid_create_request=gate_api.MarginGridCreateRequest() # MarginGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a lever gridapi_response=api_instance.post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_margin_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
margin_grid_create_requestMarginGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_infinite_grid_create

AIHubCreateSuccessResponse post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

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.BotApi(api_client)
infinite_grid_create_request=gate_api.InfiniteGridCreateRequest() # InfiniteGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create infinite gridapi_response=api_instance.post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_infinite_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
infinite_grid_create_requestInfiniteGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_futures_grid_create

AIHubCreateSuccessResponse post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

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.BotApi(api_client)
futures_grid_create_request=gate_api.FuturesGridCreateRequest() # FuturesGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a contract gridapi_response=api_instance.post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_futures_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
futures_grid_create_requestFuturesGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_martingale_create

AIHubCreateSuccessResponse post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create Spot Martin

Create a spot martingale strategy from the given parameters. Stop-loss semantics match the app / MartingaleBot: - Use create_params.stop_loss_per_cycle (ratio per round as a decimal string) for creation-side stop-loss; do not use stop_loss_price for creation logic. - Stop-loss prices shown on detail pages are computed per round by the engine; creation accepts optional create_params.trigger_price (trigger price).

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.BotApi(api_client)
spot_martingale_create_request=gate_api.SpotMartingaleCreateRequest() # SpotMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create Spot Martinapi_response=api_instance.post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_martingale_create_requestSpotMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_contract_martingale_create

AIHubCreateSuccessResponse post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create contract martin

Create a contract Martin strategy based on the input parameters.

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.BotApi(api_client)
contract_martingale_create_request=gate_api.ContractMartingaleCreateRequest() # ContractMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create contract martinapi_response=api_instance.post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_contract_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
contract_martingale_create_requestContractMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_running

AIHubPortfolioRunningSuccessResponse get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query the list of running policies

Query the list of AIHub strategies currently running by the user, and support filtering by strategy type, trading pair and paging conditions.

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.BotApi(api_client)
strategy_type='strategy_type_example'# str | Filter by policy type (optional)market='market_example'# str | Filter by trading pair (optional)page=1# int | Page number, default 1 (optional) (default to 1)page_size=20# int | Paging size, default 20, maximum 50 (optional) (default to 20)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query the list of running policiesapi_response=api_instance.get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_running: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_typestrFilter by policy type[optional]
marketstrFilter by trading pair[optional]
pageintPage number, default 1[optional] [default to 1]
page_sizeintPaging size, default 20, maximum 50[optional] [default to 20]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioRunningSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_detail

AIHubPortfolioDetailSuccessResponse get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query order policy details

Both strategy_id and strategy_type must be passed in the request, where strategy_type is used to distribute to the underlying detailed implementation by strategy type.

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.BotApi(api_client)
strategy_id='strategy_id_example'# str | Policy IDstrategy_type='strategy_type_example'# str | Policy type; used for underlying detail distributionx_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query order policy detailsapi_response=api_instance.get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_idstrPolicy ID
strategy_typestrPolicy type; used for underlying detail distribution
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioDetailSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_portfolio_stop

AIHubPortfolioStopSuccessResponse post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Terminate a single running policy

Only one policy is allowed to be terminated per request. Risk warning and secondary confirmation are borne by the upper layer of OpenClaw; this interface is only responsible for executing stop.

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.BotApi(api_client)
ai_hub_portfolio_stop_request=gate_api.AIHubPortfolioStopRequest() # AIHubPortfolioStopRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Terminate a single running policyapi_response=api_instance.post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_portfolio_stop: %s\n"%e)

Parameters

NameTypeDescriptionNotes
ai_hub_portfolio_stop_requestAIHubPortfolioStopRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioStopSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

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

Latest commit

History

History
812 lines (628 loc) · 39.9 KB

File metadata and controls

812 lines (628 loc) · 39.9 KB

gate_api.BotApi

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

MethodHTTP requestDescription
get_ai_hub_strategy_recommendGET /bot/strategy/recommendGet AIHub strategy recommendations
post_ai_hub_spot_grid_createPOST /bot/spot-grid/createCreate spot grid
post_ai_hub_margin_grid_createPOST /bot/margin-grid/createCreate a lever grid
post_ai_hub_infinite_grid_createPOST /bot/infinite-grid/createCreate infinite grid
post_ai_hub_futures_grid_createPOST /bot/futures-grid/createCreate a contract grid
post_ai_hub_spot_martingale_createPOST /bot/spot-martingale/createCreate Spot Martin
post_ai_hub_contract_martingale_createPOST /bot/contract-martingale/createCreate contract martin
get_ai_hub_portfolio_runningGET /bot/portfolio/runningQuery the list of running policies
get_ai_hub_portfolio_detailGET /bot/portfolio/detailQuery order policy details
post_ai_hub_portfolio_stopPOST /bot/portfolio/stopTerminate a single running policy

get_ai_hub_strategy_recommend

AIHubDiscoverSuccessResponse get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Get AIHub strategy recommendations

The only formal interface for the discover domain. Support scenarios: - top1 - bundle - filter - refresh Constraints: - The active recommendation pool only contains spot_grid, futures_grid, spot_martingale - Can return but do not actively recommend infinite_grid, margin_grid - contract_martingale, smart-position, spot-future-arbitrage must not be returned - When scene=filter is used, only filtering by market, backtest_apr_gte, max_drawdown_lte is allowed - scene=refresh inherits the refresh context through refresh_recommendation_id; the official minimum format only requires strategy_type|market - If the upstream directly transmits the previous recommendation recommendation_id, the third paragraph backtest_id will currently be ignored.

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.BotApi(api_client)
market='market_example'# str | Trading pair, such as `BTC_USDT` (optional)strategy_type='strategy_type_example'# str | Recommended target policy type; `contract_martingale` not allowed (optional)direction='direction_example'# str | Market direction (optional)invest_amount='invest_amount_example'# str | Investment amount, string transparent transmission (optional)scene='scene_example'# str | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic. (optional)refresh_recommendation_id='refresh_recommendation_id_example'# str | It is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_type|market`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored. (optional)limit=56# int | Return quantity; when `scene=filter` is used, the actual results are up to 10 (optional)max_drawdown_lte='max_drawdown_lte_example'# str | Maximum drawdown limit (optional)backtest_apr_gte='backtest_apr_gte_example'# str | Backtest annualized lower limit (optional)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Get AIHub strategy recommendationsapi_response=api_instance.get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_strategy_recommend: %s\n"%e)

Parameters

NameTypeDescriptionNotes
marketstrTrading pair, such as `BTC_USDT`[optional]
strategy_typestrRecommended target policy type; `contract_martingale` not allowed[optional]
directionstrMarket direction[optional]
invest_amountstrInvestment amount, string transparent transmission[optional]
scenestrRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional]
refresh_recommendation_idstrIt is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_typemarket`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored.
limitintReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
max_drawdown_ltestrMaximum drawdown limit[optional]
backtest_apr_gtestrBacktest annualized lower limit[optional]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubDiscoverSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_grid_create

AIHubCreateSuccessResponse post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

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.BotApi(api_client)
spot_grid_create_request=gate_api.SpotGridCreateRequest() # SpotGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create spot gridapi_response=api_instance.post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_grid_create_requestSpotGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_margin_grid_create

AIHubCreateSuccessResponse post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

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.BotApi(api_client)
margin_grid_create_request=gate_api.MarginGridCreateRequest() # MarginGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a lever gridapi_response=api_instance.post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_margin_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
margin_grid_create_requestMarginGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_infinite_grid_create

AIHubCreateSuccessResponse post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

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.BotApi(api_client)
infinite_grid_create_request=gate_api.InfiniteGridCreateRequest() # InfiniteGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create infinite gridapi_response=api_instance.post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_infinite_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
infinite_grid_create_requestInfiniteGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_futures_grid_create

AIHubCreateSuccessResponse post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

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.BotApi(api_client)
futures_grid_create_request=gate_api.FuturesGridCreateRequest() # FuturesGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a contract gridapi_response=api_instance.post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_futures_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
futures_grid_create_requestFuturesGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_martingale_create

AIHubCreateSuccessResponse post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create Spot Martin

Create a spot martingale strategy from the given parameters. Stop-loss semantics match the app / MartingaleBot: - Use create_params.stop_loss_per_cycle (ratio per round as a decimal string) for creation-side stop-loss; do not use stop_loss_price for creation logic. - Stop-loss prices shown on detail pages are computed per round by the engine; creation accepts optional create_params.trigger_price (trigger price).

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.BotApi(api_client)
spot_martingale_create_request=gate_api.SpotMartingaleCreateRequest() # SpotMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create Spot Martinapi_response=api_instance.post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_martingale_create_requestSpotMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_contract_martingale_create

AIHubCreateSuccessResponse post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create contract martin

Create a contract Martin strategy based on the input parameters.

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.BotApi(api_client)
contract_martingale_create_request=gate_api.ContractMartingaleCreateRequest() # ContractMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create contract martinapi_response=api_instance.post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_contract_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
contract_martingale_create_requestContractMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_running

AIHubPortfolioRunningSuccessResponse get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query the list of running policies

Query the list of AIHub strategies currently running by the user, and support filtering by strategy type, trading pair and paging conditions.

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.BotApi(api_client)
strategy_type='strategy_type_example'# str | Filter by policy type (optional)market='market_example'# str | Filter by trading pair (optional)page=1# int | Page number, default 1 (optional) (default to 1)page_size=20# int | Paging size, default 20, maximum 50 (optional) (default to 20)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query the list of running policiesapi_response=api_instance.get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_running: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_typestrFilter by policy type[optional]
marketstrFilter by trading pair[optional]
pageintPage number, default 1[optional] [default to 1]
page_sizeintPaging size, default 20, maximum 50[optional] [default to 20]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioRunningSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_detail

AIHubPortfolioDetailSuccessResponse get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query order policy details

Both strategy_id and strategy_type must be passed in the request, where strategy_type is used to distribute to the underlying detailed implementation by strategy type.

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.BotApi(api_client)
strategy_id='strategy_id_example'# str | Policy IDstrategy_type='strategy_type_example'# str | Policy type; used for underlying detail distributionx_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query order policy detailsapi_response=api_instance.get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_idstrPolicy ID
strategy_typestrPolicy type; used for underlying detail distribution
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioDetailSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_portfolio_stop

AIHubPortfolioStopSuccessResponse post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Terminate a single running policy

Only one policy is allowed to be terminated per request. Risk warning and secondary confirmation are borne by the upper layer of OpenClaw; this interface is only responsible for executing stop.

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.BotApi(api_client)
ai_hub_portfolio_stop_request=gate_api.AIHubPortfolioStopRequest() # AIHubPortfolioStopRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Terminate a single running policyapi_response=api_instance.post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_portfolio_stop: %s\n"%e)

Parameters

NameTypeDescriptionNotes
ai_hub_portfolio_stop_requestAIHubPortfolioStopRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioStopSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

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

Latest commit

History

History
812 lines (628 loc) · 39.9 KB

File metadata and controls

812 lines (628 loc) · 39.9 KB

gate_api.BotApi

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

MethodHTTP requestDescription
get_ai_hub_strategy_recommendGET /bot/strategy/recommendGet AIHub strategy recommendations
post_ai_hub_spot_grid_createPOST /bot/spot-grid/createCreate spot grid
post_ai_hub_margin_grid_createPOST /bot/margin-grid/createCreate a lever grid
post_ai_hub_infinite_grid_createPOST /bot/infinite-grid/createCreate infinite grid
post_ai_hub_futures_grid_createPOST /bot/futures-grid/createCreate a contract grid
post_ai_hub_spot_martingale_createPOST /bot/spot-martingale/createCreate Spot Martin
post_ai_hub_contract_martingale_createPOST /bot/contract-martingale/createCreate contract martin
get_ai_hub_portfolio_runningGET /bot/portfolio/runningQuery the list of running policies
get_ai_hub_portfolio_detailGET /bot/portfolio/detailQuery order policy details
post_ai_hub_portfolio_stopPOST /bot/portfolio/stopTerminate a single running policy

get_ai_hub_strategy_recommend

AIHubDiscoverSuccessResponse get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Get AIHub strategy recommendations

The only formal interface for the discover domain. Support scenarios: - top1 - bundle - filter - refresh Constraints: - The active recommendation pool only contains spot_grid, futures_grid, spot_martingale - Can return but do not actively recommend infinite_grid, margin_grid - contract_martingale, smart-position, spot-future-arbitrage must not be returned - When scene=filter is used, only filtering by market, backtest_apr_gte, max_drawdown_lte is allowed - scene=refresh inherits the refresh context through refresh_recommendation_id; the official minimum format only requires strategy_type|market - If the upstream directly transmits the previous recommendation recommendation_id, the third paragraph backtest_id will currently be ignored.

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.BotApi(api_client)
market='market_example'# str | Trading pair, such as `BTC_USDT` (optional)strategy_type='strategy_type_example'# str | Recommended target policy type; `contract_martingale` not allowed (optional)direction='direction_example'# str | Market direction (optional)invest_amount='invest_amount_example'# str | Investment amount, string transparent transmission (optional)scene='scene_example'# str | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic. (optional)refresh_recommendation_id='refresh_recommendation_id_example'# str | It is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_type|market`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored. (optional)limit=56# int | Return quantity; when `scene=filter` is used, the actual results are up to 10 (optional)max_drawdown_lte='max_drawdown_lte_example'# str | Maximum drawdown limit (optional)backtest_apr_gte='backtest_apr_gte_example'# str | Backtest annualized lower limit (optional)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Get AIHub strategy recommendationsapi_response=api_instance.get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_strategy_recommend: %s\n"%e)

Parameters

NameTypeDescriptionNotes
marketstrTrading pair, such as `BTC_USDT`[optional]
strategy_typestrRecommended target policy type; `contract_martingale` not allowed[optional]
directionstrMarket direction[optional]
invest_amountstrInvestment amount, string transparent transmission[optional]
scenestrRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional]
refresh_recommendation_idstrIt is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_typemarket`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored.
limitintReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
max_drawdown_ltestrMaximum drawdown limit[optional]
backtest_apr_gtestrBacktest annualized lower limit[optional]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubDiscoverSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_grid_create

AIHubCreateSuccessResponse post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

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.BotApi(api_client)
spot_grid_create_request=gate_api.SpotGridCreateRequest() # SpotGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create spot gridapi_response=api_instance.post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_grid_create_requestSpotGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_margin_grid_create

AIHubCreateSuccessResponse post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

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.BotApi(api_client)
margin_grid_create_request=gate_api.MarginGridCreateRequest() # MarginGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a lever gridapi_response=api_instance.post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_margin_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
margin_grid_create_requestMarginGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_infinite_grid_create

AIHubCreateSuccessResponse post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

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.BotApi(api_client)
infinite_grid_create_request=gate_api.InfiniteGridCreateRequest() # InfiniteGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create infinite gridapi_response=api_instance.post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_infinite_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
infinite_grid_create_requestInfiniteGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_futures_grid_create

AIHubCreateSuccessResponse post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

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.BotApi(api_client)
futures_grid_create_request=gate_api.FuturesGridCreateRequest() # FuturesGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a contract gridapi_response=api_instance.post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_futures_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
futures_grid_create_requestFuturesGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_martingale_create

AIHubCreateSuccessResponse post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create Spot Martin

Create a spot martingale strategy from the given parameters. Stop-loss semantics match the app / MartingaleBot: - Use create_params.stop_loss_per_cycle (ratio per round as a decimal string) for creation-side stop-loss; do not use stop_loss_price for creation logic. - Stop-loss prices shown on detail pages are computed per round by the engine; creation accepts optional create_params.trigger_price (trigger price).

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.BotApi(api_client)
spot_martingale_create_request=gate_api.SpotMartingaleCreateRequest() # SpotMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create Spot Martinapi_response=api_instance.post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_martingale_create_requestSpotMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_contract_martingale_create

AIHubCreateSuccessResponse post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create contract martin

Create a contract Martin strategy based on the input parameters.

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.BotApi(api_client)
contract_martingale_create_request=gate_api.ContractMartingaleCreateRequest() # ContractMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create contract martinapi_response=api_instance.post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_contract_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
contract_martingale_create_requestContractMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_running

AIHubPortfolioRunningSuccessResponse get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query the list of running policies

Query the list of AIHub strategies currently running by the user, and support filtering by strategy type, trading pair and paging conditions.

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.BotApi(api_client)
strategy_type='strategy_type_example'# str | Filter by policy type (optional)market='market_example'# str | Filter by trading pair (optional)page=1# int | Page number, default 1 (optional) (default to 1)page_size=20# int | Paging size, default 20, maximum 50 (optional) (default to 20)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query the list of running policiesapi_response=api_instance.get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_running: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_typestrFilter by policy type[optional]
marketstrFilter by trading pair[optional]
pageintPage number, default 1[optional] [default to 1]
page_sizeintPaging size, default 20, maximum 50[optional] [default to 20]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioRunningSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_detail

AIHubPortfolioDetailSuccessResponse get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query order policy details

Both strategy_id and strategy_type must be passed in the request, where strategy_type is used to distribute to the underlying detailed implementation by strategy type.

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.BotApi(api_client)
strategy_id='strategy_id_example'# str | Policy IDstrategy_type='strategy_type_example'# str | Policy type; used for underlying detail distributionx_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query order policy detailsapi_response=api_instance.get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_idstrPolicy ID
strategy_typestrPolicy type; used for underlying detail distribution
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioDetailSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_portfolio_stop

AIHubPortfolioStopSuccessResponse post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Terminate a single running policy

Only one policy is allowed to be terminated per request. Risk warning and secondary confirmation are borne by the upper layer of OpenClaw; this interface is only responsible for executing stop.

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.BotApi(api_client)
ai_hub_portfolio_stop_request=gate_api.AIHubPortfolioStopRequest() # AIHubPortfolioStopRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Terminate a single running policyapi_response=api_instance.post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_portfolio_stop: %s\n"%e)

Parameters

NameTypeDescriptionNotes
ai_hub_portfolio_stop_requestAIHubPortfolioStopRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioStopSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

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

Latest commit

History

History
812 lines (628 loc) · 39.9 KB

File metadata and controls

812 lines (628 loc) · 39.9 KB

gate_api.BotApi

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

MethodHTTP requestDescription
get_ai_hub_strategy_recommendGET /bot/strategy/recommendGet AIHub strategy recommendations
post_ai_hub_spot_grid_createPOST /bot/spot-grid/createCreate spot grid
post_ai_hub_margin_grid_createPOST /bot/margin-grid/createCreate a lever grid
post_ai_hub_infinite_grid_createPOST /bot/infinite-grid/createCreate infinite grid
post_ai_hub_futures_grid_createPOST /bot/futures-grid/createCreate a contract grid
post_ai_hub_spot_martingale_createPOST /bot/spot-martingale/createCreate Spot Martin
post_ai_hub_contract_martingale_createPOST /bot/contract-martingale/createCreate contract martin
get_ai_hub_portfolio_runningGET /bot/portfolio/runningQuery the list of running policies
get_ai_hub_portfolio_detailGET /bot/portfolio/detailQuery order policy details
post_ai_hub_portfolio_stopPOST /bot/portfolio/stopTerminate a single running policy

get_ai_hub_strategy_recommend

AIHubDiscoverSuccessResponse get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Get AIHub strategy recommendations

The only formal interface for the discover domain. Support scenarios: - top1 - bundle - filter - refresh Constraints: - The active recommendation pool only contains spot_grid, futures_grid, spot_martingale - Can return but do not actively recommend infinite_grid, margin_grid - contract_martingale, smart-position, spot-future-arbitrage must not be returned - When scene=filter is used, only filtering by market, backtest_apr_gte, max_drawdown_lte is allowed - scene=refresh inherits the refresh context through refresh_recommendation_id; the official minimum format only requires strategy_type|market - If the upstream directly transmits the previous recommendation recommendation_id, the third paragraph backtest_id will currently be ignored.

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.BotApi(api_client)
market='market_example'# str | Trading pair, such as `BTC_USDT` (optional)strategy_type='strategy_type_example'# str | Recommended target policy type; `contract_martingale` not allowed (optional)direction='direction_example'# str | Market direction (optional)invest_amount='invest_amount_example'# str | Investment amount, string transparent transmission (optional)scene='scene_example'# str | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic. (optional)refresh_recommendation_id='refresh_recommendation_id_example'# str | It is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_type|market`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored. (optional)limit=56# int | Return quantity; when `scene=filter` is used, the actual results are up to 10 (optional)max_drawdown_lte='max_drawdown_lte_example'# str | Maximum drawdown limit (optional)backtest_apr_gte='backtest_apr_gte_example'# str | Backtest annualized lower limit (optional)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Get AIHub strategy recommendationsapi_response=api_instance.get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_strategy_recommend: %s\n"%e)

Parameters

NameTypeDescriptionNotes
marketstrTrading pair, such as `BTC_USDT`[optional]
strategy_typestrRecommended target policy type; `contract_martingale` not allowed[optional]
directionstrMarket direction[optional]
invest_amountstrInvestment amount, string transparent transmission[optional]
scenestrRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional]
refresh_recommendation_idstrIt is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_typemarket`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored.
limitintReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
max_drawdown_ltestrMaximum drawdown limit[optional]
backtest_apr_gtestrBacktest annualized lower limit[optional]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubDiscoverSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_grid_create

AIHubCreateSuccessResponse post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

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.BotApi(api_client)
spot_grid_create_request=gate_api.SpotGridCreateRequest() # SpotGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create spot gridapi_response=api_instance.post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_grid_create_requestSpotGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_margin_grid_create

AIHubCreateSuccessResponse post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

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.BotApi(api_client)
margin_grid_create_request=gate_api.MarginGridCreateRequest() # MarginGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a lever gridapi_response=api_instance.post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_margin_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
margin_grid_create_requestMarginGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_infinite_grid_create

AIHubCreateSuccessResponse post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

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.BotApi(api_client)
infinite_grid_create_request=gate_api.InfiniteGridCreateRequest() # InfiniteGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create infinite gridapi_response=api_instance.post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_infinite_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
infinite_grid_create_requestInfiniteGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_futures_grid_create

AIHubCreateSuccessResponse post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

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.BotApi(api_client)
futures_grid_create_request=gate_api.FuturesGridCreateRequest() # FuturesGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a contract gridapi_response=api_instance.post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_futures_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
futures_grid_create_requestFuturesGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_martingale_create

AIHubCreateSuccessResponse post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create Spot Martin

Create a spot martingale strategy from the given parameters. Stop-loss semantics match the app / MartingaleBot: - Use create_params.stop_loss_per_cycle (ratio per round as a decimal string) for creation-side stop-loss; do not use stop_loss_price for creation logic. - Stop-loss prices shown on detail pages are computed per round by the engine; creation accepts optional create_params.trigger_price (trigger price).

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.BotApi(api_client)
spot_martingale_create_request=gate_api.SpotMartingaleCreateRequest() # SpotMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create Spot Martinapi_response=api_instance.post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_martingale_create_requestSpotMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_contract_martingale_create

AIHubCreateSuccessResponse post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create contract martin

Create a contract Martin strategy based on the input parameters.

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.BotApi(api_client)
contract_martingale_create_request=gate_api.ContractMartingaleCreateRequest() # ContractMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create contract martinapi_response=api_instance.post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_contract_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
contract_martingale_create_requestContractMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_running

AIHubPortfolioRunningSuccessResponse get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query the list of running policies

Query the list of AIHub strategies currently running by the user, and support filtering by strategy type, trading pair and paging conditions.

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.BotApi(api_client)
strategy_type='strategy_type_example'# str | Filter by policy type (optional)market='market_example'# str | Filter by trading pair (optional)page=1# int | Page number, default 1 (optional) (default to 1)page_size=20# int | Paging size, default 20, maximum 50 (optional) (default to 20)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query the list of running policiesapi_response=api_instance.get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_running: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_typestrFilter by policy type[optional]
marketstrFilter by trading pair[optional]
pageintPage number, default 1[optional] [default to 1]
page_sizeintPaging size, default 20, maximum 50[optional] [default to 20]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioRunningSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_detail

AIHubPortfolioDetailSuccessResponse get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query order policy details

Both strategy_id and strategy_type must be passed in the request, where strategy_type is used to distribute to the underlying detailed implementation by strategy type.

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.BotApi(api_client)
strategy_id='strategy_id_example'# str | Policy IDstrategy_type='strategy_type_example'# str | Policy type; used for underlying detail distributionx_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query order policy detailsapi_response=api_instance.get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_idstrPolicy ID
strategy_typestrPolicy type; used for underlying detail distribution
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioDetailSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_portfolio_stop

AIHubPortfolioStopSuccessResponse post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Terminate a single running policy

Only one policy is allowed to be terminated per request. Risk warning and secondary confirmation are borne by the upper layer of OpenClaw; this interface is only responsible for executing stop.

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.BotApi(api_client)
ai_hub_portfolio_stop_request=gate_api.AIHubPortfolioStopRequest() # AIHubPortfolioStopRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Terminate a single running policyapi_response=api_instance.post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_portfolio_stop: %s\n"%e)

Parameters

NameTypeDescriptionNotes
ai_hub_portfolio_stop_requestAIHubPortfolioStopRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioStopSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

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

Latest commit

History

History
812 lines (628 loc) · 39.9 KB

File metadata and controls

812 lines (628 loc) · 39.9 KB

gate_api.BotApi

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

MethodHTTP requestDescription
get_ai_hub_strategy_recommendGET /bot/strategy/recommendGet AIHub strategy recommendations
post_ai_hub_spot_grid_createPOST /bot/spot-grid/createCreate spot grid
post_ai_hub_margin_grid_createPOST /bot/margin-grid/createCreate a lever grid
post_ai_hub_infinite_grid_createPOST /bot/infinite-grid/createCreate infinite grid
post_ai_hub_futures_grid_createPOST /bot/futures-grid/createCreate a contract grid
post_ai_hub_spot_martingale_createPOST /bot/spot-martingale/createCreate Spot Martin
post_ai_hub_contract_martingale_createPOST /bot/contract-martingale/createCreate contract martin
get_ai_hub_portfolio_runningGET /bot/portfolio/runningQuery the list of running policies
get_ai_hub_portfolio_detailGET /bot/portfolio/detailQuery order policy details
post_ai_hub_portfolio_stopPOST /bot/portfolio/stopTerminate a single running policy

get_ai_hub_strategy_recommend

AIHubDiscoverSuccessResponse get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Get AIHub strategy recommendations

The only formal interface for the discover domain. Support scenarios: - top1 - bundle - filter - refresh Constraints: - The active recommendation pool only contains spot_grid, futures_grid, spot_martingale - Can return but do not actively recommend infinite_grid, margin_grid - contract_martingale, smart-position, spot-future-arbitrage must not be returned - When scene=filter is used, only filtering by market, backtest_apr_gte, max_drawdown_lte is allowed - scene=refresh inherits the refresh context through refresh_recommendation_id; the official minimum format only requires strategy_type|market - If the upstream directly transmits the previous recommendation recommendation_id, the third paragraph backtest_id will currently be ignored.

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.BotApi(api_client)
market='market_example'# str | Trading pair, such as `BTC_USDT` (optional)strategy_type='strategy_type_example'# str | Recommended target policy type; `contract_martingale` not allowed (optional)direction='direction_example'# str | Market direction (optional)invest_amount='invest_amount_example'# str | Investment amount, string transparent transmission (optional)scene='scene_example'# str | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic. (optional)refresh_recommendation_id='refresh_recommendation_id_example'# str | It is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_type|market`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored. (optional)limit=56# int | Return quantity; when `scene=filter` is used, the actual results are up to 10 (optional)max_drawdown_lte='max_drawdown_lte_example'# str | Maximum drawdown limit (optional)backtest_apr_gte='backtest_apr_gte_example'# str | Backtest annualized lower limit (optional)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Get AIHub strategy recommendationsapi_response=api_instance.get_ai_hub_strategy_recommend(market=market, strategy_type=strategy_type, direction=direction, invest_amount=invest_amount, scene=scene, refresh_recommendation_id=refresh_recommendation_id, limit=limit, max_drawdown_lte=max_drawdown_lte, backtest_apr_gte=backtest_apr_gte, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_strategy_recommend: %s\n"%e)

Parameters

NameTypeDescriptionNotes
marketstrTrading pair, such as `BTC_USDT`[optional]
strategy_typestrRecommended target policy type; `contract_martingale` not allowed[optional]
directionstrMarket direction[optional]
invest_amountstrInvestment amount, string transparent transmission[optional]
scenestrRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional]
refresh_recommendation_idstrIt is recommended to refresh the context. Used when `scene=refresh` is used; when `scene` is empty but the field exists, bot-service will also automatically determine as `refresh`. The official minimum format is `strategy_typemarket`; if the `recommendation_id` of the previous recommendation is directly passed through, the third paragraph `backtest_id` will be ignored.
limitintReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
max_drawdown_ltestrMaximum drawdown limit[optional]
backtest_apr_gtestrBacktest annualized lower limit[optional]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubDiscoverSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_grid_create

AIHubCreateSuccessResponse post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

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.BotApi(api_client)
spot_grid_create_request=gate_api.SpotGridCreateRequest() # SpotGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create spot gridapi_response=api_instance.post_ai_hub_spot_grid_create(spot_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_grid_create_requestSpotGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_margin_grid_create

AIHubCreateSuccessResponse post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

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.BotApi(api_client)
margin_grid_create_request=gate_api.MarginGridCreateRequest() # MarginGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a lever gridapi_response=api_instance.post_ai_hub_margin_grid_create(margin_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_margin_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
margin_grid_create_requestMarginGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_infinite_grid_create

AIHubCreateSuccessResponse post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

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.BotApi(api_client)
infinite_grid_create_request=gate_api.InfiniteGridCreateRequest() # InfiniteGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create infinite gridapi_response=api_instance.post_ai_hub_infinite_grid_create(infinite_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_infinite_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
infinite_grid_create_requestInfiniteGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_futures_grid_create

AIHubCreateSuccessResponse post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

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.BotApi(api_client)
futures_grid_create_request=gate_api.FuturesGridCreateRequest() # FuturesGridCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create a contract gridapi_response=api_instance.post_ai_hub_futures_grid_create(futures_grid_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_futures_grid_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
futures_grid_create_requestFuturesGridCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_spot_martingale_create

AIHubCreateSuccessResponse post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create Spot Martin

Create a spot martingale strategy from the given parameters. Stop-loss semantics match the app / MartingaleBot: - Use create_params.stop_loss_per_cycle (ratio per round as a decimal string) for creation-side stop-loss; do not use stop_loss_price for creation logic. - Stop-loss prices shown on detail pages are computed per round by the engine; creation accepts optional create_params.trigger_price (trigger price).

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.BotApi(api_client)
spot_martingale_create_request=gate_api.SpotMartingaleCreateRequest() # SpotMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create Spot Martinapi_response=api_instance.post_ai_hub_spot_martingale_create(spot_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_spot_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
spot_martingale_create_requestSpotMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_contract_martingale_create

AIHubCreateSuccessResponse post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Create contract martin

Create a contract Martin strategy based on the input parameters.

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.BotApi(api_client)
contract_martingale_create_request=gate_api.ContractMartingaleCreateRequest() # ContractMartingaleCreateRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Create contract martinapi_response=api_instance.post_ai_hub_contract_martingale_create(contract_martingale_create_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_contract_martingale_create: %s\n"%e)

Parameters

NameTypeDescriptionNotes
contract_martingale_create_requestContractMartingaleCreateRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubCreateSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_running

AIHubPortfolioRunningSuccessResponse get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query the list of running policies

Query the list of AIHub strategies currently running by the user, and support filtering by strategy type, trading pair and paging conditions.

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.BotApi(api_client)
strategy_type='strategy_type_example'# str | Filter by policy type (optional)market='market_example'# str | Filter by trading pair (optional)page=1# int | Page number, default 1 (optional) (default to 1)page_size=20# int | Paging size, default 20, maximum 50 (optional) (default to 20)x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query the list of running policiesapi_response=api_instance.get_ai_hub_portfolio_running(strategy_type=strategy_type, market=market, page=page, page_size=page_size, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_running: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_typestrFilter by policy type[optional]
marketstrFilter by trading pair[optional]
pageintPage number, default 1[optional] [default to 1]
page_sizeintPaging size, default 20, maximum 50[optional] [default to 20]
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioRunningSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

get_ai_hub_portfolio_detail

AIHubPortfolioDetailSuccessResponse get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Query order policy details

Both strategy_id and strategy_type must be passed in the request, where strategy_type is used to distribute to the underlying detailed implementation by strategy type.

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.BotApi(api_client)
strategy_id='strategy_id_example'# str | Policy IDstrategy_type='strategy_type_example'# str | Policy type; used for underlying detail distributionx_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Query order policy detailsapi_response=api_instance.get_ai_hub_portfolio_detail(strategy_id, strategy_type, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->get_ai_hub_portfolio_detail: %s\n"%e)

Parameters

NameTypeDescriptionNotes
strategy_idstrPolicy ID
strategy_typestrPolicy type; used for underlying detail distribution
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioDetailSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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

post_ai_hub_portfolio_stop

AIHubPortfolioStopSuccessResponse post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)

Terminate a single running policy

Only one policy is allowed to be terminated per request. Risk warning and secondary confirmation are borne by the upper layer of OpenClaw; this interface is only responsible for executing stop.

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.BotApi(api_client)
ai_hub_portfolio_stop_request=gate_api.AIHubPortfolioStopRequest() # AIHubPortfolioStopRequest | x_gate_service_id='x_gate_service_id_example'# str | Call source identifier; injected by APIv4 if necessary (optional)x_gate_app_lang='x_gate_app_lang_example'# str | Language context, such as `zh-CN` / `en-US` (optional)x_request_id='x_request_id_example'# str | Request link ID; caller can transmit transparently (optional)x_trace_id='x_trace_id_example'# str | trace header; can be generated uniformly by APIv4 (optional)try:
# Terminate a single running policyapi_response=api_instance.post_ai_hub_portfolio_stop(ai_hub_portfolio_stop_request, x_gate_service_id=x_gate_service_id, x_gate_app_lang=x_gate_app_lang, x_request_id=x_request_id, x_trace_id=x_trace_id)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling BotApi->post_ai_hub_portfolio_stop: %s\n"%e)

Parameters

NameTypeDescriptionNotes
ai_hub_portfolio_stop_requestAIHubPortfolioStopRequest
x_gate_service_idstrCall source identifier; injected by APIv4 if necessary[optional]
x_gate_app_langstrLanguage context, such as `zh-CN` / `en-US`[optional]
x_request_idstrRequest link ID; caller can transmit transparently[optional]
x_trace_idstrtrace header; can be generated uniformly by APIv4[optional]

Return type

AIHubPortfolioStopSuccessResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Unified business response-

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