Skip to content

Latest commit

History

History
850 lines (676 loc) · 40.3 KB

File metadata and controls

850 lines (676 loc) · 40.3 KB

BotApi

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

MethodHTTP requestDescription
getAIHubStrategyRecommendGET /bot/strategy/recommendGet AIHub strategy recommendations
postAIHubSpotGridCreatePOST /bot/spot-grid/createCreate spot grid
postAIHubMarginGridCreatePOST /bot/margin-grid/createCreate a lever grid
postAIHubInfiniteGridCreatePOST /bot/infinite-grid/createCreate infinite grid
postAIHubFuturesGridCreatePOST /bot/futures-grid/createCreate a contract grid
postAIHubSpotMartingaleCreatePOST /bot/spot-martingale/createCreate Spot Martin
postAIHubContractMartingaleCreatePOST /bot/contract-martingale/createCreate contract martin
getAIHubPortfolioRunningGET /bot/portfolio/runningQuery the list of running policies
getAIHubPortfolioDetailGET /bot/portfolio/detailQuery order policy details
postAIHubPortfolioStopPOST /bot/portfolio/stopTerminate a single running policy

getAIHubStrategyRecommend

AIHubDiscoverSuccessResponse getAIHubStrategyRecommend().market(market).strategyType(strategyType).direction(direction).investAmount(investAmount).scene(scene).refreshRecommendationId(refreshRecommendationId).limit(limit).maxDrawdownLte(maxDrawdownLte).backtestAprGte(backtestAprGte).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
Stringmarket = "market_example"; // String | Trading pair, such as `BTC_USDT`StringstrategyType = "strategyType_example"; // String | Recommended target policy type; `contract_martingale` not allowedStringdirection = "direction_example"; // String | Market directionStringinvestAmount = "investAmount_example"; // String | Investment amount, string transparent transmissionStringscene = "scene_example"; // String | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic.StringrefreshRecommendationId = "refreshRecommendationId_example"; // String | 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.Integerlimit = 56; // Integer | Return quantity; when `scene=filter` is used, the actual results are up to 10StringmaxDrawdownLte = "maxDrawdownLte_example"; // String | Maximum drawdown limitStringbacktestAprGte = "backtestAprGte_example"; // String | Backtest annualized lower limitStringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubDiscoverSuccessResponseresult = apiInstance.getAIHubStrategyRecommend()
.market(market)
.strategyType(strategyType)
.direction(direction)
.investAmount(investAmount)
.scene(scene)
.refreshRecommendationId(refreshRecommendationId)
.limit(limit)
.maxDrawdownLte(maxDrawdownLte)
.backtestAprGte(backtestAprGte)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubStrategyRecommend");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
marketStringTrading pair, such as `BTC_USDT`[optional]
strategyTypeStringRecommended target policy type; `contract_martingale` not allowed[optional] [enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale]
directionStringMarket direction[optional] [enum: buy, sell, neutral]
investAmountStringInvestment amount, string transparent transmission[optional]
sceneStringRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional] [enum: top1, bundle, filter, refresh]
refreshRecommendationIdStringIt 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.
limitIntegerReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
maxDrawdownLteStringMaximum drawdown limit[optional]
backtestAprGteStringBacktest annualized lower limit[optional]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubSpotGridCreate

