Skip to content

# Bot

Bot AIHub policy recommendation, creation, query and termination interface

# Get AIHub strategy recommendations

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/bot/strategy/recommend'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/bot/strategy/recommend"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /bot/strategy/recommend

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.

Parameters

Name In Type Required Description
market query string false Trading pair, such as BTC_USDT
strategy_type query string false Recommended target policy type; contract_martingale not allowed
direction query string false Market direction
invest_amount query string false Investment amount, string transparent transmission
scene query string false Recommended scenario; when empty, bot-service can automatically infer according to the implementation logic.
refresh_recommendation_id query string false 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.
limit query integer(int32) false Return quantity; when scene=filter is used, the actual results are up to 10
max_drawdown_lte query string false Maximum drawdown limit
backtest_apr_gte query string false Backtest annualized lower limit
X-Gate-Service-Id header string false Call source identifier; injected by APIv4 if necessary
X-Gate-AppLang header string false Language context, such as zh-CN / en-US
X-Request-Id header string false Request link ID; caller can transmit transparently
X-Trace-Id header string false trace header; can be generated uniformly by APIv4

# Detailed descriptions

refresh_recommendation_id: 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.

# Enumerated Values

Parameter Value
strategy_type spot_grid
strategy_type margin_grid
strategy_type infinite_grid
strategy_type futures_grid
strategy_type spot_martingale
direction buy
direction sell
direction neutral
scene top1
scene bundle
scene filter
scene refresh

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "scene": "top1",
    "recommendations": [
      {}
    ],
    "unsupported_filters": [
      "string"
    ]
  },
  "trace_id": "string"
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Unified business response AIHubDiscoverSuccessResponse

Response Schema

Status Code 200

Get the response body when the strategy recommendation is successful.

Name Type Description
» code integer(int32) none
» message string none
» data AIHubDiscoverData Strategy recommendation result data.
»» scene DiscoverScene Enumeration of scenarios supported by the policy recommendation interface.
»» recommendations array [A single piece of strategy recommendation information.]
»»» None AIHubRecommendation A single piece of strategy recommendation information.
»»»» recommendation_id string none
»»»» market string none
»»»» strategy_type StrategyType The complete enumeration of policy types supported by AIHub.
»»»» strategy_name string none
»»»» backtest_apr string none
»»»» max_drawdown string none
»»»» summary string none
»»»» strategy_params_preview string Recommended-parameter preview as JSON text (string-encoded so clients deserialize it consistently). The value is a serialized JSON object whose structure varies by strategy type; callers or upper-layer models must parse it.
»»» unsupported_filters array Filter conditions not supported in this issue
»» trace_id string none

# Enumerated Values

Property Value
scene top1
scene bundle
scene filter
scene refresh
strategy_type spot_grid
strategy_type margin_grid
strategy_type infinite_grid
strategy_type futures_grid
strategy_type spot_martingale
strategy_type contract_martingale

WARNING

To perform this operation, you must be authenticated by API key and secret

# Create spot grid

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/bot/spot-grid/create'
query_param = ''
body='{"strategy_type":"spot_grid","market":"string","create_params":{"money":"string","low_price":"string","high_price":"string","grid_num":1,"price_type":0,"trigger_price":"string","stop_profit":"string","stop_loss":"string","profit_sharing_ratio":"string","is_use_base":true}}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/bot/spot-grid/create"
query_param=""
body_param='{"strategy_type":"spot_grid","market":"string","create_params":{"money":"string","low_price":"string","high_price":"string","grid_num":1,"price_type":0,"trigger_price":"string","stop_profit":"string","stop_loss":"string","profit_sharing_ratio":"string","is_use_base":true}}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /bot/spot-grid/create

Create spot grid

Create a spot grid strategy based on the incoming parameters.

Body parameter

{
  "strategy_type": "spot_grid",
  "market": "string",
  "create_params": {
    "money": "string",
    "low_price": "string",
    "high_price": "string",
    "grid_num": 1,
    "price_type": 0,
    "trigger_price": "string",
    "stop_profit": "string",
    "stop_loss": "string",
    "profit_sharing_ratio": "string",
    "is_use_base": true
  }
}

Parameters

Name In Type Required Description
X-Gate-Service-Id header string false Call source identifier; injected by APIv4 if necessary
X-Gate-AppLang header string false Language context, such as zh-CN / en-US
X-Request-Id header string false Request link ID; caller can transmit transparently
X-Trace-Id header string false trace header; can be generated uniformly by APIv4
body body SpotGridCreateRequest true none
» strategy_type body string true none
» market body string true none
» create_params body SpotGridCreateParams true Creation parameters for the spot grid strategy.
»» money body string true Amount of investment
»» low_price body string true Range lower limit
»» high_price body string true Range upper limit
»» grid_num body integer(int32) true Number of grids
»» price_type body integer(int32) true none
»» trigger_price body string false none
»» stop_profit body string false none
»» stop_loss body string false none
»» profit_sharing_ratio body string false none
»» is_use_base body boolean false none

# Enumerated Values

Parameter Value
» strategy_type spot_grid
»» price_type 0
»» price_type 1

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string"
  },
  "trace_id": "string"
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Unified business response AIHubCreateSuccessResponse

Response Schema

Status Code 200

The response body when the creation strategy is successful.

Name Type Description
» code integer(int32) none
» message string none
» data AIHubCreateData Policy information returned after the policy is successfully created.
»» strategy_id string none
»» strategy_type StrategyType The complete enumeration of policy types supported by AIHub.
»» market string none
»» status string The initial state after successful creation, usually running
»» jump_url string none
» trace_id string none

# Enumerated Values

Property Value
strategy_type spot_grid
strategy_type margin_grid
strategy_type infinite_grid
strategy_type futures_grid
strategy_type spot_martingale
strategy_type contract_martingale

WARNING

To perform this operation, you must be authenticated by API key and secret

# Create a lever grid

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/bot/margin-grid/create'
query_param = ''
body='{"strategy_type":"margin_grid","market":"string","create_params":{"money":"string","low_price":"string","high_price":"string","grid_num":1,"price_type":0,"leverage":"string","direction":"long","trigger_price":"string","stop_profit":"string","stop_loss":"string","profit_sharing_ratio":"string","is_use_base":true}}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/bot/margin-grid/create"
query_param=""
body_param='{"strategy_type":"margin_grid","market":"string","create_params":{"money":"string","low_price":"string","high_price":"string","grid_num":1,"price_type":0,"leverage":"string","direction":"long","trigger_price":"string","stop_profit":"string","stop_loss":"string","profit_sharing_ratio":"string","is_use_base":true}}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /bot/margin-grid/create

