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

Six real official source types. Exact rebalance asset membership is filtered before ranking. contract_martingale and futures_combo are manual-only. Legacy APR/drawdown and ordinary two-segment refresh remain compatible. Exclusion binds one prior logical candidate before ranking; no alternative returns an empty list without relaxing constraints.

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 Context only. No budget eligibility filter; reported unsupported when not consumed.
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 Actual maximum result count, 1–10; defaults 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
exclude_recommendation_id query string false Refresh-only previous returned identity: type|market|backtest_id, with an optional stable parameter discriminator for colliding source IDs. Ambiguous old identities are rejected; metric-only changes do not produce a new plan.

# 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
strategy_type smart_position
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",
  "label": "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.

Type Constraints
AIHubDiscoverSuccessResponse required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubDiscoverData false required: ["scene","recommendations","unsupported_filters"] Strategy recommendation result data.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

data

Strategy recommendation result data.

Type Constraints
AIHubDiscoverData required: ["scene","recommendations","unsupported_filters"]

Properties

Name Type Required Constraints Description
scene DiscoverScene true enum: ["top1","bundle","filter","refresh"] Enumeration of scenarios supported by the policy recommendation interface.
recommendations array true
unsupported_filters array true Filter conditions not supported in this issue

data / recommendations

Type Constraints
array

data / recommendations / items

A single piece of strategy recommendation information.

Type Constraints
AIHubRecommendation required: ["recommendation_id","market","strategy_type","strategy_name","summary"]

Properties

Name Type Required Constraints Description
recommendation_id string true
market string true
strategy_type StrategyType true enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
strategy_name string true
backtest_apr string false
max_drawdown string false
summary string true
strategy_params_preview string false 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.

data / unsupported_filters

Filter conditions not supported in this issue

Type Constraints
array

data / unsupported_filters / items

Type Constraints
string

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

# Request Body Schema

Create the request body for the spot grid policy.

Type Constraints
SpotGridCreateRequest required: ["strategy_type","market","create_params"]

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["spot_grid"]
market string true
create_params SpotGridCreateParams true required: ["money","low_price","high_price","grid_num","price_type"] Creation parameters for the spot grid strategy.

create_params

Creation parameters for the spot grid strategy.

Type Constraints
SpotGridCreateParams required: ["money","low_price","high_price","grid_num","price_type"]

Properties

Name Type Required Constraints Description
money string true Amount of investment
low_price string true Range lower limit
high_price string true Range upper limit
grid_num integer(int32) true minimum: 1 Number of grids
price_type integer(int32) true enum: [0,1]
trigger_price string false
stop_profit string false
stop_loss string false
profit_sharing_ratio string false
is_use_base boolean false

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string",
    "operation_status": "string",
    "recovery_required": true
  },
  "trace_id": "string",
  "label": "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.

Type Constraints
AIHubCreateSuccessResponse required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubCreateData false Policy information returned after the policy is successfully created.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

data

Policy information returned after the policy is successfully created.

Type Constraints
AIHubCreateData

Properties

Name Type Required Constraints Description
strategy_id string false
strategy_type StrategyType false enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
market string false
status string false Observed product lifecycle state, or unknown. Creation acceptance/starting is not running; stopping/finished alone does not prove funds settled.
jump_url string false
operation_status string false pending when the write result requires verification; rejected for a proven pre-effect refusal.
recovery_required boolean false

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

# Request Body Schema

Create the request body for the Leverage Grid strategy.

Type Constraints
MarginGridCreateRequest required: ["strategy_type","market","create_params"]

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["margin_grid"]
market string true
create_params MarginGridCreateParams true required: ["money","low_price","high_price","grid_num","price_type","leverage"] Creation parameters for the Leverage Grid strategy.

create_params

Creation parameters for the Leverage Grid strategy.

Type Constraints
MarginGridCreateParams required: ["money","low_price","high_price","grid_num","price_type","leverage"]

Properties

Name Type Required Constraints Description
money string true
low_price string true
high_price string true
grid_num integer(int32) true minimum: 1
price_type integer(int32) true enum: [0,1]
leverage string true
direction FuturesDirection false enum: ["long","short","neutral"] Direction enumeration supported by contract-based strategies.
trigger_price string false
stop_profit string false
stop_loss string false
profit_sharing_ratio string false
is_use_base boolean false

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string",
    "operation_status": "string",
    "recovery_required": true
  },
  "trace_id": "string",
  "label": "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.

Type Constraints
AIHubCreateSuccessResponse required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubCreateData false Policy information returned after the policy is successfully created.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

data

Policy information returned after the policy is successfully created.

Type Constraints
AIHubCreateData

Properties

Name Type Required Constraints Description
strategy_id string false
strategy_type StrategyType false enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
market string false
status string false Observed product lifecycle state, or unknown. Creation acceptance/starting is not running; stopping/finished alone does not prove funds settled.
jump_url string false
operation_status string false pending when the write result requires verification; rejected for a proven pre-effect refusal.
recovery_required boolean false

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

# Request Body Schema

Create the request body for the infinite grid policy.

Type Constraints
InfiniteGridCreateRequest required: ["strategy_type","market","create_params"]

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["infinite_grid"]
market string true
create_params InfiniteGridCreateParams true required: ["money","price_floor","profit_per_grid"] 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).

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

Type Constraints
InfiniteGridCreateParams required: ["money","price_floor","profit_per_grid"]

Properties

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

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string",
    "operation_status": "string",
    "recovery_required": true
  },
  "trace_id": "string",
  "label": "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.

Type Constraints
AIHubCreateSuccessResponse required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubCreateData false Policy information returned after the policy is successfully created.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

data

Policy information returned after the policy is successfully created.

Type Constraints
AIHubCreateData

Properties

Name Type Required Constraints Description
strategy_id string false
strategy_type StrategyType false enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
market string false
status string false Observed product lifecycle state, or unknown. Creation acceptance/starting is not running; stopping/finished alone does not prove funds settled.
jump_url string false
operation_status string false pending when the write result requires verification; rejected for a proven pre-effect refusal.
recovery_required boolean false

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

# Request Body Schema