AIHubCreateSuccessResponse postAIHubSpotGridCreate(spotGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
SpotGridCreateRequestspotGridCreateRequest = newSpotGridCreateRequest(); // SpotGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubSpotGridCreate(spotGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubSpotGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
spotGridCreateRequestSpotGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubMarginGridCreate

AIHubCreateSuccessResponse postAIHubMarginGridCreate(marginGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
MarginGridCreateRequestmarginGridCreateRequest = newMarginGridCreateRequest(); // MarginGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubMarginGridCreate(marginGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubMarginGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
marginGridCreateRequestMarginGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubInfiniteGridCreate

AIHubCreateSuccessResponse postAIHubInfiniteGridCreate(infiniteGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
InfiniteGridCreateRequestinfiniteGridCreateRequest = newInfiniteGridCreateRequest(); // InfiniteGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubInfiniteGridCreate(infiniteGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubInfiniteGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
infiniteGridCreateRequestInfiniteGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubFuturesGridCreate

AIHubCreateSuccessResponse postAIHubFuturesGridCreate(futuresGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
FuturesGridCreateRequestfuturesGridCreateRequest = newFuturesGridCreateRequest(); // FuturesGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubFuturesGridCreate(futuresGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubFuturesGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
futuresGridCreateRequestFuturesGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubSpotMartingaleCreate

AIHubCreateSuccessResponse postAIHubSpotMartingaleCreate(spotMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
SpotMartingaleCreateRequestspotMartingaleCreateRequest = newSpotMartingaleCreateRequest(); // SpotMartingaleCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubSpotMartingaleCreate(spotMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubSpotMartingaleCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
spotMartingaleCreateRequestSpotMartingaleCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubContractMartingaleCreate

AIHubCreateSuccessResponse postAIHubContractMartingaleCreate(contractMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create contract martin

Create a contract Martin strategy based on the input parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
ContractMartingaleCreateRequestcontractMartingaleCreateRequest = newContractMartingaleCreateRequest(); // ContractMartingaleCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubContractMartingaleCreate(contractMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubContractMartingaleCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractMartingaleCreateRequestContractMartingaleCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

getAIHubPortfolioRunning

AIHubPortfolioRunningSuccessResponse getAIHubPortfolioRunning().strategyType(strategyType).market(market).page(page).pageSize(pageSize).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
StringstrategyType = "strategyType_example"; // String | Filter by policy typeStringmarket = "market_example"; // String | Filter by trading pairIntegerpage = 1; // Integer | Page number, default 1IntegerpageSize = 20; // Integer | Paging size, default 20, maximum 50StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioRunningSuccessResponseresult = apiInstance.getAIHubPortfolioRunning()
.strategyType(strategyType)
.market(market)
.page(page)
.pageSize(pageSize)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubPortfolioRunning");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
strategyTypeStringFilter by policy type[optional] [enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale, contract_martingale]
marketStringFilter by trading pair[optional]
pageIntegerPage number, default 1[optional] [default to 1]
pageSizeIntegerPaging size, default 20, maximum 50[optional] [default to 20]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

getAIHubPortfolioDetail

AIHubPortfolioDetailSuccessResponse getAIHubPortfolioDetail(strategyId, strategyType).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
StringstrategyId = "strategyId_example"; // String | Policy IDStringstrategyType = "strategyType_example"; // String | Policy type; used for underlying detail distributionStringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioDetailSuccessResponseresult = apiInstance.getAIHubPortfolioDetail(strategyId, strategyType)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubPortfolioDetail");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
strategyIdStringPolicy ID
strategyTypeStringPolicy type; used for underlying detail distribution[enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale, contract_martingale]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubPortfolioStop

AIHubPortfolioStopSuccessResponse postAIHubPortfolioStop(aiHubPortfolioStopRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
AIHubPortfolioStopRequestaiHubPortfolioStopRequest = newAIHubPortfolioStopRequest(); // AIHubPortfolioStopRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioStopSuccessResponseresult = apiInstance.postAIHubPortfolioStop(aiHubPortfolioStopRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubPortfolioStop");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
aiHubPortfolioStopRequestAIHubPortfolioStopRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-
, '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-java/docs/BotApi.md at master · gate/gateapi-java · GitHub
Skip to content

Latest commit

History

History
850 lines (676 loc) · 40.3 KB

File metadata and controls

850 lines (676 loc) · 40.3 KB

BotApi

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

MethodHTTP requestDescription
getAIHubStrategyRecommendGET /bot/strategy/recommendGet AIHub strategy recommendations
postAIHubSpotGridCreatePOST /bot/spot-grid/createCreate spot grid
postAIHubMarginGridCreatePOST /bot/margin-grid/createCreate a lever grid
postAIHubInfiniteGridCreatePOST /bot/infinite-grid/createCreate infinite grid
postAIHubFuturesGridCreatePOST /bot/futures-grid/createCreate a contract grid
postAIHubSpotMartingaleCreatePOST /bot/spot-martingale/createCreate Spot Martin
postAIHubContractMartingaleCreatePOST /bot/contract-martingale/createCreate contract martin
getAIHubPortfolioRunningGET /bot/portfolio/runningQuery the list of running policies
getAIHubPortfolioDetailGET /bot/portfolio/detailQuery order policy details
postAIHubPortfolioStopPOST /bot/portfolio/stopTerminate a single running policy

getAIHubStrategyRecommend

AIHubDiscoverSuccessResponse getAIHubStrategyRecommend().market(market).strategyType(strategyType).direction(direction).investAmount(investAmount).scene(scene).refreshRecommendationId(refreshRecommendationId).limit(limit).maxDrawdownLte(maxDrawdownLte).backtestAprGte(backtestAprGte).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
Stringmarket = "market_example"; // String | Trading pair, such as `BTC_USDT`StringstrategyType = "strategyType_example"; // String | Recommended target policy type; `contract_martingale` not allowedStringdirection = "direction_example"; // String | Market directionStringinvestAmount = "investAmount_example"; // String | Investment amount, string transparent transmissionStringscene = "scene_example"; // String | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic.StringrefreshRecommendationId = "refreshRecommendationId_example"; // String | 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.Integerlimit = 56; // Integer | Return quantity; when `scene=filter` is used, the actual results are up to 10StringmaxDrawdownLte = "maxDrawdownLte_example"; // String | Maximum drawdown limitStringbacktestAprGte = "backtestAprGte_example"; // String | Backtest annualized lower limitStringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubDiscoverSuccessResponseresult = apiInstance.getAIHubStrategyRecommend()
.market(market)
.strategyType(strategyType)
.direction(direction)
.investAmount(investAmount)
.scene(scene)
.refreshRecommendationId(refreshRecommendationId)
.limit(limit)
.maxDrawdownLte(maxDrawdownLte)
.backtestAprGte(backtestAprGte)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubStrategyRecommend");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
marketStringTrading pair, such as `BTC_USDT`[optional]
strategyTypeStringRecommended target policy type; `contract_martingale` not allowed[optional] [enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale]
directionStringMarket direction[optional] [enum: buy, sell, neutral]
investAmountStringInvestment amount, string transparent transmission[optional]
sceneStringRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional] [enum: top1, bundle, filter, refresh]
refreshRecommendationIdStringIt 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.
limitIntegerReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
maxDrawdownLteStringMaximum drawdown limit[optional]
backtestAprGteStringBacktest annualized lower limit[optional]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubSpotGridCreate

AIHubCreateSuccessResponse postAIHubSpotGridCreate(spotGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
SpotGridCreateRequestspotGridCreateRequest = newSpotGridCreateRequest(); // SpotGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubSpotGridCreate(spotGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubSpotGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
spotGridCreateRequestSpotGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubMarginGridCreate

AIHubCreateSuccessResponse postAIHubMarginGridCreate(marginGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
MarginGridCreateRequestmarginGridCreateRequest = newMarginGridCreateRequest(); // MarginGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubMarginGridCreate(marginGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubMarginGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
marginGridCreateRequestMarginGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubInfiniteGridCreate

AIHubCreateSuccessResponse postAIHubInfiniteGridCreate(infiniteGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
InfiniteGridCreateRequestinfiniteGridCreateRequest = newInfiniteGridCreateRequest(); // InfiniteGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubInfiniteGridCreate(infiniteGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubInfiniteGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
infiniteGridCreateRequestInfiniteGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubFuturesGridCreate

AIHubCreateSuccessResponse postAIHubFuturesGridCreate(futuresGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
FuturesGridCreateRequestfuturesGridCreateRequest = newFuturesGridCreateRequest(); // FuturesGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubFuturesGridCreate(futuresGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubFuturesGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
futuresGridCreateRequestFuturesGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubSpotMartingaleCreate

AIHubCreateSuccessResponse postAIHubSpotMartingaleCreate(spotMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
SpotMartingaleCreateRequestspotMartingaleCreateRequest = newSpotMartingaleCreateRequest(); // SpotMartingaleCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubSpotMartingaleCreate(spotMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubSpotMartingaleCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
spotMartingaleCreateRequestSpotMartingaleCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubContractMartingaleCreate

AIHubCreateSuccessResponse postAIHubContractMartingaleCreate(contractMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create contract martin

Create a contract Martin strategy based on the input parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
ContractMartingaleCreateRequestcontractMartingaleCreateRequest = newContractMartingaleCreateRequest(); // ContractMartingaleCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubContractMartingaleCreate(contractMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubContractMartingaleCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractMartingaleCreateRequestContractMartingaleCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

getAIHubPortfolioRunning

AIHubPortfolioRunningSuccessResponse getAIHubPortfolioRunning().strategyType(strategyType).market(market).page(page).pageSize(pageSize).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
StringstrategyType = "strategyType_example"; // String | Filter by policy typeStringmarket = "market_example"; // String | Filter by trading pairIntegerpage = 1; // Integer | Page number, default 1IntegerpageSize = 20; // Integer | Paging size, default 20, maximum 50StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioRunningSuccessResponseresult = apiInstance.getAIHubPortfolioRunning()
.strategyType(strategyType)
.market(market)
.page(page)
.pageSize(pageSize)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubPortfolioRunning");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
strategyTypeStringFilter by policy type[optional] [enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale, contract_martingale]
marketStringFilter by trading pair[optional]
pageIntegerPage number, default 1[optional] [default to 1]
pageSizeIntegerPaging size, default 20, maximum 50[optional] [default to 20]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

getAIHubPortfolioDetail

AIHubPortfolioDetailSuccessResponse getAIHubPortfolioDetail(strategyId, strategyType).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
StringstrategyId = "strategyId_example"; // String | Policy IDStringstrategyType = "strategyType_example"; // String | Policy type; used for underlying detail distributionStringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioDetailSuccessResponseresult = apiInstance.getAIHubPortfolioDetail(strategyId, strategyType)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubPortfolioDetail");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
strategyIdStringPolicy ID
strategyTypeStringPolicy type; used for underlying detail distribution[enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale, contract_martingale]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubPortfolioStop

AIHubPortfolioStopSuccessResponse postAIHubPortfolioStop(aiHubPortfolioStopRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
AIHubPortfolioStopRequestaiHubPortfolioStopRequest = newAIHubPortfolioStopRequest(); // AIHubPortfolioStopRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioStopSuccessResponseresult = apiInstance.postAIHubPortfolioStop(aiHubPortfolioStopRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubPortfolioStop");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
aiHubPortfolioStopRequestAIHubPortfolioStopRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-
, '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-java/docs/BotApi.md at master · gate/gateapi-java · GitHub
Skip to content

Latest commit

History

History
850 lines (676 loc) · 40.3 KB

File metadata and controls

850 lines (676 loc) · 40.3 KB

BotApi

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

MethodHTTP requestDescription
getAIHubStrategyRecommendGET /bot/strategy/recommendGet AIHub strategy recommendations
postAIHubSpotGridCreatePOST /bot/spot-grid/createCreate spot grid
postAIHubMarginGridCreatePOST /bot/margin-grid/createCreate a lever grid
postAIHubInfiniteGridCreatePOST /bot/infinite-grid/createCreate infinite grid
postAIHubFuturesGridCreatePOST /bot/futures-grid/createCreate a contract grid
postAIHubSpotMartingaleCreatePOST /bot/spot-martingale/createCreate Spot Martin
postAIHubContractMartingaleCreatePOST /bot/contract-martingale/createCreate contract martin
getAIHubPortfolioRunningGET /bot/portfolio/runningQuery the list of running policies
getAIHubPortfolioDetailGET /bot/portfolio/detailQuery order policy details
postAIHubPortfolioStopPOST /bot/portfolio/stopTerminate a single running policy

getAIHubStrategyRecommend

AIHubDiscoverSuccessResponse getAIHubStrategyRecommend().market(market).strategyType(strategyType).direction(direction).investAmount(investAmount).scene(scene).refreshRecommendationId(refreshRecommendationId).limit(limit).maxDrawdownLte(maxDrawdownLte).backtestAprGte(backtestAprGte).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
Stringmarket = "market_example"; // String | Trading pair, such as `BTC_USDT`StringstrategyType = "strategyType_example"; // String | Recommended target policy type; `contract_martingale` not allowedStringdirection = "direction_example"; // String | Market directionStringinvestAmount = "investAmount_example"; // String | Investment amount, string transparent transmissionStringscene = "scene_example"; // String | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic.StringrefreshRecommendationId = "refreshRecommendationId_example"; // String | 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.Integerlimit = 56; // Integer | Return quantity; when `scene=filter` is used, the actual results are up to 10StringmaxDrawdownLte = "maxDrawdownLte_example"; // String | Maximum drawdown limitStringbacktestAprGte = "backtestAprGte_example"; // String | Backtest annualized lower limitStringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubDiscoverSuccessResponseresult = apiInstance.getAIHubStrategyRecommend()
.market(market)
.strategyType(strategyType)
.direction(direction)
.investAmount(investAmount)
.scene(scene)
.refreshRecommendationId(refreshRecommendationId)
.limit(limit)
.maxDrawdownLte(maxDrawdownLte)
.backtestAprGte(backtestAprGte)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubStrategyRecommend");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
marketStringTrading pair, such as `BTC_USDT`[optional]
strategyTypeStringRecommended target policy type; `contract_martingale` not allowed[optional] [enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale]
directionStringMarket direction[optional] [enum: buy, sell, neutral]
investAmountStringInvestment amount, string transparent transmission[optional]
sceneStringRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional] [enum: top1, bundle, filter, refresh]
refreshRecommendationIdStringIt 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.
limitIntegerReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
maxDrawdownLteStringMaximum drawdown limit[optional]
backtestAprGteStringBacktest annualized lower limit[optional]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubSpotGridCreate

AIHubCreateSuccessResponse postAIHubSpotGridCreate(spotGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
SpotGridCreateRequestspotGridCreateRequest = newSpotGridCreateRequest(); // SpotGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubSpotGridCreate(spotGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubSpotGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
spotGridCreateRequestSpotGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubMarginGridCreate

AIHubCreateSuccessResponse postAIHubMarginGridCreate(marginGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
MarginGridCreateRequestmarginGridCreateRequest = newMarginGridCreateRequest(); // MarginGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubMarginGridCreate(marginGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubMarginGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
marginGridCreateRequestMarginGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubInfiniteGridCreate

AIHubCreateSuccessResponse postAIHubInfiniteGridCreate(infiniteGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
InfiniteGridCreateRequestinfiniteGridCreateRequest = newInfiniteGridCreateRequest(); // InfiniteGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubInfiniteGridCreate(infiniteGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubInfiniteGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
infiniteGridCreateRequestInfiniteGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubFuturesGridCreate

AIHubCreateSuccessResponse postAIHubFuturesGridCreate(futuresGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
FuturesGridCreateRequestfuturesGridCreateRequest = newFuturesGridCreateRequest(); // FuturesGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubFuturesGridCreate(futuresGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubFuturesGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
futuresGridCreateRequestFuturesGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubSpotMartingaleCreate

AIHubCreateSuccessResponse postAIHubSpotMartingaleCreate(spotMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
SpotMartingaleCreateRequestspotMartingaleCreateRequest = newSpotMartingaleCreateRequest(); // SpotMartingaleCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubSpotMartingaleCreate(spotMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubSpotMartingaleCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
spotMartingaleCreateRequestSpotMartingaleCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubContractMartingaleCreate

AIHubCreateSuccessResponse postAIHubContractMartingaleCreate(contractMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create contract martin

Create a contract Martin strategy based on the input parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
ContractMartingaleCreateRequestcontractMartingaleCreateRequest = newContractMartingaleCreateRequest(); // ContractMartingaleCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubContractMartingaleCreate(contractMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubContractMartingaleCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractMartingaleCreateRequestContractMartingaleCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

getAIHubPortfolioRunning

AIHubPortfolioRunningSuccessResponse getAIHubPortfolioRunning().strategyType(strategyType).market(market).page(page).pageSize(pageSize).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
StringstrategyType = "strategyType_example"; // String | Filter by policy typeStringmarket = "market_example"; // String | Filter by trading pairIntegerpage = 1; // Integer | Page number, default 1IntegerpageSize = 20; // Integer | Paging size, default 20, maximum 50StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioRunningSuccessResponseresult = apiInstance.getAIHubPortfolioRunning()
.strategyType(strategyType)
.market(market)
.page(page)
.pageSize(pageSize)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubPortfolioRunning");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
strategyTypeStringFilter by policy type[optional] [enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale, contract_martingale]
marketStringFilter by trading pair[optional]
pageIntegerPage number, default 1[optional] [default to 1]
pageSizeIntegerPaging size, default 20, maximum 50[optional] [default to 20]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

getAIHubPortfolioDetail

AIHubPortfolioDetailSuccessResponse getAIHubPortfolioDetail(strategyId, strategyType).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
StringstrategyId = "strategyId_example"; // String | Policy IDStringstrategyType = "strategyType_example"; // String | Policy type; used for underlying detail distributionStringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioDetailSuccessResponseresult = apiInstance.getAIHubPortfolioDetail(strategyId, strategyType)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubPortfolioDetail");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
strategyIdStringPolicy ID
strategyTypeStringPolicy type; used for underlying detail distribution[enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale, contract_martingale]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubPortfolioStop

AIHubPortfolioStopSuccessResponse postAIHubPortfolioStop(aiHubPortfolioStopRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
AIHubPortfolioStopRequestaiHubPortfolioStopRequest = newAIHubPortfolioStopRequest(); // AIHubPortfolioStopRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioStopSuccessResponseresult = apiInstance.postAIHubPortfolioStop(aiHubPortfolioStopRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubPortfolioStop");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
aiHubPortfolioStopRequestAIHubPortfolioStopRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-
, '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-java/docs/BotApi.md at master · gate/gateapi-java · GitHub
Skip to content

Latest commit

History

History
850 lines (676 loc) · 40.3 KB

File metadata and controls

850 lines (676 loc) · 40.3 KB

BotApi

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

MethodHTTP requestDescription
getAIHubStrategyRecommendGET /bot/strategy/recommendGet AIHub strategy recommendations
postAIHubSpotGridCreatePOST /bot/spot-grid/createCreate spot grid
postAIHubMarginGridCreatePOST /bot/margin-grid/createCreate a lever grid
postAIHubInfiniteGridCreatePOST /bot/infinite-grid/createCreate infinite grid
postAIHubFuturesGridCreatePOST /bot/futures-grid/createCreate a contract grid
postAIHubSpotMartingaleCreatePOST /bot/spot-martingale/createCreate Spot Martin
postAIHubContractMartingaleCreatePOST /bot/contract-martingale/createCreate contract martin
getAIHubPortfolioRunningGET /bot/portfolio/runningQuery the list of running policies
getAIHubPortfolioDetailGET /bot/portfolio/detailQuery order policy details
postAIHubPortfolioStopPOST /bot/portfolio/stopTerminate a single running policy

getAIHubStrategyRecommend

AIHubDiscoverSuccessResponse getAIHubStrategyRecommend().market(market).strategyType(strategyType).direction(direction).investAmount(investAmount).scene(scene).refreshRecommendationId(refreshRecommendationId).limit(limit).maxDrawdownLte(maxDrawdownLte).backtestAprGte(backtestAprGte).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
Stringmarket = "market_example"; // String | Trading pair, such as `BTC_USDT`StringstrategyType = "strategyType_example"; // String | Recommended target policy type; `contract_martingale` not allowedStringdirection = "direction_example"; // String | Market directionStringinvestAmount = "investAmount_example"; // String | Investment amount, string transparent transmissionStringscene = "scene_example"; // String | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic.StringrefreshRecommendationId = "refreshRecommendationId_example"; // String | 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.Integerlimit = 56; // Integer | Return quantity; when `scene=filter` is used, the actual results are up to 10StringmaxDrawdownLte = "maxDrawdownLte_example"; // String | Maximum drawdown limitStringbacktestAprGte = "backtestAprGte_example"; // String | Backtest annualized lower limitStringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubDiscoverSuccessResponseresult = apiInstance.getAIHubStrategyRecommend()
.market(market)
.strategyType(strategyType)
.direction(direction)
.investAmount(investAmount)
.scene(scene)
.refreshRecommendationId(refreshRecommendationId)
.limit(limit)
.maxDrawdownLte(maxDrawdownLte)
.backtestAprGte(backtestAprGte)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubStrategyRecommend");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
marketStringTrading pair, such as `BTC_USDT`[optional]
strategyTypeStringRecommended target policy type; `contract_martingale` not allowed[optional] [enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale]
directionStringMarket direction[optional] [enum: buy, sell, neutral]
investAmountStringInvestment amount, string transparent transmission[optional]
sceneStringRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional] [enum: top1, bundle, filter, refresh]
refreshRecommendationIdStringIt 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.
limitIntegerReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
maxDrawdownLteStringMaximum drawdown limit[optional]
backtestAprGteStringBacktest annualized lower limit[optional]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubSpotGridCreate

AIHubCreateSuccessResponse postAIHubSpotGridCreate(spotGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
SpotGridCreateRequestspotGridCreateRequest = newSpotGridCreateRequest(); // SpotGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubSpotGridCreate(spotGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubSpotGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
spotGridCreateRequestSpotGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubMarginGridCreate

AIHubCreateSuccessResponse postAIHubMarginGridCreate(marginGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
MarginGridCreateRequestmarginGridCreateRequest = newMarginGridCreateRequest(); // MarginGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubMarginGridCreate(marginGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubMarginGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
marginGridCreateRequestMarginGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubInfiniteGridCreate

AIHubCreateSuccessResponse postAIHubInfiniteGridCreate(infiniteGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
InfiniteGridCreateRequestinfiniteGridCreateRequest = newInfiniteGridCreateRequest(); // InfiniteGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubInfiniteGridCreate(infiniteGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubInfiniteGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
infiniteGridCreateRequestInfiniteGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubFuturesGridCreate

AIHubCreateSuccessResponse postAIHubFuturesGridCreate(futuresGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
FuturesGridCreateRequestfuturesGridCreateRequest = newFuturesGridCreateRequest(); // FuturesGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubFuturesGridCreate(futuresGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubFuturesGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
futuresGridCreateRequestFuturesGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubSpotMartingaleCreate

AIHubCreateSuccessResponse postAIHubSpotMartingaleCreate(spotMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
SpotMartingaleCreateRequestspotMartingaleCreateRequest = newSpotMartingaleCreateRequest(); // SpotMartingaleCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubSpotMartingaleCreate(spotMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubSpotMartingaleCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
spotMartingaleCreateRequestSpotMartingaleCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubContractMartingaleCreate

AIHubCreateSuccessResponse postAIHubContractMartingaleCreate(contractMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create contract martin

Create a contract Martin strategy based on the input parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
ContractMartingaleCreateRequestcontractMartingaleCreateRequest = newContractMartingaleCreateRequest(); // ContractMartingaleCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubContractMartingaleCreate(contractMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubContractMartingaleCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractMartingaleCreateRequestContractMartingaleCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

getAIHubPortfolioRunning

AIHubPortfolioRunningSuccessResponse getAIHubPortfolioRunning().strategyType(strategyType).market(market).page(page).pageSize(pageSize).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
StringstrategyType = "strategyType_example"; // String | Filter by policy typeStringmarket = "market_example"; // String | Filter by trading pairIntegerpage = 1; // Integer | Page number, default 1IntegerpageSize = 20; // Integer | Paging size, default 20, maximum 50StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioRunningSuccessResponseresult = apiInstance.getAIHubPortfolioRunning()
.strategyType(strategyType)
.market(market)
.page(page)
.pageSize(pageSize)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubPortfolioRunning");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
strategyTypeStringFilter by policy type[optional] [enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale, contract_martingale]
marketStringFilter by trading pair[optional]
pageIntegerPage number, default 1[optional] [default to 1]
pageSizeIntegerPaging size, default 20, maximum 50[optional] [default to 20]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

getAIHubPortfolioDetail

AIHubPortfolioDetailSuccessResponse getAIHubPortfolioDetail(strategyId, strategyType).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
StringstrategyId = "strategyId_example"; // String | Policy IDStringstrategyType = "strategyType_example"; // String | Policy type; used for underlying detail distributionStringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioDetailSuccessResponseresult = apiInstance.getAIHubPortfolioDetail(strategyId, strategyType)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubPortfolioDetail");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
strategyIdStringPolicy ID
strategyTypeStringPolicy type; used for underlying detail distribution[enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale, contract_martingale]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubPortfolioStop

AIHubPortfolioStopSuccessResponse postAIHubPortfolioStop(aiHubPortfolioStopRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
AIHubPortfolioStopRequestaiHubPortfolioStopRequest = newAIHubPortfolioStopRequest(); // AIHubPortfolioStopRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioStopSuccessResponseresult = apiInstance.postAIHubPortfolioStop(aiHubPortfolioStopRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubPortfolioStop");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
aiHubPortfolioStopRequestAIHubPortfolioStopRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-
, '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-java/docs/BotApi.md at master · gate/gateapi-java · GitHub
Skip to content

Latest commit

History

History
850 lines (676 loc) · 40.3 KB

File metadata and controls

850 lines (676 loc) · 40.3 KB

BotApi

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

MethodHTTP requestDescription
getAIHubStrategyRecommendGET /bot/strategy/recommendGet AIHub strategy recommendations
postAIHubSpotGridCreatePOST /bot/spot-grid/createCreate spot grid
postAIHubMarginGridCreatePOST /bot/margin-grid/createCreate a lever grid
postAIHubInfiniteGridCreatePOST /bot/infinite-grid/createCreate infinite grid
postAIHubFuturesGridCreatePOST /bot/futures-grid/createCreate a contract grid
postAIHubSpotMartingaleCreatePOST /bot/spot-martingale/createCreate Spot Martin
postAIHubContractMartingaleCreatePOST /bot/contract-martingale/createCreate contract martin
getAIHubPortfolioRunningGET /bot/portfolio/runningQuery the list of running policies
getAIHubPortfolioDetailGET /bot/portfolio/detailQuery order policy details
postAIHubPortfolioStopPOST /bot/portfolio/stopTerminate a single running policy

getAIHubStrategyRecommend

AIHubDiscoverSuccessResponse getAIHubStrategyRecommend().market(market).strategyType(strategyType).direction(direction).investAmount(investAmount).scene(scene).refreshRecommendationId(refreshRecommendationId).limit(limit).maxDrawdownLte(maxDrawdownLte).backtestAprGte(backtestAprGte).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
Stringmarket = "market_example"; // String | Trading pair, such as `BTC_USDT`StringstrategyType = "strategyType_example"; // String | Recommended target policy type; `contract_martingale` not allowedStringdirection = "direction_example"; // String | Market directionStringinvestAmount = "investAmount_example"; // String | Investment amount, string transparent transmissionStringscene = "scene_example"; // String | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic.StringrefreshRecommendationId = "refreshRecommendationId_example"; // String | 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.Integerlimit = 56; // Integer | Return quantity; when `scene=filter` is used, the actual results are up to 10StringmaxDrawdownLte = "maxDrawdownLte_example"; // String | Maximum drawdown limitStringbacktestAprGte = "backtestAprGte_example"; // String | Backtest annualized lower limitStringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubDiscoverSuccessResponseresult = apiInstance.getAIHubStrategyRecommend()
.market(market)
.strategyType(strategyType)
.direction(direction)
.investAmount(investAmount)
.scene(scene)
.refreshRecommendationId(refreshRecommendationId)
.limit(limit)
.maxDrawdownLte(maxDrawdownLte)
.backtestAprGte(backtestAprGte)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubStrategyRecommend");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
marketStringTrading pair, such as `BTC_USDT`[optional]
strategyTypeStringRecommended target policy type; `contract_martingale` not allowed[optional] [enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale]
directionStringMarket direction[optional] [enum: buy, sell, neutral]
investAmountStringInvestment amount, string transparent transmission[optional]
sceneStringRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional] [enum: top1, bundle, filter, refresh]
refreshRecommendationIdStringIt 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.
limitIntegerReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
maxDrawdownLteStringMaximum drawdown limit[optional]
backtestAprGteStringBacktest annualized lower limit[optional]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubSpotGridCreate

AIHubCreateSuccessResponse postAIHubSpotGridCreate(spotGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
SpotGridCreateRequestspotGridCreateRequest = newSpotGridCreateRequest(); // SpotGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubSpotGridCreate(spotGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubSpotGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
spotGridCreateRequestSpotGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubMarginGridCreate

AIHubCreateSuccessResponse postAIHubMarginGridCreate(marginGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
MarginGridCreateRequestmarginGridCreateRequest = newMarginGridCreateRequest(); // MarginGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubMarginGridCreate(marginGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubMarginGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
marginGridCreateRequestMarginGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubInfiniteGridCreate

AIHubCreateSuccessResponse postAIHubInfiniteGridCreate(infiniteGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
InfiniteGridCreateRequestinfiniteGridCreateRequest = newInfiniteGridCreateRequest(); // InfiniteGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubInfiniteGridCreate(infiniteGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubInfiniteGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
infiniteGridCreateRequestInfiniteGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubFuturesGridCreate

AIHubCreateSuccessResponse postAIHubFuturesGridCreate(futuresGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
FuturesGridCreateRequestfuturesGridCreateRequest = newFuturesGridCreateRequest(); // FuturesGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubFuturesGridCreate(futuresGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubFuturesGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
futuresGridCreateRequestFuturesGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubSpotMartingaleCreate

AIHubCreateSuccessResponse postAIHubSpotMartingaleCreate(spotMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
SpotMartingaleCreateRequestspotMartingaleCreateRequest = newSpotMartingaleCreateRequest(); // SpotMartingaleCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubSpotMartingaleCreate(spotMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubSpotMartingaleCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
spotMartingaleCreateRequestSpotMartingaleCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubContractMartingaleCreate

AIHubCreateSuccessResponse postAIHubContractMartingaleCreate(contractMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create contract martin

Create a contract Martin strategy based on the input parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
ContractMartingaleCreateRequestcontractMartingaleCreateRequest = newContractMartingaleCreateRequest(); // ContractMartingaleCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubContractMartingaleCreate(contractMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubContractMartingaleCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractMartingaleCreateRequestContractMartingaleCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

getAIHubPortfolioRunning

AIHubPortfolioRunningSuccessResponse getAIHubPortfolioRunning().strategyType(strategyType).market(market).page(page).pageSize(pageSize).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
StringstrategyType = "strategyType_example"; // String | Filter by policy typeStringmarket = "market_example"; // String | Filter by trading pairIntegerpage = 1; // Integer | Page number, default 1IntegerpageSize = 20; // Integer | Paging size, default 20, maximum 50StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioRunningSuccessResponseresult = apiInstance.getAIHubPortfolioRunning()
.strategyType(strategyType)
.market(market)
.page(page)
.pageSize(pageSize)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubPortfolioRunning");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
strategyTypeStringFilter by policy type[optional] [enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale, contract_martingale]
marketStringFilter by trading pair[optional]
pageIntegerPage number, default 1[optional] [default to 1]
pageSizeIntegerPaging size, default 20, maximum 50[optional] [default to 20]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

getAIHubPortfolioDetail

AIHubPortfolioDetailSuccessResponse getAIHubPortfolioDetail(strategyId, strategyType).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
StringstrategyId = "strategyId_example"; // String | Policy IDStringstrategyType = "strategyType_example"; // String | Policy type; used for underlying detail distributionStringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioDetailSuccessResponseresult = apiInstance.getAIHubPortfolioDetail(strategyId, strategyType)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubPortfolioDetail");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
strategyIdStringPolicy ID
strategyTypeStringPolicy type; used for underlying detail distribution[enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale, contract_martingale]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubPortfolioStop

AIHubPortfolioStopSuccessResponse postAIHubPortfolioStop(aiHubPortfolioStopRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
AIHubPortfolioStopRequestaiHubPortfolioStopRequest = newAIHubPortfolioStopRequest(); // AIHubPortfolioStopRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioStopSuccessResponseresult = apiInstance.postAIHubPortfolioStop(aiHubPortfolioStopRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubPortfolioStop");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
aiHubPortfolioStopRequestAIHubPortfolioStopRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-
, '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-java/docs/BotApi.md at master · gate/gateapi-java · GitHub
Skip to content

Latest commit

History

History
850 lines (676 loc) · 40.3 KB

File metadata and controls

850 lines (676 loc) · 40.3 KB

BotApi

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

MethodHTTP requestDescription
getAIHubStrategyRecommendGET /bot/strategy/recommendGet AIHub strategy recommendations
postAIHubSpotGridCreatePOST /bot/spot-grid/createCreate spot grid
postAIHubMarginGridCreatePOST /bot/margin-grid/createCreate a lever grid
postAIHubInfiniteGridCreatePOST /bot/infinite-grid/createCreate infinite grid
postAIHubFuturesGridCreatePOST /bot/futures-grid/createCreate a contract grid
postAIHubSpotMartingaleCreatePOST /bot/spot-martingale/createCreate Spot Martin
postAIHubContractMartingaleCreatePOST /bot/contract-martingale/createCreate contract martin
getAIHubPortfolioRunningGET /bot/portfolio/runningQuery the list of running policies
getAIHubPortfolioDetailGET /bot/portfolio/detailQuery order policy details
postAIHubPortfolioStopPOST /bot/portfolio/stopTerminate a single running policy

getAIHubStrategyRecommend

AIHubDiscoverSuccessResponse getAIHubStrategyRecommend().market(market).strategyType(strategyType).direction(direction).investAmount(investAmount).scene(scene).refreshRecommendationId(refreshRecommendationId).limit(limit).maxDrawdownLte(maxDrawdownLte).backtestAprGte(backtestAprGte).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
Stringmarket = "market_example"; // String | Trading pair, such as `BTC_USDT`StringstrategyType = "strategyType_example"; // String | Recommended target policy type; `contract_martingale` not allowedStringdirection = "direction_example"; // String | Market directionStringinvestAmount = "investAmount_example"; // String | Investment amount, string transparent transmissionStringscene = "scene_example"; // String | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic.StringrefreshRecommendationId = "refreshRecommendationId_example"; // String | 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.Integerlimit = 56; // Integer | Return quantity; when `scene=filter` is used, the actual results are up to 10StringmaxDrawdownLte = "maxDrawdownLte_example"; // String | Maximum drawdown limitStringbacktestAprGte = "backtestAprGte_example"; // String | Backtest annualized lower limitStringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubDiscoverSuccessResponseresult = apiInstance.getAIHubStrategyRecommend()
.market(market)
.strategyType(strategyType)
.direction(direction)
.investAmount(investAmount)
.scene(scene)
.refreshRecommendationId(refreshRecommendationId)
.limit(limit)
.maxDrawdownLte(maxDrawdownLte)
.backtestAprGte(backtestAprGte)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubStrategyRecommend");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
marketStringTrading pair, such as `BTC_USDT`[optional]
strategyTypeStringRecommended target policy type; `contract_martingale` not allowed[optional] [enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale]
directionStringMarket direction[optional] [enum: buy, sell, neutral]
investAmountStringInvestment amount, string transparent transmission[optional]
sceneStringRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional] [enum: top1, bundle, filter, refresh]
refreshRecommendationIdStringIt 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.
limitIntegerReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
maxDrawdownLteStringMaximum drawdown limit[optional]
backtestAprGteStringBacktest annualized lower limit[optional]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubSpotGridCreate

AIHubCreateSuccessResponse postAIHubSpotGridCreate(spotGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
SpotGridCreateRequestspotGridCreateRequest = newSpotGridCreateRequest(); // SpotGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubSpotGridCreate(spotGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubSpotGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
spotGridCreateRequestSpotGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubMarginGridCreate

AIHubCreateSuccessResponse postAIHubMarginGridCreate(marginGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
MarginGridCreateRequestmarginGridCreateRequest = newMarginGridCreateRequest(); // MarginGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubMarginGridCreate(marginGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubMarginGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
marginGridCreateRequestMarginGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubInfiniteGridCreate

AIHubCreateSuccessResponse postAIHubInfiniteGridCreate(infiniteGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
InfiniteGridCreateRequestinfiniteGridCreateRequest = newInfiniteGridCreateRequest(); // InfiniteGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubInfiniteGridCreate(infiniteGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubInfiniteGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
infiniteGridCreateRequestInfiniteGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubFuturesGridCreate

AIHubCreateSuccessResponse postAIHubFuturesGridCreate(futuresGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
FuturesGridCreateRequestfuturesGridCreateRequest = newFuturesGridCreateRequest(); // FuturesGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubFuturesGridCreate(futuresGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubFuturesGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
futuresGridCreateRequestFuturesGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubSpotMartingaleCreate

AIHubCreateSuccessResponse postAIHubSpotMartingaleCreate(spotMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
SpotMartingaleCreateRequestspotMartingaleCreateRequest = newSpotMartingaleCreateRequest(); // SpotMartingaleCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubSpotMartingaleCreate(spotMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubSpotMartingaleCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
spotMartingaleCreateRequestSpotMartingaleCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubContractMartingaleCreate

AIHubCreateSuccessResponse postAIHubContractMartingaleCreate(contractMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create contract martin

Create a contract Martin strategy based on the input parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
ContractMartingaleCreateRequestcontractMartingaleCreateRequest = newContractMartingaleCreateRequest(); // ContractMartingaleCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubContractMartingaleCreate(contractMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubContractMartingaleCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractMartingaleCreateRequestContractMartingaleCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

getAIHubPortfolioRunning

AIHubPortfolioRunningSuccessResponse getAIHubPortfolioRunning().strategyType(strategyType).market(market).page(page).pageSize(pageSize).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
StringstrategyType = "strategyType_example"; // String | Filter by policy typeStringmarket = "market_example"; // String | Filter by trading pairIntegerpage = 1; // Integer | Page number, default 1IntegerpageSize = 20; // Integer | Paging size, default 20, maximum 50StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioRunningSuccessResponseresult = apiInstance.getAIHubPortfolioRunning()
.strategyType(strategyType)
.market(market)
.page(page)
.pageSize(pageSize)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubPortfolioRunning");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
strategyTypeStringFilter by policy type[optional] [enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale, contract_martingale]
marketStringFilter by trading pair[optional]
pageIntegerPage number, default 1[optional] [default to 1]
pageSizeIntegerPaging size, default 20, maximum 50[optional] [default to 20]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

getAIHubPortfolioDetail

AIHubPortfolioDetailSuccessResponse getAIHubPortfolioDetail(strategyId, strategyType).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
StringstrategyId = "strategyId_example"; // String | Policy IDStringstrategyType = "strategyType_example"; // String | Policy type; used for underlying detail distributionStringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioDetailSuccessResponseresult = apiInstance.getAIHubPortfolioDetail(strategyId, strategyType)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubPortfolioDetail");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
strategyIdStringPolicy ID
strategyTypeStringPolicy type; used for underlying detail distribution[enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale, contract_martingale]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubPortfolioStop

AIHubPortfolioStopSuccessResponse postAIHubPortfolioStop(aiHubPortfolioStopRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
AIHubPortfolioStopRequestaiHubPortfolioStopRequest = newAIHubPortfolioStopRequest(); // AIHubPortfolioStopRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioStopSuccessResponseresult = apiInstance.postAIHubPortfolioStop(aiHubPortfolioStopRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubPortfolioStop");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
aiHubPortfolioStopRequestAIHubPortfolioStopRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-
, '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); } })(); })(); gateapi-java/docs/BotApi.md at master · gate/gateapi-java · GitHub
Skip to content

Latest commit

History

History
850 lines (676 loc) · 40.3 KB

File metadata and controls

850 lines (676 loc) · 40.3 KB

BotApi

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

MethodHTTP requestDescription
getAIHubStrategyRecommendGET /bot/strategy/recommendGet AIHub strategy recommendations
postAIHubSpotGridCreatePOST /bot/spot-grid/createCreate spot grid
postAIHubMarginGridCreatePOST /bot/margin-grid/createCreate a lever grid
postAIHubInfiniteGridCreatePOST /bot/infinite-grid/createCreate infinite grid
postAIHubFuturesGridCreatePOST /bot/futures-grid/createCreate a contract grid
postAIHubSpotMartingaleCreatePOST /bot/spot-martingale/createCreate Spot Martin
postAIHubContractMartingaleCreatePOST /bot/contract-martingale/createCreate contract martin
getAIHubPortfolioRunningGET /bot/portfolio/runningQuery the list of running policies
getAIHubPortfolioDetailGET /bot/portfolio/detailQuery order policy details
postAIHubPortfolioStopPOST /bot/portfolio/stopTerminate a single running policy

getAIHubStrategyRecommend

AIHubDiscoverSuccessResponse getAIHubStrategyRecommend().market(market).strategyType(strategyType).direction(direction).investAmount(investAmount).scene(scene).refreshRecommendationId(refreshRecommendationId).limit(limit).maxDrawdownLte(maxDrawdownLte).backtestAprGte(backtestAprGte).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
Stringmarket = "market_example"; // String | Trading pair, such as `BTC_USDT`StringstrategyType = "strategyType_example"; // String | Recommended target policy type; `contract_martingale` not allowedStringdirection = "direction_example"; // String | Market directionStringinvestAmount = "investAmount_example"; // String | Investment amount, string transparent transmissionStringscene = "scene_example"; // String | Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic.StringrefreshRecommendationId = "refreshRecommendationId_example"; // String | 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.Integerlimit = 56; // Integer | Return quantity; when `scene=filter` is used, the actual results are up to 10StringmaxDrawdownLte = "maxDrawdownLte_example"; // String | Maximum drawdown limitStringbacktestAprGte = "backtestAprGte_example"; // String | Backtest annualized lower limitStringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubDiscoverSuccessResponseresult = apiInstance.getAIHubStrategyRecommend()
.market(market)
.strategyType(strategyType)
.direction(direction)
.investAmount(investAmount)
.scene(scene)
.refreshRecommendationId(refreshRecommendationId)
.limit(limit)
.maxDrawdownLte(maxDrawdownLte)
.backtestAprGte(backtestAprGte)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubStrategyRecommend");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
marketStringTrading pair, such as `BTC_USDT`[optional]
strategyTypeStringRecommended target policy type; `contract_martingale` not allowed[optional] [enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale]
directionStringMarket direction[optional] [enum: buy, sell, neutral]
investAmountStringInvestment amount, string transparent transmission[optional]
sceneStringRecommended scenario; when empty, bot-service can automatically infer according to the implementation logic.[optional] [enum: top1, bundle, filter, refresh]
refreshRecommendationIdStringIt 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.
limitIntegerReturn quantity; when `scene=filter` is used, the actual results are up to 10[optional]
maxDrawdownLteStringMaximum drawdown limit[optional]
backtestAprGteStringBacktest annualized lower limit[optional]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubSpotGridCreate

AIHubCreateSuccessResponse postAIHubSpotGridCreate(spotGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create spot grid

Create a spot grid strategy based on the incoming parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
SpotGridCreateRequestspotGridCreateRequest = newSpotGridCreateRequest(); // SpotGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubSpotGridCreate(spotGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubSpotGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
spotGridCreateRequestSpotGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubMarginGridCreate

AIHubCreateSuccessResponse postAIHubMarginGridCreate(marginGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
MarginGridCreateRequestmarginGridCreateRequest = newMarginGridCreateRequest(); // MarginGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubMarginGridCreate(marginGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubMarginGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
marginGridCreateRequestMarginGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubInfiniteGridCreate

AIHubCreateSuccessResponse postAIHubInfiniteGridCreate(infiniteGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create infinite grid

Create an infinite grid strategy based on passed parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
InfiniteGridCreateRequestinfiniteGridCreateRequest = newInfiniteGridCreateRequest(); // InfiniteGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubInfiniteGridCreate(infiniteGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubInfiniteGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
infiniteGridCreateRequestInfiniteGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubFuturesGridCreate

AIHubCreateSuccessResponse postAIHubFuturesGridCreate(futuresGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
FuturesGridCreateRequestfuturesGridCreateRequest = newFuturesGridCreateRequest(); // FuturesGridCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubFuturesGridCreate(futuresGridCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubFuturesGridCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
futuresGridCreateRequestFuturesGridCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubSpotMartingaleCreate

AIHubCreateSuccessResponse postAIHubSpotMartingaleCreate(spotMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
SpotMartingaleCreateRequestspotMartingaleCreateRequest = newSpotMartingaleCreateRequest(); // SpotMartingaleCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubSpotMartingaleCreate(spotMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubSpotMartingaleCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
spotMartingaleCreateRequestSpotMartingaleCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubContractMartingaleCreate

AIHubCreateSuccessResponse postAIHubContractMartingaleCreate(contractMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

Create contract martin

Create a contract Martin strategy based on the input parameters.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
ContractMartingaleCreateRequestcontractMartingaleCreateRequest = newContractMartingaleCreateRequest(); // ContractMartingaleCreateRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubCreateSuccessResponseresult = apiInstance.postAIHubContractMartingaleCreate(contractMartingaleCreateRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubContractMartingaleCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractMartingaleCreateRequestContractMartingaleCreateRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

getAIHubPortfolioRunning

AIHubPortfolioRunningSuccessResponse getAIHubPortfolioRunning().strategyType(strategyType).market(market).page(page).pageSize(pageSize).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
StringstrategyType = "strategyType_example"; // String | Filter by policy typeStringmarket = "market_example"; // String | Filter by trading pairIntegerpage = 1; // Integer | Page number, default 1IntegerpageSize = 20; // Integer | Paging size, default 20, maximum 50StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioRunningSuccessResponseresult = apiInstance.getAIHubPortfolioRunning()
.strategyType(strategyType)
.market(market)
.page(page)
.pageSize(pageSize)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubPortfolioRunning");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
strategyTypeStringFilter by policy type[optional] [enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale, contract_martingale]
marketStringFilter by trading pair[optional]
pageIntegerPage number, default 1[optional] [default to 1]
pageSizeIntegerPaging size, default 20, maximum 50[optional] [default to 20]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

getAIHubPortfolioDetail

AIHubPortfolioDetailSuccessResponse getAIHubPortfolioDetail(strategyId, strategyType).xGateServiceId(xGateServiceId).xGateAppLang(xGateAppLang).xRequestId(xRequestId).xTraceId(xTraceId).execute();

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
StringstrategyId = "strategyId_example"; // String | Policy IDStringstrategyType = "strategyType_example"; // String | Policy type; used for underlying detail distributionStringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioDetailSuccessResponseresult = apiInstance.getAIHubPortfolioDetail(strategyId, strategyType)
.xGateServiceId(xGateServiceId)
.xGateAppLang(xGateAppLang)
.xRequestId(xRequestId)
.xTraceId(xTraceId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#getAIHubPortfolioDetail");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
strategyIdStringPolicy ID
strategyTypeStringPolicy type; used for underlying detail distribution[enum: spot_grid, margin_grid, infinite_grid, futures_grid, spot_martingale, contract_martingale]
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-

postAIHubPortfolioStop

AIHubPortfolioStopSuccessResponse postAIHubPortfolioStop(aiHubPortfolioStopRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId)

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

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.BotApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
BotApiapiInstance = newBotApi(defaultClient);
AIHubPortfolioStopRequestaiHubPortfolioStopRequest = newAIHubPortfolioStopRequest(); // AIHubPortfolioStopRequest | StringxGateServiceId = "xGateServiceId_example"; // String | Call source identifier; injected by APIv4 if necessaryStringxGateAppLang = "xGateAppLang_example"; // String | Language context, such as `zh-CN` / `en-US`StringxRequestId = "xRequestId_example"; // String | Request link ID; caller can transmit transparentlyStringxTraceId = "xTraceId_example"; // String | trace header; can be generated uniformly by APIv4try {
AIHubPortfolioStopSuccessResponseresult = apiInstance.postAIHubPortfolioStop(aiHubPortfolioStopRequest, xGateServiceId, xGateAppLang, xRequestId, xTraceId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling BotApi#postAIHubPortfolioStop");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
aiHubPortfolioStopRequestAIHubPortfolioStopRequest
xGateServiceIdStringCall source identifier; injected by APIv4 if necessary[optional]
xGateAppLangStringLanguage context, such as `zh-CN` / `en-US`[optional]
xRequestIdStringRequest link ID; caller can transmit transparently[optional]
xTraceIdStringtrace 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-