Create a lever grid

Create a leverage grid strategy based on the passed parameters.

Body parameter

{
  "strategy_type": "margin_grid",
  "market": "string",
  "create_params": {
    "money": "string",
    "low_price": "string",
    "high_price": "string",
    "grid_num": 1,
    "price_type": 0,
    "leverage": "string",
    "direction": "long",
    "trigger_price": "string",
    "stop_profit": "string",
    "stop_loss": "string",
    "profit_sharing_ratio": "string",
    "is_use_base": true
  }
}

Parameters

Name In Type Required Description
X-Gate-Service-Id header string false Call source identifier; injected by APIv4 if necessary
X-Gate-AppLang header string false Language context, such as zh-CN / en-US
X-Request-Id header string false Request link ID; caller can transmit transparently
X-Trace-Id header string false trace header; can be generated uniformly by APIv4
body body MarginGridCreateRequest true none
» strategy_type body string true none
» market body string true none
» create_params body MarginGridCreateParams true Creation parameters for the Leverage Grid strategy.
»» money body string true none
»» low_price body string true none
»» high_price body string true none
»» grid_num body integer(int32) true none
»» price_type body integer(int32) true none
»» leverage body string true none
»» direction body FuturesDirection false Direction enumeration supported by contract-based strategies.
»» trigger_price body string false none
»» stop_profit body string false none
»» stop_loss body string false none
»» profit_sharing_ratio body string false none
»» is_use_base body boolean false none

# Enumerated Values

Parameter Value
» strategy_type margin_grid
»» price_type 0
»» price_type 1
»» direction long
»» direction short
»» direction neutral

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string"
  },
  "trace_id": "string"
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Unified business response AIHubCreateSuccessResponse

Response Schema

Status Code 200

The response body when the creation strategy is successful.

Name Type Description
» code integer(int32) none
» message string none
» data AIHubCreateData Policy information returned after the policy is successfully created.
»» strategy_id string none
»» strategy_type StrategyType The complete enumeration of policy types supported by AIHub.
»» market string none
»» status string The initial state after successful creation, usually running
»» jump_url string none
» trace_id string none

# Enumerated Values

Property Value
strategy_type spot_grid
strategy_type margin_grid
strategy_type infinite_grid
strategy_type futures_grid
strategy_type spot_martingale
strategy_type contract_martingale

WARNING

To perform this operation, you must be authenticated by API key and secret

# Create infinite grid

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/bot/infinite-grid/create'
query_param = ''
body='{"strategy_type":"infinite_grid","market":"string","create_params":{"money":"string","price_floor":"string","profit_per_grid":"string","grid_num":1,"price_type":0,"trigger_price":"string","stop_profit":"string","stop_loss":"string","profit_sharing_ratio":"string","is_use_base":true}}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/bot/infinite-grid/create"
query_param=""
body_param='{"strategy_type":"infinite_grid","market":"string","create_params":{"money":"string","price_floor":"string","profit_per_grid":"string","grid_num":1,"price_type":0,"trigger_price":"string","stop_profit":"string","stop_loss":"string","profit_sharing_ratio":"string","is_use_base":true}}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /bot/infinite-grid/create

Create infinite grid

Create an infinite grid strategy based on passed parameters.

Body parameter

{
  "strategy_type": "infinite_grid",
  "market": "string",
  "create_params": {
    "money": "string",
    "price_floor": "string",
    "profit_per_grid": "string",
    "grid_num": 1,
    "price_type": 0,
    "trigger_price": "string",
    "stop_profit": "string",
    "stop_loss": "string",
    "profit_sharing_ratio": "string",
    "is_use_base": true
  }
}

Parameters

Name In Type Required Description
X-Gate-Service-Id header string false Call source identifier; injected by APIv4 if necessary
X-Gate-AppLang header string false Language context, such as zh-CN / en-US
X-Request-Id header string false Request link ID; caller can transmit transparently
X-Trace-Id header string false trace header; can be generated uniformly by APIv4
body body InfiniteGridCreateRequest true none
» strategy_type body string true none
» market body string true none
» create_params body InfiniteGridCreateParams true Infinite grid creation parameters.
Aligned with the app: money, price_floor, and profit_per_grid are required;
grid_num and price_type are optional (defaults applied server-side when omitted).
»» money body string true none
»» price_floor body string true price floor
»» profit_per_grid body string true Profit per square
»» grid_num body integer(int32) false Optional; may be omitted like in the app.
»» price_type body integer(int32) false Optional. 0 arithmetic grid; 1 geometric; omit for server defaults.
»» trigger_price body string false none
»» stop_profit body string false none
»» stop_loss body string false none
»» profit_sharing_ratio body string false none
»» is_use_base body boolean false none

# Detailed descriptions

» create_params: Infinite grid creation parameters.
Aligned with the app: money, price_floor, and profit_per_grid are required;
grid_num and price_type are optional (defaults applied server-side when omitted).

# Enumerated Values

Parameter Value
» strategy_type infinite_grid
»» price_type 0
»» price_type 1

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string"
  },
  "trace_id": "string"
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Unified business response AIHubCreateSuccessResponse

Response Schema

Status Code 200

The response body when the creation strategy is successful.

Name Type Description
» code integer(int32) none
» message string none
» data AIHubCreateData Policy information returned after the policy is successfully created.
»» strategy_id string none
»» strategy_type StrategyType The complete enumeration of policy types supported by AIHub.
»» market string none
»» status string The initial state after successful creation, usually running
»» jump_url string none
» trace_id string none

# Enumerated Values

Property Value
strategy_type spot_grid
strategy_type margin_grid
strategy_type infinite_grid
strategy_type futures_grid
strategy_type spot_martingale
strategy_type contract_martingale

WARNING

To perform this operation, you must be authenticated by API key and secret

# Create a contract grid

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/bot/futures-grid/create'
query_param = ''
body='{"strategy_type":"futures_grid","market":"string","create_params":{"money":"string","low_price":"string","high_price":"string","grid_num":1,"price_type":0,"leverage":"string","direction":"long","trigger_price":"string","stop_profit":"string","stop_loss":"string","profit_sharing_ratio":"string","is_use_base":true}}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/bot/futures-grid/create"
query_param=""
body_param='{"strategy_type":"futures_grid","market":"string","create_params":{"money":"string","low_price":"string","high_price":"string","grid_num":1,"price_type":0,"leverage":"string","direction":"long","trigger_price":"string","stop_profit":"string","stop_loss":"string","profit_sharing_ratio":"string","is_use_base":true}}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /bot/futures-grid/create