Create the request body of the contract grid strategy.

Type Constraints
FuturesGridCreateRequest required: ["strategy_type","market","create_params"]

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["futures_grid"]
market string true
create_params FuturesGridCreateParams true required: ["money","low_price","high_price","grid_num","price_type","leverage"] Creation parameters for the contract grid strategy.

create_params

Creation parameters for the contract grid strategy.

Type Constraints
FuturesGridCreateParams required: ["money","low_price","high_price","grid_num","price_type","leverage"]

Properties

Name Type Required Constraints Description
money string true
low_price string true
high_price string true
grid_num integer(int32) true minimum: 1
price_type integer(int32) true enum: [0,1]
leverage string true
direction FuturesDirection false enum: ["long","short","neutral"] Direction enumeration supported by contract-based strategies.
trigger_price string false
stop_profit string false
stop_loss string false
profit_sharing_ratio string false
is_use_base boolean false

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string",
    "operation_status": "string",
    "recovery_required": true
  },
  "trace_id": "string",
  "label": "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.

Type Constraints
AIHubCreateSuccessResponse required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubCreateData false Policy information returned after the policy is successfully created.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

data

Policy information returned after the policy is successfully created.

Type Constraints
AIHubCreateData

Properties

Name Type Required Constraints Description
strategy_id string false
strategy_type StrategyType false enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
market string false
status string false Observed product lifecycle state, or unknown. Creation acceptance/starting is not running; stopping/finished alone does not prove funds settled.
jump_url string false
operation_status string false pending when the write result requires verification; rejected for a proven pre-effect refusal.
recovery_required boolean false

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

# Request Body Schema

Create the request body of the Spot Martin strategy.

Type Constraints
SpotMartingaleCreateRequest required: ["strategy_type","market","create_params"]

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["spot_martingale"]
market string true
create_params SpotMartingaleCreateParams true required: ["invest_amount","price_deviation","max_orders","take_profit_ratio"] 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).

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).
Type Constraints
SpotMartingaleCreateParams required: ["invest_amount","price_deviation","max_orders","take_profit_ratio"]

Properties

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

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string",
    "operation_status": "string",
    "recovery_required": true
  },
  "trace_id": "string",
  "label": "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.

Type Constraints
AIHubCreateSuccessResponse required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubCreateData false Policy information returned after the policy is successfully created.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

data

Policy information returned after the policy is successfully created.

Type Constraints
AIHubCreateData

Properties

Name Type Required Constraints Description
strategy_id string false
strategy_type StrategyType false enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
market string false
status string false Observed product lifecycle state, or unknown. Creation acceptance/starting is not running; stopping/finished alone does not prove funds settled.
jump_url string false
operation_status string false pending when the write result requires verification; rejected for a proven pre-effect refusal.
recovery_required boolean false

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","stop_loss_price_type":"last"}}'
# 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","stop_loss_price_type":"last"}}'
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",
    "stop_loss_price_type": "last"
  }
}

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

# Enumerated Values

Parameter Value
strategy_type contract_martingale

# Request Body Schema

Create the request body of the contract Martin strategy.

Type Constraints
ContractMartingaleCreateRequest required: ["strategy_type","market","create_params"]

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["contract_martingale"]
market string true
create_params ContractMartingaleCreateParams true required: ["invest_amount","price_deviation","max_orders","take_profit_ratio","direction","leverage"] The creation parameters of the contract Martin strategy.

create_params

The creation parameters of the contract Martin strategy.

Type Constraints
ContractMartingaleCreateParams required: ["invest_amount","price_deviation","max_orders","take_profit_ratio","direction","leverage"]

Properties

Name Type Required in this object Constraints Description
invest_amount string true Total strategy budget, not first-order margin. The server uses the complete existing ladder formula, owner fee and live contract facts, quantizes quantity down and rechecks before allocation. Minimum infeasible budget is rejected.
price_deviation string true
max_orders integer(int32) true minimum: 1 Maximum additional entries, excluding the first; preserve this legacy meaning.
take_profit_ratio string true
direction ContractMartingaleDirection true enum: ["buy","sell"] The direction enumeration supported by the contract Martin strategy is consistent with the original interface of the App.
leverage string true
stop_loss_price string false Positive fixed stop price; requires explicit stop_loss_price_type. Missing both leaves the old no-fixed-stop request unchanged.
profit_sharing_ratio string false
stop_loss_price_type string false enum: ["last","index","mark"]

create_params / allOf[0]

Type Constraints
oneOf

create_params / allOf[0] / oneOf[0]

Type Constraints
not

create_params / allOf[0] / oneOf[0] / not

Type Constraints
anyOf

create_params / allOf[0] / oneOf[0] / not / anyOf[0]

Type Constraints
any required: ["stop_loss_price"]

create_params / allOf[0] / oneOf[0] / not / anyOf[1]

Type Constraints
any required: ["stop_loss_price_type"]

create_params / allOf[0] / oneOf[1]

Type Constraints
any required: ["stop_loss_price","stop_loss_price_type"]

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string",
    "operation_status": "string",
    "recovery_required": true
  },
  "trace_id": "string",
  "label": "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.

Type Constraints
AIHubCreateSuccessResponse required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubCreateData false Policy information returned after the policy is successfully created.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

data

Policy information returned after the policy is successfully created.

Type Constraints
AIHubCreateData

Properties

Name Type Required Constraints Description
strategy_id string false
strategy_type StrategyType false enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
market string false
status string false Observed product lifecycle state, or unknown. Creation acceptance/starting is not running; stopping/finished alone does not prove funds settled.
jump_url string false
operation_status string false pending when the write result requires verification; rejected for a proven pre-effect refusal.
recovery_required boolean false

WARNING

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

# List running strategies.

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

List running strategies.

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
strategy_type smart_position
strategy_type futures_combo

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "items": [
      {}
    ],
    "page": 0,
    "page_size": 0,
    "total": 0
  },
  "trace_id": "string",
  "label": "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.

Type Constraints
AIHubPortfolioRunningSuccessResponse required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubPortfolioRunningData false required: ["items","page","page_size","total"] Running policy list data.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