Create a contract grid

Create a contract grid strategy based on the incoming parameters.

Body parameter

{
  "strategy_type": "futures_grid",
  "market": "string",
  "create_params": {
    "money": "string",
    "low_price": "string",
    "high_price": "string",
    "grid_num": 1,
    "price_type": 0,
    "leverage": "string",
    "direction": "long",
    "trigger_price": "string",
    "stop_profit": "string",
    "stop_loss": "string",
    "profit_sharing_ratio": "string",
    "is_use_base": true
  }
}

Parameters

Name In Type Required Description
X-Gate-Service-Id header string false Call source identifier; injected by APIv4 if necessary
X-Gate-AppLang header string false Language context, such as zh-CN / en-US
X-Request-Id header string false Request link ID; caller can transmit transparently
X-Trace-Id header string false trace header; can be generated uniformly by APIv4
body body FuturesGridCreateRequest true none
» strategy_type body string true none
» market body string true none
» create_params body FuturesGridCreateParams true Creation parameters for the contract grid strategy.
»» money body string true none
»» low_price body string true none
»» high_price body string true none
»» grid_num body integer(int32) true none
»» price_type body integer(int32) true none
»» leverage body string true none
»» direction body FuturesDirection false Direction enumeration supported by contract-based strategies.
»» trigger_price body string false none
»» stop_profit body string false none
»» stop_loss body string false none
»» profit_sharing_ratio body string false none
»» is_use_base body boolean false none

# Enumerated Values

Parameter Value
» strategy_type futures_grid
»» price_type 0
»» price_type 1
»» direction long
»» direction short
»» direction neutral

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string"
  },
  "trace_id": "string"
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Unified business response AIHubCreateSuccessResponse

Response Schema

Status Code 200

The response body when the creation strategy is successful.

Name Type Description
» code integer(int32) none
» message string none
» data AIHubCreateData Policy information returned after the policy is successfully created.
»» strategy_id string none
»» strategy_type StrategyType The complete enumeration of policy types supported by AIHub.
»» market string none
»» status string The initial state after successful creation, usually running
»» jump_url string none
» trace_id string none

# Enumerated Values

Property Value
strategy_type spot_grid
strategy_type margin_grid
strategy_type infinite_grid
strategy_type futures_grid
strategy_type spot_martingale
strategy_type contract_martingale

WARNING

To perform this operation, you must be authenticated by API key and secret

# Create Spot Martin

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/bot/spot-martingale/create'
query_param = ''
body='{"strategy_type":"spot_martingale","market":"string","create_params":{"invest_amount":"string","price_deviation":"string","max_orders":1,"take_profit_ratio":"string","stop_loss_per_cycle":"string","trigger_price":"string","profit_sharing_ratio":"string"}}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/bot/spot-martingale/create"
query_param=""
body_param='{"strategy_type":"spot_martingale","market":"string","create_params":{"invest_amount":"string","price_deviation":"string","max_orders":1,"take_profit_ratio":"string","stop_loss_per_cycle":"string","trigger_price":"string","profit_sharing_ratio":"string"}}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /bot/spot-martingale/create

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).

Body parameter

{
  "strategy_type": "spot_martingale",
  "market": "string",
  "create_params": {
    "invest_amount": "string",
    "price_deviation": "string",
    "max_orders": 1,
    "take_profit_ratio": "string",
    "stop_loss_per_cycle": "string",
    "trigger_price": "string",
    "profit_sharing_ratio": "string"
  }
}

Parameters

Name In Type Required Description
X-Gate-Service-Id header string false Call source identifier; injected by APIv4 if necessary
X-Gate-AppLang header string false Language context, such as zh-CN / en-US
X-Request-Id header string false Request link ID; caller can transmit transparently
X-Trace-Id header string false trace header; can be generated uniformly by APIv4
body body SpotMartingaleCreateRequest true none
» strategy_type body string true none
» market body string true none
» create_params body SpotMartingaleCreateParams true Spot martingale creation parameters (serialized fields aligned with MartingaleBot).
- Stop-loss: use stop_loss_per_cycle (ratio per round), same as the app; do not use stop_loss_price.
- Optional trigger_price: trigger price.
- If stop_loss_per_cycle is passed and > 0, the server validates roughly between 0.001 and 0.9999 (same as check_martingale).
»» invest_amount body string true none
»» price_deviation body string true Add-position deviation ratio as a decimal string (e.g. a 2% drop is 0.02).
»» max_orders body integer(int32) true none
»» take_profit_ratio body string true Take-profit ratio per round as a decimal string.
»» stop_loss_per_cycle body string false Stop-loss ratio per round as a decimal string; optional; aligned with app stop_loss_per_cycle.
»» trigger_price body string false Trigger price; optional.
»» profit_sharing_ratio body string false none

# Detailed descriptions

» create_params: Spot martingale creation parameters (serialized fields aligned with MartingaleBot).
- Stop-loss: use stop_loss_per_cycle (ratio per round), same as the app; do not use stop_loss_price.
- Optional trigger_price: trigger price.
- If stop_loss_per_cycle is passed and > 0, the server validates roughly between 0.001 and 0.9999 (same as check_martingale).

# Enumerated Values

Parameter Value
» strategy_type spot_martingale

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string"
  },
  "trace_id": "string"
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Unified business response AIHubCreateSuccessResponse

Response Schema

Status Code 200

The response body when the creation strategy is successful.

Name Type Description
» code integer(int32) none
» message string none
» data AIHubCreateData Policy information returned after the policy is successfully created.
»» strategy_id string none
»» strategy_type StrategyType The complete enumeration of policy types supported by AIHub.
»» market string none
»» status string The initial state after successful creation, usually running
»» jump_url string none
» trace_id string none

# Enumerated Values

Property Value
strategy_type spot_grid
strategy_type margin_grid
strategy_type infinite_grid
strategy_type futures_grid
strategy_type spot_martingale
strategy_type contract_martingale

WARNING

To perform this operation, you must be authenticated by API key and secret