data

Running policy list data.

Type Constraints
AIHubPortfolioRunningData required: ["items","page","page_size","total"]

Properties

Name Type Required Constraints Description
items array true
page integer(int32) true
page_size integer(int32) true
total integer(int32) true

data / items

Type Constraints
array

data / items / items

A single record in the list of running policies.

Type Constraints
AIHubPortfolioRunningItem required: ["strategy_id","strategy_type","strategy_name","market","status"]

Properties

Name Type Required Constraints Description
strategy_id string true
strategy_type StrategyType true enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
strategy_name string true
market string true Single market, or empty string for a portfolio; use assets/markets for the latter.
status string true
pnl string false
pnl_rate string false
invest_amount string false
created_at string false Created time
assets array false
markets array false

data / items / items / assets

Type Constraints
array

data / items / items / assets / items

Type Constraints
string

data / items / items / markets

Type Constraints
array

data / items / items / markets / items

Type Constraints
string

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
strategy_type smart_position
strategy_type futures_combo

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,
    "assets": [
      "string"
    ],
    "markets": [
      "string"
    ],
    "positions": [
      {}
    ],
    "positions_status": "verified",
    "configuration": {},
    "stop_progress": {
      "trading_finished": true,
      "funds_returned": true,
      "refund_amount": "string",
      "refund_currency": "string",
      "account_released": true
    }
  },
  "trace_id": "string",
  "label": "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.

Type Constraints
AIHubPortfolioDetailSuccessResponse required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubPortfolioDetailData false required: ["strategy_id","strategy_type","market","status","base_info","metrics","stop_supported"] Policy details data.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

data

Policy details data.

Type Constraints
AIHubPortfolioDetailData required: ["strategy_id","strategy_type","market","status","base_info","metrics","stop_supported"]

Properties

Name Type Required Constraints Description
strategy_id string true
strategy_type StrategyType true enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
market string true Single market, or empty string for a portfolio; use assets/markets for the latter.
status string true
base_info AIHubPortfolioBaseInfo true required: ["strategy_name","created_at","running_duration","invest_amount","total_profit","profit_rate"] Strategy detail base info.
metrics AIHubPortfolioMetrics true Strategy detail metrics; fields returned depend on strategy type.
position AIHubPortfolioPosition|null false nullable: true Strategy detail position info; fields returned depend on strategy type.
stop_supported boolean true
assets array false
markets array false
positions array false
positions_status string false enum: ["verified","partial","unverified","historical"]
configuration object false Product-specific saved configuration. spot_martingale exposes AIHubSpotMartingaleConfiguration; absence is unverified. Runtime recovery internals are excluded.
stop_progress AIHubStopProgress false Read-only projection of durable facts. Absent values are unverified. Final refund excludes ordinary decrease-principal transfers. Account release is never inferred from stopped status or an empty account.

data / base_info

Strategy detail base info.

Type Constraints
AIHubPortfolioBaseInfo required: ["strategy_name","created_at","running_duration","invest_amount","total_profit","profit_rate"]

Properties

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

data / metrics

Strategy detail metrics; fields returned depend on strategy type.

Type Constraints
AIHubPortfolioMetrics

Properties

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

data / position

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

Type Constraints
AIHubPortfolioPosition|null nullable: true

Properties

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

data / assets

Type Constraints
array

data / assets / items

Type Constraints
string

data / markets

Type Constraints
array

data / markets / items

Type Constraints
string

data / positions

Type Constraints
array

data / positions / items

Position information for one asset or market in a portfolio strategy.

Type Constraints
AIHubPortfolioAssetPosition

Properties

Name Type Required Constraints Description
asset string false
market string false
side string false
amount string false
amount_unit string false
entry_price string false
position_value string false
position_value_unit string false
target_weight string false
leverage string false

data / stop_progress

Read-only projection of durable facts. Absent values are unverified. Final refund excludes ordinary decrease-principal transfers. Account release is never inferred from stopped status or an empty account.

Type Constraints
AIHubStopProgress

Properties

Name Type Required Constraints Description
trading_finished boolean false
funds_returned boolean false
refund_amount string false
refund_currency string false
account_released boolean false

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":null,"stop_mode":"market","stop_options":{"price":"string","expiration":1,"slip":"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/portfolio/stop"
query_param=""
body_param='{"strategy_id":"string","strategy_type":null,"stop_mode":"market","stop_options":{"price":"string","expiration":1,"slip":"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/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": null,
  "stop_mode": "market",
  "stop_options": {
    "price": "string",
    "expiration": 1,
    "slip": "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 AIHubPortfolioStopRequest true none

# Request Body Schema

Single owner-scoped stop. Existing six-type ID/type requests retain default exits. smart_position requires explicit mode, limit requires options; futures_combo uses fixed whole-portfolio close/settlement.

Type Constraints
AIHubPortfolioStopRequest required: ["strategy_id","strategy_type"]

Properties

Name Type Required in this object Constraints Description
strategy_id string true
strategy_type StrategyType true enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
stop_mode string false enum: ["market","limit","no_close"] Required only for smart_position. Other types reject custom exit options.
stop_options AIHubRebalanceStopOptions false required: ["price","expiration"]
additionalProperties: false
Options for the limit stop mode of a smart-position strategy.

stop_options

Options for the limit stop mode of a smart-position strategy.

Type Constraints
AIHubRebalanceStopOptions required: ["price","expiration"]
additionalProperties: false

Properties

Name Type Required Constraints Description
price string true One product-supported price expression; not one expression per member.
expiration integer(int64) true minimum: 1 Seconds of validity. Expiry cancels and returns assets; never switches to market.
slip string false Optional ratio 0.001–0.05, precision at most six.

allOf[0]

Type Constraints
oneOf

allOf[0] / oneOf[0]

Type Constraints
object

Properties

Name Type Required in this object Constraints Description
strategy_type not true

allOf[0] / oneOf[0] / strategy_type

Type Constraints
not

allOf[0] / oneOf[0] / strategy_type / not

Type Constraints
string

Enumerated Values

Value
"smart_position"

allOf[0] / oneOf[0] / not

Type Constraints
anyOf

allOf[0] / oneOf[0] / not / anyOf[0]

Type Constraints
any required: ["stop_mode"]

allOf[0] / oneOf[0] / not / anyOf[1]

Type Constraints
any required: ["stop_options"]

allOf[0] / oneOf[1]

Type Constraints
object required: ["stop_mode"]

Properties

Name Type Required in this object Constraints Description
strategy_type string true enum: ["smart_position"]
stop_mode string true enum: ["market","no_close"]

allOf[0] / oneOf[1] / not

Type Constraints
any required: ["stop_options"]

allOf[0] / oneOf[2]

Type Constraints
object required: ["stop_mode","stop_options"]

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["smart_position"]
stop_mode string true enum: ["limit"]

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "status": "string",
    "result_message": "string",
    "operation_status": "string",
    "recovery_required": true
  },
  "trace_id": "string",
  "label": "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.

Type Constraints
AIHubPortfolioStopSuccessResponse required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubPortfolioStopData false The result information returned after the termination strategy is successful.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

data

The result information returned after the termination strategy is successful.

Type Constraints
AIHubPortfolioStopData

Properties

Name Type Required Constraints Description
strategy_id string false
strategy_type StrategyType false enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
status string false Observed product lifecycle state, or unknown. Creation acceptance/starting is not running; stopping/finished alone does not prove funds settled.
result_message string false
operation_status string false pending when the write result requires verification; rejected for a proven pre-effect refusal.
recovery_required boolean false

WARNING

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

# Create rebalance bot

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/smart-position/create'
query_param = ''
body='{"strategy_type":"smart_position","create_params":{}}'
# 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/smart-position/create"
query_param=""
body_param='{"strategy_type":"smart_position","create_params":{}}'
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/smart-position/create

Create rebalance bot

Typed AIHub adapter; authenticated owner comes only from trusted gateway context.

Body parameter

{
  "strategy_type": "smart_position",
  "create_params": {}
}

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 AIHubRebalanceCreateRequest true none
strategy_type body string true none

# Enumerated Values

Parameter Value
strategy_type smart_position

# Request Body Schema

Request body for creating a smart-position strategy.

Type Constraints
AIHubRebalanceCreateRequest required: ["strategy_type","create_params"]
additionalProperties: false

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["smart_position"]
create_params AIHubRebalanceCreateParams true required: ["begin_money_amount","begin_money_currency","asset_info"]
additionalProperties: false
Creation parameters for a smart-position strategy.

create_params

Creation parameters for a smart-position strategy.

Type Constraints
AIHubRebalanceCreateParams required: ["begin_money_amount","begin_money_currency","asset_info"]
additionalProperties: false

Properties

Name Type Required in this object Constraints Description
begin_money_amount string true
begin_money_currency string true enum: ["USDT"]
asset_info array true minItems: 2
maxItems: 10
period string false Product interval between 1m and 28d.
threshold string false Positive ratio below 1, at most four decimal places.
close_flag integer false enum: [0,1]
default: 1
is_use_base boolean false
stop_profit string false
stop_loss string false

create_params / asset_info

Type Constraints
array minItems: 2
maxItems: 10

create_params / asset_info / items

One asset and its target weight in a smart-position strategy.

Type Constraints
AIHubRebalanceAsset required: ["asset","rate"]
additionalProperties: false

Properties

Name Type Required Constraints Description
asset string true
rate string true Two decimal places, minimum 0.01; unique assets and sum exactly 1.

create_params / oneOf[0]

Type Constraints
not required: ["period"]

create_params / oneOf[0] / not

Type Constraints
any required: ["threshold"]

create_params / oneOf[1]

Type Constraints
not required: ["threshold"]

create_params / oneOf[1] / not

Type Constraints
any required: ["period"]

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string",
    "operation_status": "string",
    "recovery_required": true
  },
  "trace_id": "string",
  "label": "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.

Type Constraints
AIHubCreateSuccessResponse required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubCreateData false Policy information returned after the policy is successfully created.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

data

Policy information returned after the policy is successfully created.

Type Constraints
AIHubCreateData

Properties

Name Type Required Constraints Description
strategy_id string false
strategy_type StrategyType false enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
market string false
status string false Observed product lifecycle state, or unknown. Creation acceptance/starting is not running; stopping/finished alone does not prove funds settled.
jump_url string false
operation_status string false pending when the write result requires verification; rejected for a proven pre-effect refusal.
recovery_required boolean false

WARNING

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

# Create futures-combo bot

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-combo/create'
query_param = ''
body='{"strategy_type":"futures_combo","create_params":{}}'
# 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-combo/create"
query_param=""
body_param='{"strategy_type":"futures_combo","create_params":{}}'
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-combo/create

Create futures-combo bot

Typed AIHub adapter; authenticated owner comes only from trusted gateway context.

Body parameter

{
  "strategy_type": "futures_combo",
  "create_params": {}
}

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 AIHubFuturesComboCreateRequest true none
strategy_type body string true none

# Enumerated Values

Parameter Value
strategy_type futures_combo

# Request Body Schema

Request body for creating a futures-combo strategy.

Type Constraints
AIHubFuturesComboCreateRequest required: ["strategy_type","create_params"]
additionalProperties: false

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["futures_combo"]
create_params AIHubFuturesComboCreateParams true required: ["begin_money_amount","begin_money_currency","asset_info","leverage"]
additionalProperties: false
Creation parameters for a futures-combo strategy.

create_params

Creation parameters for a futures-combo strategy.

Type Constraints
AIHubFuturesComboCreateParams required: ["begin_money_amount","begin_money_currency","asset_info","leverage"]
additionalProperties: false

Properties

Name Type Required in this object Constraints Description
begin_money_amount string true
begin_money_currency string true enum: ["USDT"]
asset_info array true minItems: 2
maxItems: 10
leverage integer true minimum: 1
maximum: 100
period string false enum: ["30m","1h","4h","8h","12h","1d","3d","7d","14d","28d"]
threshold string false Ratio 0.01–0.50; exclusive with period.
stop_profit string|null false nullable: true
stop_loss string|null false nullable: true