# Create contract martin

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/bot/contract-martingale/create'
query_param = ''
body='{"strategy_type":"contract_martingale","market":"string","create_params":{"invest_amount":"string","price_deviation":"string","max_orders":1,"take_profit_ratio":"string","direction":"buy","leverage":"string","stop_loss_price":"string","profit_sharing_ratio":"string"}}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/bot/contract-martingale/create"
query_param=""
body_param='{"strategy_type":"contract_martingale","market":"string","create_params":{"invest_amount":"string","price_deviation":"string","max_orders":1,"take_profit_ratio":"string","direction":"buy","leverage":"string","stop_loss_price":"string","profit_sharing_ratio":"string"}}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /bot/contract-martingale/create

Create contract martin

Create a contract Martin strategy based on the input parameters.

Body parameter

{
  "strategy_type": "contract_martingale",
  "market": "string",
  "create_params": {
    "invest_amount": "string",
    "price_deviation": "string",
    "max_orders": 1,
    "take_profit_ratio": "string",
    "direction": "buy",
    "leverage": "string",
    "stop_loss_price": "string",
    "profit_sharing_ratio": "string"
  }
}

Parameters

Name In Type Required Description
X-Gate-Service-Id header string false Call source identifier; injected by APIv4 if necessary
X-Gate-AppLang header string false Language context, such as zh-CN / en-US
X-Request-Id header string false Request link ID; caller can transmit transparently
X-Trace-Id header string false trace header; can be generated uniformly by APIv4
body body ContractMartingaleCreateRequest true none
» strategy_type body string true none
» market body string true none
» create_params body ContractMartingaleCreateParams true The creation parameters of the contract Martin strategy.
»» invest_amount body string true Margin allocated; the server converts it to initial contract size using live contract price, contract multiplier, and minimum lot size.
»» price_deviation body string true none
»» max_orders body integer(int32) true none
»» take_profit_ratio body string true none
»» direction body ContractMartingaleDirection true The direction enumeration supported by the contract Martin strategy is consistent with the original interface of the App.
»» leverage body string true none
»» stop_loss_price body string false Legacy field name. The AIHub contract_martingale creation path does not map this field today;
follow contract martingale rules from the underlying API. MCP tooling must match bot-service behavior.
»» profit_sharing_ratio body string false none

# Detailed descriptions

»» stop_loss_price: Legacy field name. The AIHub contract_martingale creation path does not map this field today;
follow contract martingale rules from the underlying API. MCP tooling must match bot-service behavior.

# Enumerated Values

Parameter Value
» strategy_type contract_martingale
»» direction buy
»» direction sell

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string"
  },
  "trace_id": "string"
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Unified business response AIHubCreateSuccessResponse

Response Schema

Status Code 200

The response body when the creation strategy is successful.

Name Type Description
» code integer(int32) none
» message string none
» data AIHubCreateData Policy information returned after the policy is successfully created.
»» strategy_id string none
»» strategy_type StrategyType The complete enumeration of policy types supported by AIHub.
»» market string none
»» status string The initial state after successful creation, usually running
»» jump_url string none
» trace_id string none

# Enumerated Values

Property Value
strategy_type spot_grid
strategy_type margin_grid
strategy_type infinite_grid
strategy_type futures_grid
strategy_type spot_martingale
strategy_type contract_martingale

WARNING

To perform this operation, you must be authenticated by API key and secret

# Query the list of running policies

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/bot/portfolio/running'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/bot/portfolio/running"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /bot/portfolio/running

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.

Parameters

Name In Type Required Description
strategy_type query string false Filter by policy type
market query string false Filter by trading pair
page query integer(int32) false Page number, default 1
page_size query integer(int32) false Paging size, default 20, maximum 50
X-Gate-Service-Id header string false Call source identifier; injected by APIv4 if necessary
X-Gate-AppLang header string false Language context, such as zh-CN / en-US
X-Request-Id header string false Request link ID; caller can transmit transparently
X-Trace-Id header string false trace header; can be generated uniformly by APIv4

# Enumerated Values

Parameter Value
strategy_type spot_grid
strategy_type margin_grid
strategy_type infinite_grid
strategy_type futures_grid
strategy_type spot_martingale
strategy_type contract_martingale

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "items": [
      {}
    ],
    "page": 0,
    "page_size": 0,
    "total": 0
  },
  "trace_id": "string"
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Unified business response AIHubPortfolioRunningSuccessResponse

Response Schema

Status Code 200

The response body when querying the running policy list is successful.

Name Type Description
» code integer(int32) none
» message string none
» data AIHubPortfolioRunningData Running policy list data.
»» items array [A single record in the list of running policies.]
»»» None AIHubPortfolioRunningItem A single record in the list of running policies.
»»»» strategy_id string none
»»»» strategy_type StrategyType The complete enumeration of policy types supported by AIHub.
»»»» strategy_name string none
»»»» market string none
»»»» status string none
»»»» pnl string none
»»»» pnl_rate string none
»»»» invest_amount string none
»»»» created_at string Created time
»»» page integer(int32) none
»»» page_size integer(int32) none
»»» total integer(int32) none
»» trace_id string none

# Enumerated Values

Property Value
strategy_type spot_grid
strategy_type margin_grid
strategy_type infinite_grid
strategy_type futures_grid
strategy_type spot_martingale
strategy_type contract_martingale

WARNING

To perform this operation, you must be authenticated by API key and secret

# Query order policy details

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/bot/portfolio/detail'
query_param = 'strategy_id=string&strategy_type=spot_grid'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/bot/portfolio/detail"
query_param="strategy_id=string&strategy_type=spot_grid"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /bot/portfolio/detail

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.

Parameters

Name In Type Required Description
strategy_id query string true Policy ID
strategy_type query string true Policy type; used for underlying detail distribution
X-Gate-Service-Id header string false Call source identifier; injected by APIv4 if necessary
X-Gate-AppLang header string false Language context, such as zh-CN / en-US
X-Request-Id header string false Request link ID; caller can transmit transparently
X-Trace-Id header string false trace header; can be generated uniformly by APIv4

# Enumerated Values