create_params / asset_info

Type Constraints
array minItems: 2
maxItems: 10

create_params / asset_info / items

One contract member of a futures-combo strategy.

Type Constraints
AIHubFuturesComboAsset required: ["market","side","rate"]
additionalProperties: false

Properties

Name Type Required Constraints Description
market string true
side string true enum: ["buy","sell"]
rate string true Ratio 0.01–1 in increments of 0.01; all member weights sum to 1.

create_params / oneOf[0]

Type Constraints
not required: ["period"]

create_params / oneOf[0] / not

Type Constraints
any required: ["threshold"]

create_params / oneOf[1]

Type Constraints
not required: ["threshold"]

create_params / oneOf[1] / not

Type Constraints
any required: ["period"]

Example responses

200 Response

{
  "code": 200,
  "message": "success",
  "data": {
    "strategy_id": "string",
    "strategy_type": "spot_grid",
    "market": "string",
    "status": "string",
    "jump_url": "string",
    "operation_status": "string",
    "recovery_required": true
  },
  "trace_id": "string",
  "label": "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.

Type Constraints
AIHubCreateSuccessResponse required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubCreateData false Policy information returned after the policy is successfully created.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

data

Policy information returned after the policy is successfully created.

Type Constraints
AIHubCreateData

Properties

Name Type Required Constraints Description
strategy_id string false
strategy_type StrategyType false enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
market string false
status string false Observed product lifecycle state, or unknown. Creation acceptance/starting is not running; stopping/finished alone does not prove funds settled.
jump_url string false
operation_status string false pending when the write result requires verification; rejected for a proven pre-effect refusal.
recovery_required boolean false

WARNING

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

# Schemas

# AIHubDiscoverSuccessResponse

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

Get the response body when the strategy recommendation is successful.

Type Constraints
object required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubDiscoverData false required: ["scene","recommendations","unsupported_filters"] Strategy recommendation result data.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

# AIHubPortfolioStopSuccessResponse

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

The response body when the termination strategy is successful.

Type Constraints
object required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubPortfolioStopData false The result information returned after the termination strategy is successful.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

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

Type Constraints
object required: ["strategy_type","market","create_params"]

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["infinite_grid"]
market string true
create_params InfiniteGridCreateParams true required: ["money","price_floor","profit_per_grid"] 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).

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

Type Constraints
object required: ["strategy_type","market","create_params"]

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["margin_grid"]
market string true
create_params MarginGridCreateParams true required: ["money","low_price","high_price","grid_num","price_type","leverage"] Creation parameters for the Leverage Grid strategy.

# AIHubPortfolioRunningSuccessResponse

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

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

Type Constraints
object required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubPortfolioRunningData false required: ["items","page","page_size","total"] Running policy list data.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

# 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",
    "stop_loss_price_type": "last"
  }
}

Create the request body of the contract Martin strategy.

Type Constraints
object required: ["strategy_type","market","create_params"]

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["contract_martingale"]
market string true
create_params ContractMartingaleCreateParams true required: ["invest_amount","price_deviation","max_orders","take_profit_ratio","direction","leverage"] The creation parameters of the contract Martin strategy.

# AIHubFuturesComboCreateRequest

{
  "strategy_type": "futures_combo",
  "create_params": {}
}

Request body for creating a futures-combo strategy.

Type Constraints
object required: ["strategy_type","create_params"]
additionalProperties: false

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["futures_combo"]
create_params AIHubFuturesComboCreateParams true required: ["begin_money_amount","begin_money_currency","asset_info","leverage"]
additionalProperties: false
Creation parameters for a futures-combo strategy.

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

Type Constraints
object required: ["money","low_price","high_price","grid_num","price_type","leverage"]

Properties

Name Type Required Constraints Description
money string true
low_price string true
high_price string true
grid_num integer(int32) true minimum: 1
price_type integer(int32) true enum: [0,1]
leverage string true
direction FuturesDirection false enum: ["long","short","neutral"] Direction enumeration supported by contract-based strategies.
trigger_price string false
stop_profit string false
stop_loss string false
profit_sharing_ratio string false
is_use_base boolean false

# AIHubCreateSuccessResponse

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

The response body when the creation strategy is successful.

Type Constraints
object required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubCreateData false Policy information returned after the policy is successfully created.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

# 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",
  "stop_loss_price_type": "last"
}

The creation parameters of the contract Martin strategy.

Type Constraints
object required: ["invest_amount","price_deviation","max_orders","take_profit_ratio","direction","leverage"]

Properties

Name Type Required in this object Constraints Description
invest_amount string true Total strategy budget, not first-order margin. The server uses the complete existing ladder formula, owner fee and live contract facts, quantizes quantity down and rechecks before allocation. Minimum infeasible budget is rejected.
price_deviation string true
max_orders integer(int32) true minimum: 1 Maximum additional entries, excluding the first; preserve this legacy meaning.
take_profit_ratio string true
direction ContractMartingaleDirection true enum: ["buy","sell"] The direction enumeration supported by the contract Martin strategy is consistent with the original interface of the App.
leverage string true
stop_loss_price string false Positive fixed stop price; requires explicit stop_loss_price_type. Missing both leaves the old no-fixed-stop request unchanged.
profit_sharing_ratio string false
stop_loss_price_type string false enum: ["last","index","mark"]

allOf[0]

Type Constraints
oneOf

allOf[0] / oneOf[0]

Type Constraints
not

allOf[0] / oneOf[0] / not

Type Constraints
anyOf

allOf[0] / oneOf[0] / not / anyOf[0]

Type Constraints
any required: ["stop_loss_price"]

allOf[0] / oneOf[0] / not / anyOf[1]

Type Constraints
any required: ["stop_loss_price_type"]

allOf[0] / oneOf[1]

Type Constraints
any required: ["stop_loss_price","stop_loss_price_type"]

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

Type Constraints
object required: ["strategy_type","market","create_params"]

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["spot_martingale"]
market string true
create_params SpotMartingaleCreateParams true required: ["invest_amount","price_deviation","max_orders","take_profit_ratio"] 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).

# AIHubPortfolioStopData

{
  "strategy_id": "string",
  "strategy_type": "spot_grid",
  "status": "string",
  "result_message": "string",
  "operation_status": "string",
  "recovery_required": true
}

The result information returned after the termination strategy is successful.

Type Constraints
object

Properties

Name Type Required Constraints Description
strategy_id string false
strategy_type StrategyType false enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
status string false Observed product lifecycle state, or unknown. Creation acceptance/starting is not running; stopping/finished alone does not prove funds settled.
result_message string false
operation_status string false pending when the write result requires verification; rejected for a proven pre-effect refusal.
recovery_required boolean false

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

Type Constraints
object required: ["strategy_type","market","create_params"]

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["spot_grid"]
market string true
create_params SpotGridCreateParams true required: ["money","low_price","high_price","grid_num","price_type"] Creation parameters for the spot grid strategy.

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

Type Constraints
object required: ["strategy_type","market","create_params"]

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["futures_grid"]
market string true
create_params FuturesGridCreateParams true required: ["money","low_price","high_price","grid_num","price_type","leverage"] Creation parameters for the contract grid strategy.

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

Type Constraints
object required: ["money","low_price","high_price","grid_num","price_type"]

Properties

Name Type Required Constraints Description
money string true Amount of investment
low_price string true Range lower limit
high_price string true Range upper limit
grid_num integer(int32) true minimum: 1 Number of grids
price_type integer(int32) true enum: [0,1]
trigger_price string false
stop_profit string false
stop_loss string false
profit_sharing_ratio string false
is_use_base boolean false

# FuturesDirection

"long"

Direction enumeration supported by contract-based strategies.

Type Constraints
string

Enumerated Values

Value
"long"
"short"
"neutral"

# ContractMartingaleDirection

"buy"

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

Type Constraints
string

Enumerated Values

Value
"buy"
"sell"

# 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,
    "assets": [
      "string"
    ],
    "markets": [
      "string"
    ],
    "positions": [
      {}
    ],
    "positions_status": "verified",
    "configuration": {},
    "stop_progress": {
      "trading_finished": true,
      "funds_returned": true,
      "refund_amount": "string",
      "refund_currency": "string",
      "account_released": true
    }
  },
  "trace_id": "string",
  "label": "string"
}

The response body when querying policy details is successful.

Type Constraints
object required: ["code","message"]

Properties

Name Type Required Constraints Description
code integer(int32) true
message string true
data AIHubPortfolioDetailData false required: ["strategy_id","strategy_type","market","status","base_info","metrics","stop_supported"] Policy details data.
trace_id string false
label string false Stable business error label when present. HTTP 200 can contain a non-200 business code; data may retain a real identity on failure.

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

Type Constraints
object required: ["money","price_floor","profit_per_grid"]

Properties

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

# AIHubRebalanceCreateRequest

{
  "strategy_type": "smart_position",
  "create_params": {}
}

Request body for creating a smart-position strategy.

Type Constraints
object required: ["strategy_type","create_params"]
additionalProperties: false

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["smart_position"]
create_params AIHubRebalanceCreateParams true required: ["begin_money_amount","begin_money_currency","asset_info"]
additionalProperties: false
Creation parameters for a smart-position strategy.

# AIHubCreateData

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

Policy information returned after the policy is successfully created.

Type Constraints
object

Properties

Name Type Required Constraints Description
strategy_id string false
strategy_type StrategyType false enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
market string false
status string false Observed product lifecycle state, or unknown. Creation acceptance/starting is not running; stopping/finished alone does not prove funds settled.
jump_url string false
operation_status string false pending when the write result requires verification; rejected for a proven pre-effect refusal.
recovery_required boolean false

# StrategyType

"spot_grid"

The complete enumeration of policy types supported by AIHub.

Type Constraints
string

Enumerated Values

Value
"spot_grid"
"margin_grid"
"infinite_grid"
"futures_grid"
"spot_martingale"
"contract_martingale"
"smart_position"
"futures_combo"

# AIHubPortfolioStopRequest

{
  "strategy_id": "string",
  "strategy_type": null,
  "stop_mode": "market",
  "stop_options": {
    "price": "string",
    "expiration": 1,
    "slip": "string"
  }
}

Single owner-scoped stop. Existing six-type ID/type requests retain default exits. smart_position requires explicit mode, limit requires options; futures_combo uses fixed whole-portfolio close/settlement.

Type Constraints
object required: ["strategy_id","strategy_type"]

Properties

Name Type Required in this object Constraints Description
strategy_id string true
strategy_type StrategyType true enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
stop_mode string false enum: ["market","limit","no_close"] Required only for smart_position. Other types reject custom exit options.
stop_options AIHubRebalanceStopOptions false required: ["price","expiration"]
additionalProperties: false
Options for the limit stop mode of a smart-position strategy.

allOf[0]

Type Constraints
oneOf

allOf[0] / oneOf[0]

Type Constraints
object

Properties

Name Type Required in this object Constraints Description
strategy_type not true

allOf[0] / oneOf[0] / strategy_type

Type Constraints
not

allOf[0] / oneOf[0] / strategy_type / not

Type Constraints
string

Enumerated Values

Value
"smart_position"

allOf[0] / oneOf[0] / not

Type Constraints
anyOf

allOf[0] / oneOf[0] / not / anyOf[0]

Type Constraints
any required: ["stop_mode"]

allOf[0] / oneOf[0] / not / anyOf[1]

Type Constraints
any required: ["stop_options"]

allOf[0] / oneOf[1]

Type Constraints
object required: ["stop_mode"]

Properties

Name Type Required in this object Constraints Description
strategy_type string true enum: ["smart_position"]
stop_mode string true enum: ["market","no_close"]

allOf[0] / oneOf[1] / not

Type Constraints
any required: ["stop_options"]

allOf[0] / oneOf[2]

Type Constraints
object required: ["stop_mode","stop_options"]

Properties

Name Type Required Constraints Description
strategy_type string true enum: ["smart_position"]
stop_mode string true enum: ["limit"]

# 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",
      "assets": [],
      "markets": []
    }
  ],
  "page": 0,
  "page_size": 0,
  "total": 0
}