Parameter Value
strategy_type spot_grid
strategy_type margin_grid
strategy_type infinite_grid
strategy_type futures_grid
strategy_type spot_martingale
strategy_type contract_martingale

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "base_info": {
      "strategy_name": "string",
      "created_at": "string",
      "running_duration": 0,
      "invest_amount": "string",
      "total_profit": "string",
      "profit_rate": "string"
    },
    "metrics": {
      "grid_profit": "string",
      "floating_pnl": "string",
      "arbitrage_count": 0,
      "price_range": "string",
      "grid_count": 0,
      "estimated_liquidation_price": "string",
      "price_floor": "string",
      "grid_profit_rate": "string",
      "realized_pnl": "string",
      "finished_rounds": 0,
      "avg_cost": "string",
      "take_profit_price": "string",
      "maintenance_margin_ratio": "string"
    },
    "position": {
      "amount": "string",
      "entry_price": "string",
      "quote_amount": "string",
      "position_value": "string",
      "margin": "string",
      "side": "string"
    },
    "stop_supported": true
  },
  "trace_id": "string"
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Unified business response AIHubPortfolioDetailSuccessResponse

Response Schema

Status Code 200

The response body when querying policy details is successful.

Name Type Description
» code integer(int32) none
» message string none
» data AIHubPortfolioDetailData Policy details data.
»» strategy_id string none
»» strategy_type StrategyType The complete enumeration of policy types supported by AIHub.
»» market string none
»» status string none
»» base_info AIHubPortfolioBaseInfo Strategy detail base info.
»»» strategy_name string none
»»» created_at string Created time
»»» running_duration integer(int64) Runtime duration in seconds.
»»» invest_amount string none
»»» total_profit string none
»»» profit_rate string none
»» metrics AIHubPortfolioMetrics Strategy detail metrics; fields returned depend on strategy type.
»»» grid_profit string none
»»» floating_pnl string none
»»» arbitrage_count integer(int64) none
»»» price_range string none
»»» grid_count integer(int64) none
»»» estimated_liquidation_price string none
»»» price_floor string none
»»» grid_profit_rate string none
»»» realized_pnl string none
»»» finished_rounds integer(int64) none
»»» avg_cost string none
»»» take_profit_price string none
»»» maintenance_margin_ratio string none
»» position AIHubPortfolioPosition|null Strategy detail position info; fields returned depend on strategy type.
»»» amount string none
»»» entry_price string none
»»» quote_amount string none
»»» position_value string none
»»» margin string none
»»» side string none
»» stop_supported boolean none
» trace_id string none

# Enumerated Values

Property Value
strategy_type spot_grid
strategy_type margin_grid
strategy_type infinite_grid
strategy_type futures_grid
strategy_type spot_martingale
strategy_type contract_martingale

WARNING

To perform this operation, you must be authenticated by API key and secret

# Terminate a single running policy

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/bot/portfolio/stop'
query_param = ''
body='{"strategy_id":"string","strategy_type":"spot_grid"}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/bot/portfolio/stop"
query_param=""
body_param='{"strategy_id":"string","strategy_type":"spot_grid"}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /bot/portfolio/stop

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.

Body parameter

{
  "strategy_id": "string",
  "strategy_type": "spot_grid"
}

Parameters

Name In Type Required Description
X-Gate-Service-Id header string false Call source identifier; injected by APIv4 if necessary
X-Gate-AppLang header string false Language context, such as zh-CN / en-US
X-Request-Id header string false Request link ID; caller can transmit transparently
X-Trace-Id header string false trace header; can be generated uniformly by APIv4
body body AIHubPortfolioStopRequest true none
» strategy_id body string true none
» strategy_type body StrategyType true The complete enumeration of policy types supported by AIHub.

# Enumerated Values

Parameter Value
» strategy_type spot_grid
» strategy_type margin_grid
» strategy_type infinite_grid
» strategy_type futures_grid
» strategy_type spot_martingale
» strategy_type contract_martingale

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "status": "string",
    "result_message": "string"
  },
  "trace_id": "string"
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Unified business response AIHubPortfolioStopSuccessResponse

Response Schema

Status Code 200

The response body when the termination strategy is successful.

Name Type Description
» code integer(int32) none
» message string none
» data AIHubPortfolioStopData The result information returned after the termination strategy is successful.
»» strategy_id string none
»» strategy_type StrategyType The complete enumeration of policy types supported by AIHub.
»» status string The current implementation returns stopping
»» result_message string none
» trace_id string none

# Enumerated Values

Property Value
strategy_type spot_grid
strategy_type margin_grid
strategy_type infinite_grid
strategy_type futures_grid
strategy_type spot_martingale
strategy_type contract_martingale

WARNING

To perform this operation, you must be authenticated by API key and secret

# Schemas

# SpotMartingaleCreateRequest

{
  "strategy_type": "spot_martingale",
  "market": "string",
  "create_params": {
    "invest_amount": "string",
    "price_deviation": "string",
    "max_orders": 1,
    "take_profit_ratio": "string",
    "stop_loss_per_cycle": "string",
    "trigger_price": "string",
    "profit_sharing_ratio": "string"
  }
}

Create the request body of the Spot Martin strategy.

# Properties

Name Type Required Restrictions Description
strategy_type string true none none
market string true none none
create_params SpotMartingaleCreateParams true none Spot martingale creation parameters (serialized fields aligned with MartingaleBot).
- Stop-loss: use stop_loss_per_cycle (ratio per round), same as the app; do not use stop_loss_price.
- Optional trigger_price: trigger price.
- If stop_loss_per_cycle is passed and > 0, the server validates roughly between 0.001 and 0.9999 (same as check_martingale).

# Enumerated Values

Property Value
strategy_type spot_martingale

# MarginGridCreateRequest

{
  "strategy_type": "margin_grid",
  "market": "string",
  "create_params": {
    "money": "string",
    "low_price": "string",
    "high_price": "string",
    "grid_num": 1,
    "price_type": 0,
    "leverage": "string",
    "direction": "long",
    "trigger_price": "string",
    "stop_profit": "string",
    "stop_loss": "string",
    "profit_sharing_ratio": "string",
    "is_use_base": true
  }
}

Create the request body for the Leverage Grid strategy.

# Properties

Name Type Required Restrictions Description
strategy_type string true none none
market string true none none
create_params MarginGridCreateParams true none Creation parameters for the Leverage Grid strategy.

# Enumerated Values

Property Value
strategy_type margin_grid

# InfiniteGridCreateRequest

{
  "strategy_type": "infinite_grid",
  "market": "string",
  "create_params": {
    "money": "string",
    "price_floor": "string",
    "profit_per_grid": "string",
    "grid_num": 1,
    "price_type": 0,
    "trigger_price": "string",
    "stop_profit": "string",
    "stop_loss": "string",
    "profit_sharing_ratio": "string",
    "is_use_base": true
  }
}

Create the request body for the infinite grid policy.

# Properties

Name Type Required Restrictions Description
strategy_type string true none none
market string true none none
create_params InfiniteGridCreateParams true none Infinite grid creation parameters.
Aligned with the app: money, price_floor, and profit_per_grid are required;
grid_num and price_type are optional (defaults applied server-side when omitted).

# Enumerated Values

Property Value
strategy_type infinite_grid

# AIHubPortfolioStopSuccessResponse

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "status": "string",
    "result_message": "string"
  },
  "trace_id": "string"
}

The response body when the termination strategy is successful.

# Properties

Name Type Required Restrictions Description
code integer(int32) true none none
message string true none none
data AIHubPortfolioStopData true none The result information returned after the termination strategy is successful.
trace_id string true none none

# InfiniteGridCreateParams

{
  "money": "string",
  "price_floor": "string",
  "profit_per_grid": "string",
  "grid_num": 1,
  "price_type": 0,
  "trigger_price": "string",
  "stop_profit": "string",
  "stop_loss": "string",
  "profit_sharing_ratio": "string",
  "is_use_base": true
}

Infinite grid creation parameters. Aligned with the app: money, price_floor, and profit_per_grid are required; grid_num and price_type are optional (defaults applied server-side when omitted).

# Properties

Name Type Required Restrictions Description
money string true none none
price_floor string true none price floor
profit_per_grid string true none Profit per square
grid_num integer(int32) false none Optional; may be omitted like in the app.
price_type integer(int32) false none Optional. 0 arithmetic grid; 1 geometric; omit for server defaults.
trigger_price string false none none
stop_profit string false none none
stop_loss string false none none
profit_sharing_ratio string false none none
is_use_base boolean false none none

# Enumerated Values

Property Value
price_type 0
price_type 1

# AIHubPortfolioStopData

{
  "strategy_id": "string",
  "strategy_type": "spot_grid",
  "status": "string",
  "result_message": "string"
}

The result information returned after the termination strategy is successful.

# Properties

Name Type Required Restrictions Description
strategy_id string true none none
strategy_type StrategyType true none The complete enumeration of policy types supported by AIHub.
status string true none The current implementation returns stopping
result_message string true none none

# AIHubPortfolioRunningSuccessResponse

{
  "code": 200,
  "message": "success",
  "data": {
    "items": [
      {}
    ],
    "page": 0,
    "page_size": 0,
    "total": 0
  },
  "trace_id": "string"
}

The response body when querying the running policy list is successful.

# Properties

Name Type Required Restrictions Description
code integer(int32) true none none
message string true none none
data AIHubPortfolioRunningData true none Running policy list data.
trace_id string true none none

# SpotGridCreateRequest

{
  "strategy_type": "spot_grid",
  "market": "string",
  "create_params": {
    "money": "string",
    "low_price": "string",
    "high_price": "string",
    "grid_num": 1,
    "price_type": 0,
    "trigger_price": "string",
    "stop_profit": "string",
    "stop_loss": "string",
    "profit_sharing_ratio": "string",
    "is_use_base": true
  }
}

Create the request body for the spot grid policy.

# Properties

Name Type Required Restrictions Description
strategy_type string true none none
market string true none none
create_params SpotGridCreateParams true none Creation parameters for the spot grid strategy.

# Enumerated Values

Property Value
strategy_type spot_grid

# AIHubCreateSuccessResponse

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string"
  },
  "trace_id": "string"
}

The response body when the creation strategy is successful.

# Properties

Name Type Required Restrictions Description
code integer(int32) true none none
message string true none none
data AIHubCreateData true none Policy information returned after the policy is successfully created.
trace_id string true none none

# FuturesGridCreateRequest

{
  "strategy_type": "futures_grid",
  "market": "string",
  "create_params": {
    "money": "string",
    "low_price": "string",
    "high_price": "string",
    "grid_num": 1,
    "price_type": 0,
    "leverage": "string",
    "direction": "long",
    "trigger_price": "string",
    "stop_profit": "string",
    "stop_loss": "string",
    "profit_sharing_ratio": "string",
    "is_use_base": true
  }
}

Create the request body of the contract grid strategy.

# Properties

Name Type Required Restrictions Description
strategy_type string true none none
market string true none none
create_params FuturesGridCreateParams true none Creation parameters for the contract grid strategy.

# Enumerated Values

Property Value
strategy_type futures_grid

# StrategyType

"spot_grid"

The complete enumeration of policy types supported by AIHub.

# Properties

Name Type Required Restrictions Description
None string false none The complete enumeration of policy types supported by AIHub.

# Enumerated Values

Property Value
None spot_grid
None margin_grid
None infinite_grid
None futures_grid
None spot_martingale
None contract_martingale

# AIHubDiscoverSuccessResponse

{
  "code": 200,
  "message": "success",
  "data": {
    "scene": "top1",
    "recommendations": [
      {}
    ],
    "unsupported_filters": [
      "string"
    ]
  },
  "trace_id": "string"
}

Get the response body when the strategy recommendation is successful.

# Properties

Name Type Required Restrictions Description
code integer(int32) true none none
message string true none none
data AIHubDiscoverData true none Strategy recommendation result data.
trace_id string true none none

# AIHubPortfolioStopRequest

{
  "strategy_id": "string",
  "strategy_type": "spot_grid"
}

The request body to terminate a running policy.

# Properties

Name Type Required Restrictions Description
strategy_id string true none none
strategy_type StrategyType true none The complete enumeration of policy types supported by AIHub.

# AIHubPortfolioDetailSuccessResponse

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "base_info": {
      "strategy_name": "string",
      "created_at": "string",
      "running_duration": 0,
      "invest_amount": "string",
      "total_profit": "string",
      "profit_rate": "string"
    },
    "metrics": {
      "grid_profit": "string",
      "floating_pnl": "string",
      "arbitrage_count": 0,
      "price_range": "string",
      "grid_count": 0,
      "estimated_liquidation_price": "string",
      "price_floor": "string",
      "grid_profit_rate": "string",
      "realized_pnl": "string",
      "finished_rounds": 0,
      "avg_cost": "string",
      "take_profit_price": "string",
      "maintenance_margin_ratio": "string"
    },
    "position": {
      "amount": "string",
      "entry_price": "string",
      "quote_amount": "string",
      "position_value": "string",
      "margin": "string",
      "side": "string"
    },
    "stop_supported": true
  },
  "trace_id": "string"
}

The response body when querying policy details is successful.

# Properties