Running policy list data.

Type Constraints
object required: ["items","page","page_size","total"]

Properties

Name Type Required Constraints Description
items array true
page integer(int32) true
page_size integer(int32) true
total integer(int32) true

items

Type Constraints
array

items / items

A single record in the list of running policies.

Type Constraints
AIHubPortfolioRunningItem required: ["strategy_id","strategy_type","strategy_name","market","status"]

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

Type Constraints
object required: ["scene","recommendations","unsupported_filters"]

Properties

Name Type Required Constraints Description
scene DiscoverScene true enum: ["top1","bundle","filter","refresh"] Enumeration of scenarios supported by the policy recommendation interface.
recommendations array true
unsupported_filters array true Filter conditions not supported in this issue

recommendations

Type Constraints
array

recommendations / items

A single piece of strategy recommendation information.

Type Constraints
AIHubRecommendation required: ["recommendation_id","market","strategy_type","strategy_name","summary"]

unsupported_filters

Filter conditions not supported in this issue

Type Constraints
array

unsupported_filters / items

Type Constraints
string

# 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).
Type Constraints
object required: ["invest_amount","price_deviation","max_orders","take_profit_ratio"]

Properties

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

# AIHubFuturesComboCreateParams

{}

Creation parameters for a futures-combo strategy.

Type Constraints
object required: ["begin_money_amount","begin_money_currency","asset_info","leverage"]
additionalProperties: false

Properties

Name Type Required in this object Constraints Description
begin_money_amount string true
begin_money_currency string true enum: ["USDT"]
asset_info array true minItems: 2
maxItems: 10
leverage integer true minimum: 1
maximum: 100
period string false enum: ["30m","1h","4h","8h","12h","1d","3d","7d","14d","28d"]
threshold string false Ratio 0.01–0.50; exclusive with period.
stop_profit string|null false nullable: true
stop_loss string|null false nullable: true

asset_info

Type Constraints
array minItems: 2
maxItems: 10

asset_info / items

One contract member of a futures-combo strategy.

Type Constraints
AIHubFuturesComboAsset required: ["market","side","rate"]
additionalProperties: false

oneOf[0]

Type Constraints
not required: ["period"]

oneOf[0] / not

Type Constraints
any required: ["threshold"]

oneOf[1]

Type Constraints
not required: ["threshold"]

oneOf[1] / not

Type Constraints
any required: ["period"]

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

Type Constraints
object required: ["money","low_price","high_price","grid_num","price_type","leverage"]

Properties

Name Type Required Constraints Description
money string true
low_price string true
high_price string true
grid_num integer(int32) true minimum: 1
price_type integer(int32) true enum: [0,1]
leverage string true
direction FuturesDirection false enum: ["long","short","neutral"] Direction enumeration supported by contract-based strategies.
trigger_price string false
stop_profit string false
stop_loss string false
profit_sharing_ratio string false
is_use_base boolean false

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

Type Constraints
object required: ["recommendation_id","market","strategy_type","strategy_name","summary"]

Properties

Name Type Required Constraints Description
recommendation_id string true
market string true
strategy_type StrategyType true enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
strategy_name string true
backtest_apr string false
max_drawdown string false
summary string true
strategy_params_preview string false 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.

# AIHubFuturesComboAsset

{
  "market": "string",
  "side": "buy",
  "rate": "string"
}

One contract member of a futures-combo strategy.

Type Constraints
object required: ["market","side","rate"]
additionalProperties: false

Properties

Name Type Required Constraints Description
market string true
side string true enum: ["buy","sell"]
rate string true Ratio 0.01–1 in increments of 0.01; all member weights sum to 1.

# DiscoverScene

"top1"

Enumeration of scenarios supported by the policy recommendation interface.

Type Constraints
string

Enumerated Values

Value
"top1"
"bundle"
"filter"
"refresh"

# AIHubRebalanceCreateParams

{}

Creation parameters for a smart-position strategy.

Type Constraints
object required: ["begin_money_amount","begin_money_currency","asset_info"]
additionalProperties: false

Properties

Name Type Required in this object Constraints Description
begin_money_amount string true
begin_money_currency string true enum: ["USDT"]
asset_info array true minItems: 2
maxItems: 10
period string false Product interval between 1m and 28d.
threshold string false Positive ratio below 1, at most four decimal places.
close_flag integer false enum: [0,1]
default: 1
is_use_base boolean false
stop_profit string false
stop_loss string false

asset_info

Type Constraints
array minItems: 2
maxItems: 10

asset_info / items

One asset and its target weight in a smart-position strategy.

Type Constraints
AIHubRebalanceAsset required: ["asset","rate"]
additionalProperties: false

oneOf[0]

Type Constraints
not required: ["period"]

oneOf[0] / not

Type Constraints
any required: ["threshold"]

oneOf[1]

Type Constraints
not required: ["threshold"]

oneOf[1] / not

Type Constraints
any required: ["period"]

# 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,
  "assets": [
    "string"
  ],
  "markets": [
    "string"
  ],
  "positions": [
    {
      "asset": "string",
      "market": "string",
      "side": "string",
      "amount": "string",
      "amount_unit": "string",
      "entry_price": "string",
      "position_value": "string",
      "position_value_unit": "string",
      "target_weight": "string",
      "leverage": "string"
    }
  ],
  "positions_status": "verified",
  "configuration": {},
  "stop_progress": {
    "trading_finished": true,
    "funds_returned": true,
    "refund_amount": "string",
    "refund_currency": "string",
    "account_released": true
  }
}

Policy details data.

Type Constraints
object required: ["strategy_id","strategy_type","market","status","base_info","metrics","stop_supported"]

Properties