Name Type Required Restrictions Description
code integer(int32) true none none
message string true none none
data AIHubPortfolioDetailData true none Policy details data.
trace_id string true none none

# MarginGridCreateParams

{
  "money": "string",
  "low_price": "string",
  "high_price": "string",
  "grid_num": 1,
  "price_type": 0,
  "leverage": "string",
  "direction": "long",
  "trigger_price": "string",
  "stop_profit": "string",
  "stop_loss": "string",
  "profit_sharing_ratio": "string",
  "is_use_base": true
}

Creation parameters for the Leverage Grid strategy.

# Properties

Name Type Required Restrictions Description
money string true none none
low_price string true none none
high_price string true none none
grid_num integer(int32) true none none
price_type integer(int32) true none none
leverage string true none none
direction FuturesDirection false none Direction enumeration supported by contract-based strategies.
trigger_price string false none none
stop_profit string false none none
stop_loss string false none none
profit_sharing_ratio string false none none
is_use_base boolean false none none

# Enumerated Values

Property Value
price_type 0
price_type 1

# AIHubPortfolioDetailData

{
  "strategy_id": "string",
  "strategy_type": "spot_grid",
  "market": "string",
  "status": "string",
  "base_info": {
    "strategy_name": "string",
    "created_at": "string",
    "running_duration": 0,
    "invest_amount": "string",
    "total_profit": "string",
    "profit_rate": "string"
  },
  "metrics": {
    "grid_profit": "string",
    "floating_pnl": "string",
    "arbitrage_count": 0,
    "price_range": "string",
    "grid_count": 0,
    "estimated_liquidation_price": "string",
    "price_floor": "string",
    "grid_profit_rate": "string",
    "realized_pnl": "string",
    "finished_rounds": 0,
    "avg_cost": "string",
    "take_profit_price": "string",
    "maintenance_margin_ratio": "string"
  },
  "position": {
    "amount": "string",
    "entry_price": "string",
    "quote_amount": "string",
    "position_value": "string",
    "margin": "string",
    "side": "string"
  },
  "stop_supported": true
}

Policy details data.

# Properties

Name Type Required Restrictions Description
strategy_id string true none none
strategy_type StrategyType true none The complete enumeration of policy types supported by AIHub.
market string true none none
status string true none none
base_info AIHubPortfolioBaseInfo true none Strategy detail base info.
metrics AIHubPortfolioMetrics true none Strategy detail metrics; fields returned depend on strategy type.
position AIHubPortfolioPosition false none Strategy detail position info; fields returned depend on strategy type.
stop_supported boolean true none none

# AIHubDiscoverData

{
  "scene": "top1",
  "recommendations": [
    {
      "recommendation_id": "string",
      "market": "string",
      "strategy_type": "spot_grid",
      "strategy_name": "string",
      "backtest_apr": "string",
      "max_drawdown": "string",
      "summary": "string",
      "strategy_params_preview": "string"
    }
  ],
  "unsupported_filters": [
    "string"
  ]
}

Strategy recommendation result data.

# Properties

Name Type Required Restrictions Description
scene DiscoverScene true none Enumeration of scenarios supported by the policy recommendation interface.
recommendations [AIHubRecommendation] true none [A single piece of strategy recommendation information.]
unsupported_filters array true none Filter conditions not supported in this issue

# AIHubPortfolioRunningData

{
  "items": [
    {
      "strategy_id": "string",
      "strategy_type": "spot_grid",
      "strategy_name": "string",
      "market": "string",
      "status": "string",
      "pnl": "string",
      "pnl_rate": "string",
      "invest_amount": "string",
      "created_at": "string"
    }
  ],
  "page": 0,
  "page_size": 0,
  "total": 0
}

Running policy list data.

# Properties

Name Type Required Restrictions Description
items [AIHubPortfolioRunningItem] true none [A single record in the list of running policies.]
page integer(int32) true none none
page_size integer(int32) true none none
total integer(int32) true none none

# AIHubCreateData

{
  "strategy_id": "string",
  "strategy_type": "spot_grid",
  "market": "string",
  "status": "string",
  "jump_url": "string"
}

Policy information returned after the policy is successfully created.

# Properties

Name Type Required Restrictions Description
strategy_id string true none none
strategy_type StrategyType true none The complete enumeration of policy types supported by AIHub.
market string true none none
status string true none The initial state after successful creation, usually running
jump_url string false none none

# AIHubPortfolioRunningItem

{
  "strategy_id": "string",
  "strategy_type": "spot_grid",
  "strategy_name": "string",
  "market": "string",
  "status": "string",
  "pnl": "string",
  "pnl_rate": "string",
  "invest_amount": "string",
  "created_at": "string"
}

A single record in the list of running policies.

# Properties

Name Type Required Restrictions Description
strategy_id string true none none
strategy_type StrategyType true none The complete enumeration of policy types supported by AIHub.
strategy_name string true none none
market string true none none
status string true none none
pnl string false none none
pnl_rate string false none none
invest_amount string false none none
created_at string false none Created time

# AIHubPortfolioPosition

{
  "amount": "string",
  "entry_price": "string",
  "quote_amount": "string",
  "position_value": "string",
  "margin": "string",
  "side": "string"
}

Strategy detail position info; fields returned depend on strategy type.

# Properties

Name Type Required Restrictions Description
amount string false none none
entry_price string false none none
quote_amount string false none none
position_value string false none none
margin string false none none
side string false none none

# ContractMartingaleCreateRequest

{
  "strategy_type": "contract_martingale",
  "market": "string",
  "create_params": {
    "invest_amount": "string",
    "price_deviation": "string",
    "max_orders": 1,
    "take_profit_ratio": "string",
    "direction": "buy",
    "leverage": "string",
    "stop_loss_price": "string",
    "profit_sharing_ratio": "string"
  }
}

Create the request body of the contract Martin strategy.

# Properties

Name Type Required Restrictions Description
strategy_type string true none none
market string true none none
create_params ContractMartingaleCreateParams true none The creation parameters of the contract Martin strategy.

# Enumerated Values

Property Value
strategy_type contract_martingale

# AIHubPortfolioMetrics

{
  "grid_profit": "string",
  "floating_pnl": "string",
  "arbitrage_count": 0,
  "price_range": "string",
  "grid_count": 0,
  "estimated_liquidation_price": "string",
  "price_floor": "string",
  "grid_profit_rate": "string",
  "realized_pnl": "string",
  "finished_rounds": 0,
  "avg_cost": "string",
  "take_profit_price": "string",
  "maintenance_margin_ratio": "string"
}