Name Type Required Constraints Description
strategy_id string true
strategy_type StrategyType true enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
market string true Single market, or empty string for a portfolio; use assets/markets for the latter.
status string true
base_info AIHubPortfolioBaseInfo true required: ["strategy_name","created_at","running_duration","invest_amount","total_profit","profit_rate"] Strategy detail base info.
metrics AIHubPortfolioMetrics true Strategy detail metrics; fields returned depend on strategy type.
position AIHubPortfolioPosition|null false nullable: true Strategy detail position info; fields returned depend on strategy type.
stop_supported boolean true
assets array false
markets array false
positions array false
positions_status string false enum: ["verified","partial","unverified","historical"]
configuration object false Product-specific saved configuration. spot_martingale exposes AIHubSpotMartingaleConfiguration; absence is unverified. Runtime recovery internals are excluded.
stop_progress AIHubStopProgress false Read-only projection of durable facts. Absent values are unverified. Final refund excludes ordinary decrease-principal transfers. Account release is never inferred from stopped status or an empty account.

assets

Type Constraints
array

assets / items

Type Constraints
string

markets

Type Constraints
array

markets / items

Type Constraints
string

positions

Type Constraints
array

positions / items

Position information for one asset or market in a portfolio strategy.

Type Constraints
AIHubPortfolioAssetPosition

# AIHubStopProgress

{
  "trading_finished": true,
  "funds_returned": true,
  "refund_amount": "string",
  "refund_currency": "string",
  "account_released": true
}

Read-only projection of durable facts. Absent values are unverified. Final refund excludes ordinary decrease-principal transfers. Account release is never inferred from stopped status or an empty account.

Type Constraints
object

Properties

Name Type Required Constraints Description
trading_finished boolean false
funds_returned boolean false
refund_amount string false
refund_currency string false
account_released boolean false

# AIHubRebalanceAsset

{
  "asset": "string",
  "rate": "string"
}

One asset and its target weight in a smart-position strategy.

Type Constraints
object required: ["asset","rate"]
additionalProperties: false

Properties

Name Type Required Constraints Description
asset string true
rate string true Two decimal places, minimum 0.01; unique assets and sum exactly 1.

# AIHubRebalanceStopOptions

{
  "price": "string",
  "expiration": 1,
  "slip": "string"
}

Options for the limit stop mode of a smart-position strategy.

Type Constraints
object required: ["price","expiration"]
additionalProperties: false

Properties

Name Type Required Constraints Description
price string true One product-supported price expression; not one expression per member.
expiration integer(int64) true minimum: 1 Seconds of validity. Expiry cancels and returns assets; never switches to market.
slip string false Optional ratio 0.001–0.05, precision at most six.

# 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",
  "assets": [
    "string"
  ],
  "markets": [
    "string"
  ]
}

A single record in the list of running policies.

Type Constraints
object required: ["strategy_id","strategy_type","strategy_name","market","status"]

Properties

Name Type Required Constraints Description
strategy_id string true
strategy_type StrategyType true enum: ["spot_grid","margin_grid","infinite_grid","futures_grid","spot_martingale","contract_martingale","smart_position","futures_combo"] The complete enumeration of policy types supported by AIHub.
strategy_name string true
market string true Single market, or empty string for a portfolio; use assets/markets for the latter.
status string true
pnl string false
pnl_rate string false
invest_amount string false
created_at string false Created time
assets array false
markets array false

assets

Type Constraints
array

assets / items

Type Constraints
string

markets

Type Constraints
array

markets / items

Type Constraints
string

# AIHubContractMartingaleConfiguration

{
  "invest_amount": "string",
  "investment_currency": "string",
  "price_deviation": "string",
  "take_profit_ratio": "string",
  "direction": "string",
  "first_order_size": "string",
  "max_orders": 0,
  "leverage": 0,
  "stop_loss_price_rule": {
    "price": "string",
    "price_type": "string",
    "is_gte": true
  }
}

AIHub-supported persisted contract settings. This is not a complete advanced native configuration.

Type Constraints
object

Properties

Name Type Required Constraints Description
invest_amount string false
investment_currency string false
price_deviation string false
take_profit_ratio string false
direction string false
first_order_size string false Exact decimal contract quantity from the product snapshot; empty remains unverified, never inferred from the total budget.
max_orders integer(int64) false Maximum additional entries excluding the first.
leverage integer(int32) false
stop_loss_price_rule AIHubMartingalePriceRule false Persisted price rule only, not proof that an order executed. Unknown price basis or non-positive price is not effective protection.

# AIHubPortfolioAssetPosition

{
  "asset": "string",
  "market": "string",
  "side": "string",
  "amount": "string",
  "amount_unit": "string",
  "entry_price": "string",
  "position_value": "string",
  "position_value_unit": "string",
  "target_weight": "string",
  "leverage": "string"
}

Position information for one asset or market in a portfolio strategy.

Type Constraints
object

Properties

Name Type Required Constraints Description
asset string false
market string false
side string false
amount string false
amount_unit string false
entry_price string false
position_value string false
position_value_unit string false
target_weight string false
leverage string false

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

Type Constraints
object

Properties

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

# AIHubMartingalePriceRule

{
  "price": "string",
  "price_type": "string",
  "is_gte": true
}

Persisted price rule only, not proof that an order executed. Unknown price basis or non-positive price is not effective protection.

Type Constraints
object

Properties

Name Type Required Constraints Description
price string false
price_type string false Original enum name (last/index/mark/unknown), or its numeric string for an unknown future enum.
is_gte boolean false

# AIHubPortfolioBaseInfo

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

Strategy detail base info.

Type Constraints
object required: ["strategy_name","created_at","running_duration","invest_amount","total_profit","profit_rate"]

Properties

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

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

Type Constraints
object|null nullable: true

Properties

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

# AIHubSpotMartingaleConfiguration

{
  "invest_amount": "string",
  "investment_currency": "string",
  "price_deviation": "string",
  "take_profit_ratio": "string",
  "stop_loss_per_cycle": "string",
  "trigger_price": "string",
  "max_orders": 0
}

Saved settings supported by AIHub, not a substitute for all advanced native configuration. Absent upstream params are unverified.

Type Constraints
object

Properties

Name Type Required Constraints Description
invest_amount string false
investment_currency string false
price_deviation string false
take_profit_ratio string false
stop_loss_per_cycle string false Saved per-cycle ratio, returned unchanged. Zero or negative legacy values do not constitute effective protection.
trigger_price string false
max_orders integer(int32) false Saved maximum additional entries excluding the first; not total orders.