Strategy detail metrics; fields returned depend on strategy type.

# Properties

Name Type Required Restrictions Description
grid_profit string false none none
floating_pnl string false none none
arbitrage_count integer(int64) false none none
price_range string false none none
grid_count integer(int64) false none none
estimated_liquidation_price string false none none
price_floor string false none none
grid_profit_rate string false none none
realized_pnl string false none none
finished_rounds integer(int64) false none none
avg_cost string false none none
take_profit_price string false none none
maintenance_margin_ratio string false none none

# AIHubPortfolioBaseInfo

{
  "strategy_name": "string",
  "created_at": "string",
  "running_duration": 0,
  "invest_amount": "string",
  "total_profit": "string",
  "profit_rate": "string"
}

Strategy detail base info.

# Properties

Name Type Required Restrictions Description
strategy_name string true none none
created_at string true none Created time
running_duration integer(int64) true none Runtime duration in seconds.
invest_amount string true none none
total_profit string true none none
profit_rate string true none none

# SpotMartingaleCreateParams

{
  "invest_amount": "string",
  "price_deviation": "string",
  "max_orders": 1,
  "take_profit_ratio": "string",
  "stop_loss_per_cycle": "string",
  "trigger_price": "string",
  "profit_sharing_ratio": "string"
}

*Spot martingale creation parameters (serialized fields aligned with MartingaleBot).

  • Stop-loss: use stop_loss_per_cycle (ratio per round), same as the app; do not use stop_loss_price.
  • Optional trigger_price: trigger price.
  • If stop_loss_per_cycle is passed and > 0, the server validates roughly between 0.001 and 0.9999 (same as check_martingale).*

# Properties

Name Type Required Restrictions Description
invest_amount string true none none
price_deviation string true none Add-position deviation ratio as a decimal string (e.g. a 2% drop is 0.02).
max_orders integer(int32) true none none
take_profit_ratio string true none Take-profit ratio per round as a decimal string.
stop_loss_per_cycle string false none Stop-loss ratio per round as a decimal string; optional; aligned with app stop_loss_per_cycle.
trigger_price string false none Trigger price; optional.
profit_sharing_ratio string false none none

# SpotGridCreateParams

{
  "money": "string",
  "low_price": "string",
  "high_price": "string",
  "grid_num": 1,
  "price_type": 0,
  "trigger_price": "string",
  "stop_profit": "string",
  "stop_loss": "string",
  "profit_sharing_ratio": "string",
  "is_use_base": true
}

Creation parameters for the spot grid strategy.

# Properties

Name Type Required Restrictions Description
money string true none Amount of investment
low_price string true none Range lower limit
high_price string true none Range upper limit
grid_num integer(int32) true none Number of grids
price_type integer(int32) true none none
trigger_price string false none none
stop_profit string false none none
stop_loss string false none none
profit_sharing_ratio string false none none
is_use_base boolean false none none

# Enumerated Values

Property Value
price_type 0
price_type 1

# FuturesGridCreateParams

{
  "money": "string",
  "low_price": "string",
  "high_price": "string",
  "grid_num": 1,
  "price_type": 0,
  "leverage": "string",
  "direction": "long",
  "trigger_price": "string",
  "stop_profit": "string",
  "stop_loss": "string",
  "profit_sharing_ratio": "string",
  "is_use_base": true
}

Creation parameters for the contract grid strategy.

# Properties

Name Type Required Restrictions Description
money string true none none
low_price string true none none
high_price string true none none
grid_num integer(int32) true none none
price_type integer(int32) true none none
leverage string true none none
direction FuturesDirection false none Direction enumeration supported by contract-based strategies.
trigger_price string false none none
stop_profit string false none none
stop_loss string false none none
profit_sharing_ratio string false none none
is_use_base boolean false none none

# Enumerated Values

Property Value
price_type 0
price_type 1

# ContractMartingaleCreateParams

{
  "invest_amount": "string",
  "price_deviation": "string",
  "max_orders": 1,
  "take_profit_ratio": "string",
  "direction": "buy",
  "leverage": "string",
  "stop_loss_price": "string",
  "profit_sharing_ratio": "string"
}

The creation parameters of the contract Martin strategy.

# Properties

Name Type Required Restrictions Description
invest_amount string true none Margin allocated; the server converts it to initial contract size using live contract price, contract multiplier, and minimum lot size.
price_deviation string true none none
max_orders integer(int32) true none none
take_profit_ratio string true none none
direction ContractMartingaleDirection true none The direction enumeration supported by the contract Martin strategy is consistent with the original interface of the App.
leverage string true none none
stop_loss_price string false none Legacy field name. The AIHub contract_martingale creation path does not map this field today;
follow contract martingale rules from the underlying API. MCP tooling must match bot-service behavior.
profit_sharing_ratio string false none none

# ContractMartingaleDirection

"buy"

The direction enumeration supported by the contract Martin strategy is consistent with the original interface of the App.

# Properties

Name Type Required Restrictions Description
None string false none The direction enumeration supported by the contract Martin strategy is consistent with the original interface of the App.

# Enumerated Values

Property Value
None buy
None sell

# DiscoverScene

"top1"

Enumeration of scenarios supported by the policy recommendation interface.

# Properties

Name Type Required Restrictions Description
None string false none Enumeration of scenarios supported by the policy recommendation interface.

# Enumerated Values

Property Value
None top1
None bundle
None filter
None refresh

# FuturesDirection

"long"

Direction enumeration supported by contract-based strategies.

# Properties

Name Type Required Restrictions Description
None string false none Direction enumeration supported by contract-based strategies.

# Enumerated Values

Property Value
None long
None short
None neutral

# AIHubRecommendation

{
  "recommendation_id": "string",
  "market": "string",
  "strategy_type": "spot_grid",
  "strategy_name": "string",
  "backtest_apr": "string",
  "max_drawdown": "string",
  "summary": "string",
  "strategy_params_preview": "string"
}

A single piece of strategy recommendation information.

# Properties

Name Type Required Restrictions Description
recommendation_id string true none none
market string true none none
strategy_type StrategyType true none The complete enumeration of policy types supported by AIHub.
strategy_name string true none none
backtest_apr string false none none
max_drawdown string false none none
summary string true none none
strategy_params_preview string false none Recommended-parameter preview as JSON text (string-encoded so clients deserialize it consistently). The value is a serialized JSON object whose structure varies by strategy type; callers or upper-layer models must parse it.