Skip to content

# CFD

CFD is a contracts-for-difference trading business that provides MT5-based forex and CFD trading services. The CFD API provides complete user management, asset query, order management, position management, and market data query capabilities.

# Query MT5 account information

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 = '/tradfi/users/mt5-account'
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="/tradfi/users/mt5-account"
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 /tradfi/users/mt5-account

Query MT5 account information

Example responses

200 Response

{
  "data": {
    "mt5_uid": 0,
    "leverage": 0,
    "stop_out_level": "",
    "status": 1
  },
  "timestamp": 1769426795464
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success Mt5Account
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» code integer Business Status Code; Non-zero Indicates Business Exception, Please Check Message
» message string Response message
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Response data
»» mt5_uid integer MT5 userID
»» leverage integer Leverage multiplier
»» stop_out_level string Liquidation margin ratio
»» status integer Account status (1=not opened, 2=pending review, 3=active)

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Query trading symbol categories

Code samples

# coding: utf-8
import requests

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

url = '/tradfi/symbols/categories'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/tradfi/symbols/categories \
  -H 'Accept: application/json'

GET /tradfi/symbols/categories

Query trading symbol categories

Example responses

200 Response

{
  "data": {
    "list": [
      {
        "category_id": 1,
        "is_favorite": false,
        "category_name": "金属"
      },
      {
        "category_id": 2,
        "is_favorite": false,
        "category_name": "Stocks"
      },
      {
        "category_id": 4,
        "is_favorite": false,
        "category_name": "指数"
      },
      {
        "category_id": 5,
        "is_favorite": false,
        "category_name": "外汇"
      },
      {
        "category_id": 6,
        "is_favorite": false,
        "category_name": "大宗商品"
      }
    ]
  },
  "timestamp": 1769398039786
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success Categories
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Data
»» list array none
»»» None object Category information
»»»» category_id integer Category ID
»»»» is_favorite boolean Whether it is a custom category, generally no need to pay attention
»»»» category_name string Category name

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

# Query symbol commission rates

Code samples

# coding: utf-8
import requests

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

url = '/tradfi/symbols/commissions'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/tradfi/symbols/commissions \
  -H 'Accept: application/json'

GET /tradfi/symbols/commissions

Query symbol commission rates

Parameters

Name In Type Required Description
symbols query string false List of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required
category_code query string false List of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required

Example responses

200 Response

{
  "data": {
    "list": [
      {
        "category_code": "forex",
        "symbol": "AUDUSD",
        "fee_per_lot": "6"
      },
      {
        "category_code": "metal",
        "symbol": "XAUUSD",
        "fee_per_lot": "6"
      }
    ]
  },
  "timestamp": 1769426795464
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success SymbolCommissions
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Response data
»» list array List of symbol commission rates
»»» None object Symbol commission rate
»»»» category_code string Category code
»»»» symbol string Trading symbol code
»»»» fee_per_lot string Commission rate per lot

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

# Query trading symbol list

Code samples

# coding: utf-8
import requests

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

url = '/tradfi/symbols'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/tradfi/symbols \
  -H 'Accept: application/json'

GET /tradfi/symbols

Query trading symbol list

Example responses

200 Response

{
  "data": {
    "list": [
      {
        "symbol": "EURUSD",
        "symbol_desc": "Euro vs United States Dollar",
        "category_id": 6,
        "status": "open",
        "trade_mode": "4",
        "icon_link": "https://gimg.staticimgs.com/image/eurusd_20260123_120701_3982593a8387f849b5eb60a05bbadd3c.png",
        "close_time": 1769464800,
        "open_time": 1769378400,
        "next_open_time": 0,
        "settlement_currency": "USD",
        "settlement_currency_symbol": "$",
        "price_precision": 8
      },
      {
        "symbol": "XAGUSD",
        "symbol_desc": "Silver vs US Dollar / Spot",
        "category_id": 1,
        "status": "open",
        "trade_mode": "4",
        "icon_link": "https://gimg.staticimgs.com/image/xagusd_20260115_162831_6d2429db5ad657da37d139eb33e4a324.png",
        "close_time": 1769464800,
        "open_time": 1769378400,
        "next_open_time": 0,
        "settlement_currency": "USD",
        "settlement_currency_symbol": "$",
        "price_precision": 3
      }
    ]
  },
  "timestamp": 1769426795464
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success Symbols
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Response data
»» list array Trading symbol list
»»» None object Trading symbol information
»»»» symbol string Trading symbol code
»»»» symbol_desc string Trading symbol description
»»»» category_id integer Category ID
»»»» status string Trading status (open=tradable, closed=non-tradable)
»»»» trade_mode string Trading mode code (0=disabled, 1=long only, 2=short only, 3=close only, 4=full trading access)
»»»» icon_link string Symbol icon URL
»»»» close_time integer(int64) Close time (Unix timestamp in seconds)
»»»» open_time integer(int64) Open time (Unix timestamp in seconds)
»»»» next_open_time integer(int64) Next open time (Unix timestamp in seconds, 0 means none)
»»»» settlement_currency string Settlement currency
»»»» settlement_currency_symbol string Settlement currency symbol
»»»» price_precision integer Price precision (decimal places)

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

# Query trading symbol details

Code samples

# coding: utf-8
import requests

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

url = '/tradfi/symbols/detail'
query_param = 'symbols=EURUSD,XAGUSD'
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/tradfi/symbols/detail?symbols=EURUSD%2CXAGUSD \
  -H 'Accept: application/json'

GET /tradfi/symbols/detail

Query trading symbol details

Parameters

Name In Type Required Description
symbols query string true Trading symbol code list (comma-separated, max 10 symbols)

Example responses

200 Response

{
  "data": {
    "list": [
      {
        "symbol": "PLNJPY",
        "symbol_desc": "掉期费-货币-预0",
        "category_name": "Forex",
        "contract_volume": "100000",
        "settlement_currency": "JPY",
        "max_order_volume": "100",
        "min_order_volume": "10",
        "leverage": "25",
        "price_precision": 4,
        "price_sl_level": "100.00",
        "swap_cost_type": "1",
        "buy_swap_cost_rate": "7.937347",
        "sell_swap_cost_rate": "-172.856426",
        "swap_cost_3day": "3",
        "trade_timezone": "GMT+2",
        "trade_mode": "4",
        "icon_link": ""
      }
    ]
  },
  "timestamp": 1769426795464
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success ContractDetail
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Response data
»» list array Contract Details List
»»» None object Futures contract details
»»»» symbol string Trading symbol code
»»»» symbol_desc string Trading symbol description
»»»» category_name string Category name
»»»» contract_volume string Contract Volume
»»»» settlement_currency string Settle currency
»»»» max_order_volume string Maximum Order Volume
»»»» min_order_volume string Minimum Order Volume
»»»» leverage string Leverage multiplier
»»»» price_precision integer Price precision (decimal places)
»»»» price_sl_level string Stop Loss Price Level
»»»» swap_cost_type string Swap Cost Type
»»»» buy_swap_cost_rate string Buy Swap Cost Rate
»»»» sell_swap_cost_rate string Sell Swap Cost Rate
»»»» swap_cost_3day string 3-Day Swap Cost
»»»» trade_timezone string Trading Timezone
»»»» trade_mode string Trading mode code (0=disabled, 1=long only, 2=short only, 3=close only, 4=full trading access)
»»»» icon_link string Symbol icon URL

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

# Query trading symbol klines

Code samples

# coding: utf-8
import requests

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

url = '/tradfi/symbols/EURUSD/klines'
query_param = 'kline_type=1m'
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/tradfi/symbols/EURUSD/klines?kline_type=1m \
  -H 'Accept: application/json'

GET /tradfi/symbols/{symbol}/klines

Query trading symbol klines

Parameters

Name In Type Required Description
symbol path string true Trading symbol code
kline_type query string true Kline type (time period)
begin_time query integer(int64) false Start time (Unix timestamp in seconds)
end_time query integer(int64) false End time (Unix timestamp in seconds)
limit query integer false Kline limit (max 500, error if exceeded)

# Enumerated Values

Parameter Value
kline_type 1m
kline_type 15m
kline_type 1h
kline_type 4h
kline_type 1d
kline_type 7d
kline_type 30d

Example responses

200 Response

{
  "timestamp": 1769398039786,
  "data": {
    "list": [
      {
        "o": "1.17198",
        "c": "1.17213",
        "h": "1.17268",
        "l": "1.1718",
        "t": 1755896400
      },
      {
        "o": "1.17208",
        "c": "1.16092",
        "h": "1.17263",
        "l": "1.16023",
        "t": 1756069200
      }
    ]
  }
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success Klines
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Response data
»» list array Kline data list
»»» None object Single kline data
»»»» o string Open price
»»»» c string Close price
»»»» h string High price
»»»» l string Low price
»»»» t integer(int64) Timestamp (Unix seconds)

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

# Query trading symbol ticker

Code samples

# coding: utf-8
import requests

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

url = '/tradfi/symbols/EURUSD/tickers'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/tradfi/symbols/EURUSD/tickers \
  -H 'Accept: application/json'

GET /tradfi/symbols/{symbol}/tickers

Query trading symbol ticker

Parameters

Name In Type Required Description
symbol path string true Trading symbol code

Example responses

200 Response

{
  "data": {
    "highest_price": "5093.04",
    "lowest_price": "5003.61",
    "price_change": "1.32",
    "price_change_amount": "66.13",
    "today_open_price": "5008.06",
    "last_today_close_price": "4989.92",
    "last_price": "5074.19",
    "bid_price": "5073.83",
    "ask_price": "5074.06",
    "favorite": false,
    "status": "open",
    "close_time": 1769464800,
    "open_time": 1769378400,
    "next_open_time": 0,
    "trade_mode": "4",
    "category_name": "Metals"
  },
  "timestamp": 1769426795464
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success TradFiTicker
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

TradFiTicker

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Response data
»» highest_price string High price
»» lowest_price string Low price
»» price_change string Price change percentage (multiplied by 100)
»» price_change_amount string Price change amount
»» today_open_price string Today's open price
»» last_today_close_price string Previous close price
»» last_price string Last trading price
»» bid_price string Bid price
»» ask_price string Ask price
»» favorite boolean Is favorited
»» status string Trading status (open=tradable, closed=non-tradable)
»» close_time integer(int64) Close time (Unix timestamp in seconds)
»» open_time integer(int64) Open time (Unix timestamp in seconds)
»» next_open_time integer(int64) Next open time (0 means none)
»» trade_mode string Trading mode code
»» category_name string Category name

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

# Create CFD user

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 = '/tradfi/users'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('POST', 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="POST"
url="/tradfi/users"
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"

POST /tradfi/users

Create CFD user

Example responses

200 Response

{
  "data": {
    "leverage": 1,
    "status": 3,
    "mt5_uid": "1"
  },
  "timestamp": 1769398039786
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Account opened successfully CreateUserResp
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object none
»» status integer Status (1=not opened, 2=pending review, 3=opened)
»» leverage integer Leverage
»» mt5_uid string mt5uid

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Query account assets

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 = '/tradfi/users/assets'
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="/tradfi/users/assets"
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 /tradfi/users/assets

Query account assets

Query account assets

Example responses

200 Response

{
  "timestamp": 1769426795464,
  "data": {
    "equity": "0.00",
    "margin_level": "0.00",
    "balance": "0.00",
    "margin": "0.00",
    "margin_free": "0.00",
    "unrealized_pnl": "0.00",
    "mt5_uid": "10122"
  }
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success UserAssetResp
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Response data
»» equity string Account equity
»» margin_level string Margin level (percentage)
»» balance string Account Balance
»» margin string Used margin
»» margin_free string Available Margin
»» unrealized_pnl string Unrealized PNL
»» mt5_uid string MT5 userID

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Query Fund Transfer In/Out Records

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 = '/tradfi/transactions'
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="/tradfi/transactions"
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 /tradfi/transactions

Query Fund Transfer In/Out Records

Parameters

Name In Type Required Description
begin_time query integer(int64) false Start Time (Second-level Timestamp)
end_time query integer(int64) false End Time (Second-level Timestamp)
type query string false Transaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)
page query integer false page number
page_size query integer false Number per page, default 10, maximum 50

# Enumerated Values

Parameter Value
type deposit
type withdraw
type dividend
type fill_negative

Example responses

200 Response

{
  "data": {
    "total": 2,
    "total_page": 1,
    "list": [
      {
        "asset": "USDT",
        "type": "dividend",
        "type_desc": "Dividend Adjustment",
        "change": "1",
        "balance": "1",
        "time": 1769329389
      },
      {
        "asset": "USDT",
        "type": "fill_negative",
        "type_desc": "填補損失",
        "change": "0.5",
        "balance": "0.5",
        "time": 1769238545
      }
    ]
  },
  "timestamp": 1769332996590
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success TransactionList
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» data object none
»» total integer Total Records
»» total_page integer Total pages
»» list array Record List
»»» asset string Asset Type
»»» type string Trading Type
»»» type_desc string Transaction Type Description
»»» change string Change amount
»»» balance string Current Balance
»»» time integer(int64) Occurrence Time (Second-level Timestamp)
»» timestamp integer(int64) Server timestamp (milliseconds)

# Enumerated Values

Property Value
type deposit-转入
type withdraw-转出
type dividend-分红结息
type fill_negative-填平负余额

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Fund transfer

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 = '/tradfi/transactions'
query_param = ''
body='{"asset":"USDT","change":"10","type":"withdraw"}'
# 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="/tradfi/transactions"
query_param=""
body_param='{"asset":"USDT","change":"10","type":"withdraw"}'
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 /tradfi/transactions

Fund transfer

Body parameter

{
  "asset": "USDT",
  "change": "10",
  "type": "withdraw"
}

Parameters

Name In Type Required Description
body body TradFiTransactionRequest true none
» asset body string true Asset type, e.g., USDT, currently only USDT is supported
» change body string true Change Quantity, supports up to two decimal places
» type body string true Transaction Type (deposit - transfer in, withdraw - transfer out)

# Enumerated Values

Parameter Value
» type deposit
» type withdraw

Example responses

200 Response

{
  "data": {
    "total": 2,
    "total_page": 1,
    "list": [
      {
        "asset": "USDT",
        "type": "dividend",
        "type_desc": "Dividend Adjustment",
        "change": "1",
        "balance": "1",
        "time": 1769329389
      },
      {
        "asset": "USDT",
        "type": "fill_negative",
        "type_desc": "填補損失",
        "change": "0.5",
        "balance": "0.5",
        "time": 1769238545
      }
    ]
  },
  "timestamp": 1769332996590
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success CreateTransaction
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object none

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Query active order list

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 = '/tradfi/orders'
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="/tradfi/orders"
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 /tradfi/orders

Query active order list

Example responses

200 Response

{
  "data": {
    "list": [
      {
        "order_id": 2630591,
        "symbol": "USDCHF",
        "symbol_desc": "US Dollar vs Swiss Franc",
        "price_type": "trigger",
        "state": 1,
        "state_desc": "",
        "finished": 0,
        "side": 2,
        "volume": "1.6",
        "price": "5.000000",
        "price_tp": "5.200000",
        "price_sl": "4.800000",
        "time_setup": 1768741530
      },
      {
        "order_id": 2630590,
        "symbol": "USDCHF",
        "symbol_desc": "US Dollar vs Swiss Franc",
        "price_type": "trigger",
        "state": 1,
        "state_desc": "",
        "finished": 0,
        "side": 2,
        "volume": "1.6",
        "price": "5.000000",
        "price_tp": "5.100000",
        "price_sl": "4.900000",
        "time_setup": 1768741526
      }
    ],
    "timestamp": 1769426795464
  }
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success OrderList
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Response data
»» list array Order list
»»» None object Order detail
»»»» order_id integer Order ID
»»»» symbol string Currency pair
»»»» symbol_desc string Symbol description
»»»» price_type string Trade type (market=market price, trigger=trigger price)
»»»» state integer Order status code
»»»» state_desc string Order status description
»»»» finished integer Is completed (0=shown in active order list, 1=not shown in active list)
»»»» side integer Side (1=sell, 2=buy)
»»»» volume string Order quantity
»»»» price string Trigger price
»»»» price_tp string Take profit price
»»»» price_sl string Stop loss price
»»»» time_setup integer(int64) Order time (Unix timestamp in seconds)

# Enumerated Values

Property Value
price_type market
price_type trigger
finished 0
finished 1
side 1
side 2

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Create order

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 = '/tradfi/orders'
query_param = ''
body='{"price":"0.9","price_type":"trigger","side":2,"symbol":"EURUSD","volume":"10","price_tp":"1.5","price_sl":"0.8"}'
# 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="/tradfi/orders"
query_param=""
body_param='{"price":"0.9","price_type":"trigger","side":2,"symbol":"EURUSD","volume":"10","price_tp":"1.5","price_sl":"0.8"}'
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 /tradfi/orders

Create order

Body parameter

{
  "price": "0.9",
  "price_type": "trigger",
  "side": 2,
  "symbol": "EURUSD",
  "volume": "10",
  "price_tp": "1.5",
  "price_sl": "0.8"
}

Parameters

Name In Type Required Description
body body TradFiOrderRequest true none
» price body string true Order price
» price_type body string true Price type (trigger=trigger price, market=market price)
» side body integer true Side (1=sell, 2=buy)
» symbol body string true Trading symbol code
» volume body string true Order quantity
» price_tp body string false Take profit price (optional)
» price_sl body string false Stop loss price (optional)

# Enumerated Values

Parameter Value
» price_type trigger
» price_type market
» side 1
» side 2

Example responses

200 Response

{
  "data": {
    "id": "117"
  },
  "timestamp": 1769426795464
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Order placed successfully CreateOrder
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Order result
»» id string Queue Task ID (not task ID)

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Modify order

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 = '/tradfi/orders/1223'
query_param = ''
body='{"price":"2","price_tp":"1.5","price_sl":"0.8"}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('PUT', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('PUT', 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="PUT"
url="/tradfi/orders/1223"
query_param=""
body_param='{"price":"2","price_tp":"1.5","price_sl":"0.8"}'
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"

PUT /tradfi/orders/{order_id}

Modify order

Body parameter

{
  "price": "2",
  "price_tp": "1.5",
  "price_sl": "0.8"
}

Parameters

Name In Type Required Description
body body TradFiOrderUpdateRequest true none
» price body string true Price
Description:
- Required
» price_tp body string|null false Take Profit Price
Description:
- If not provided or set to "0": The original take profit price will be cleared
- If you do not want to clear it, pass the original take profit price returned by the interface
» price_sl body string|null false Stop Loss Price
Description:
- If not provided or set to "0": The original stop loss price will be cleared
- If you do not want to clear it, pass the original stop loss price returned by the interface
order_id path integer true Order ID

# Detailed descriptions

» price: Price
Description:
- Required

» price_tp: Take Profit Price
Description:
- If not provided or set to "0": The original take profit price will be cleared
- If you do not want to clear it, pass the original take profit price returned by the interface

» price_sl: Stop Loss Price
Description:
- If not provided or set to "0": The original stop loss price will be cleared
- If you do not want to clear it, pass the original stop loss price returned by the interface

Example responses

200 Response

{
  "data": {
    "order_id": 2651172,
    "symbol": "AUDUSD",
    "state": "1",
    "volume": "1",
    "price": "2.00000",
    "price_tp": "1.50000",
    "price_sl": "0.80000"
  },
  "timestamp": 1769956396273
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success UpdateOrder
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Order modification result

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Response data
»» order_id integer Order ID
»» symbol string Currency pair
»» state string Order status code
»» volume string Order quantity
»» price string Current price
»» price_tp string Current take profit price
»» price_sl string Current stop loss price

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Cancel order

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 = '/tradfi/orders/1223'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('DELETE', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('DELETE', 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="DELETE"
url="/tradfi/orders/1223"
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"

DELETE /tradfi/orders/{order_id}

Cancel order

Parameters

Name In Type Required Description
order_id path integer true Order ID

Example responses

200 Response

{}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Deleted successfully Inline
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Returns empty object on success

Name Type Description

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Query historical order list

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 = '/tradfi/orders/history'
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="/tradfi/orders/history"
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 /tradfi/orders/history

Query historical order list

Parameters

Name In Type Required Description
begin_time query integer(int64) false Start time (Unix timestamp in seconds), earliest query is one month ago
end_time query integer(int64) false End time (Unix timestamp in seconds)
symbol query string false Currency pair
side query integer false Side (1=sell, 2=buy)

# Enumerated Values

Parameter Value
side 1
side 2

Example responses

200 Response

{
  "data": {
    "list": [
      {
        "order_id": 2648991,
        "symbol": "USDCAD",
        "symbol_desc": "USD VS CAD;",
        "price_type": "market",
        "order_opt_type": 4,
        "state": 4,
        "state_desc": "Filled",
        "side": 2,
        "volume": "0.05",
        "fill_volume": "0.05",
        "close_pnl": "-1.49755",
        "price": "1.3689",
        "trigger_price": "1.3689",
        "price_tp": "0",
        "price_sl": "0",
        "time_setup": 1769397512,
        "time_done": 1769397512
      }
    ]
  }
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success OrderHistoryList
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Response data
»» list array Historical order list
»»» None object Order detail
»»»» order_id integer Order ID
»»»» symbol string Currency pair
»»»» symbol_desc string Symbol description
»»»» price_type string Trade type (market=market price, trigger=trigger price)
»»»» order_opt_type integer Order operation type (1=sell, 2=buy, 3=close long, 4=close short, 5=force close long, 6=force close short)
»»»» state integer Order status code
»»»» state_desc string Order status description
»»»» side integer Side (1=sell, 2=buy)
»»»» volume string Order quantity
»»»» fill_volume string Trading size
»»»» close_pnl string Close Position P&L
»»»» price string Average fill price
»»»» trigger_price string Trigger price
»»»» price_tp string Take profit price
»»»» price_sl string Stop loss price
»»»» time_setup integer(int64) Order time (Unix timestamp in seconds)
»»»» time_done integer(int64) End time (Unix timestamp in seconds)

# Enumerated Values

Property Value
price_type market
price_type trigger
order_opt_type 1
order_opt_type 2
order_opt_type 3
order_opt_type 4
order_opt_type 5
order_opt_type 6
side 1
side 2

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Get order details by log ID

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 = '/tradfi/orders/log/1223'
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="/tradfi/orders/log/1223"
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 /tradfi/orders/log/{log_id}

Get order details by log ID

Parameters

Name In Type Required Description
log_id path integer true log_id returned from the order placement API

Example responses

200 Response

{
  "timestamp": 1715769600000,
  "data": {
    "order_id": 13950884,
    "log_id": 1214290,
    "symbol": "AUDUSD",
    "price_type": "market",
    "state": 4,
    "side": 2,
    "volume": "0.01",
    "price": "0.72221"
  }
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success OrderLog
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Response data
»» order_id integer Order ID
»» log_id integer logID
»» symbol string Trading pair of the order
»» price_type string Trade type (market=market price, trigger=trigger price)
»» state integer Order status code (1=placed, 2=canceled, 3=partially filled, 4=filled, 5=rejected)
»» side integer Side (1=sell, 2=buy)
»» volume string Order quantity
»» price string Average fill price

# Enumerated Values

Property Value
price_type market
price_type trigger
side 1
side 2

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Query active position list

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 = '/tradfi/positions'
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="/tradfi/positions"
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 /tradfi/positions

Query active position list

Example responses

200 Response

{
  "data": {
    "list": [
      {
        "position_id": 2648925,
        "margin": "2.354440320000000142",
        "symbol": "EURUSD",
        "symbol_desc": "Euro vs United States Dollar",
        "unrealized_pnl": "8.06969999999992903440215741284191608428955078125",
        "unrealized_pnl_rate": "0.0068548775107622",
        "volume": "0.01",
        "price_open": "1.177220",
        "position_dir": "Long",
        "price_tp": "0.000000",
        "price_sl": "0.000000",
        "counterparty_price": "1.1851598599999999539278405791264958679676055908203125",
        "time_create": 1769319320
      }
    ],
    "timestamp": 1769426795464
  }
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success PositionList
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Response data
»» list array Position information
»»» None object Position information
»»»» position_id integer Position ID
»»»» symbol string Trading market code
»»»» symbol_desc string Market description
»»»» margin string Used margin
»»»» unrealized_pnl string Unrealized PNL
»»»» unrealized_pnl_rate string Unrealized return rate
»»»» volume string Position size
»»»» price_open string Average Opening Price
»»»» position_dir string Position direction (Long=long position, Short=short position)

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Modify position

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 = '/tradfi/positions/1223'
query_param = ''
body='{"price_tp":"1","price_sl":"1"}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('PUT', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('PUT', 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="PUT"
url="/tradfi/positions/1223"
query_param=""
body_param='{"price_tp":"1","price_sl":"1"}'
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"

PUT /tradfi/positions/{position_id}

Modify position

Body parameter

{
  "price_tp": "1",
  "price_sl": "1"
}

Parameters

Name In Type Required Description
position_id path integer true Position ID
body body TradFiPositionUpdateRequest true none
» price_tp body string|null false Take Profit Price
Description:
- If not provided or set to "0": The original take profit price will be cleared
- If you do not want to clear it, pass the original take profit price returned by the interface
» price_sl body string|null false Stop Loss Price
Description:
- If not provided or set to "0": The original stop loss price will be cleared
- If you do not want to clear it, pass the original stop loss price returned by the interface

# Detailed descriptions

» price_tp: Take Profit Price
Description:
- If not provided or set to "0": The original take profit price will be cleared
- If you do not want to clear it, pass the original take profit price returned by the interface

» price_sl: Stop Loss Price
Description:
- If not provided or set to "0": The original stop loss price will be cleared
- If you do not want to clear it, pass the original stop loss price returned by the interface

Example responses

200 Response

{
  "timestamp": 0,
  "data": {}
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success UpdatePosition
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object none

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Close position

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 = '/tradfi/positions/1223/close'
query_param = ''
body='{"close_type":1,"close_volume":"1"}'
# 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="/tradfi/positions/1223/close"
query_param=""
body_param='{"close_type":1,"close_volume":"1"}'
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 /tradfi/positions/{position_id}/close

Close position

Body parameter

{
  "close_type": 1,
  "close_volume": "1"
}

Parameters

Name In Type Required Description
position_id path integer true Position ID
body body TradFiClosePositionRequest true none
» close_type body integer true Close Type
Description:
- 1: Partial Close (close_volume is required)
- 2: Full Close (close_volume is not required)
» close_volume body string|null false Close Volume
Description:
- Required when close_type = 1
- Ignored when close_type = 2

# Detailed descriptions

» close_type: Close Type
Description:
- 1: Partial Close (close_volume is required)
- 2: Full Close (close_volume is not required)

» close_volume: Close Volume
Description:
- Required when close_type = 1
- Ignored when close_type = 2

# Enumerated Values

Parameter Value
» close_type 1
» close_type 2

Example responses

200 Response

{
  "timestamp": 0,
  "data": {}
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success DeletePosition
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object none

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Query historical position list

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 = '/tradfi/positions/history'
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="/tradfi/positions/history"
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 /tradfi/positions/history

Query historical position list

Parameters

Name In Type Required Description
page query integer(int64) false Page number; defaults to 1 if omitted.
page_size query integer(int64) false Page size; defaults to 10 if omitted. Maximum 100.
begin_time query integer(int64) false Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago
end_time query integer(int64) false End time (timestamp in seconds)
symbol query string false Trading symbol (e.g., EURUSD)
position_dir query string false Position direction (Long=long position, Short=short position)

# Enumerated Values

Parameter Value
position_dir Long
position_dir Short

Example responses

200 Response

{
  "data": {
    "total": 1,
    "total_page": 1,
    "list": [
      {
        "position_id": 2648854,
        "symbol": "EURUSD",
        "realized_pnl": "-2.4",
        "realized_pnl_rate": "-0.0339783598282142",
        "volume": "0.3",
        "volume_closed": "0.3",
        "price_open": "1.17722016",
        "position_dir": "Long",
        "price_tp": "0",
        "price_sl": "0",
        "counterparty_price": "",
        "close_price": "1.1772198600000001",
        "time_close": "1769223573",
        "time_create": "1769223566",
        "position_status": "1",
        "realized_pnl_detail": {
          "closed_pnl": "0",
          "swap": "0",
          "fee": "-2.4"
        },
        "close_detail": null
      },
      {
        "position_id": 2648850,
        "symbol": "EURUSD",
        "realized_pnl": "-1.6",
        "realized_pnl_rate": "-0.0339783598282142",
        "volume": "0.2",
        "volume_closed": "0.2",
        "price_open": "1.17722016",
        "position_dir": "Long",
        "price_tp": "0",
        "price_sl": "0",
        "counterparty_price": "",
        "close_price": "1.1772198600000001",
        "time_close": "1769223391",
        "time_create": "1769223287",
        "position_status": "1",
        "realized_pnl_detail": {
          "closed_pnl": "0",
          "swap": "0",
          "fee": "-1.6"
        },
        "close_detail": null
      }
    ]
  }
}

400 Response

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "data": null,
  "timestamp": 1769835481814
}

Responses

Status Meaning Description Schema
200 OK (opens new window) Request success PositionHistoryList
400 Bad Request (opens new window) Request failed TradFiError

Response Schema

Status Code 200

Name Type Description
» timestamp integer(int64) Server timestamp (milliseconds)
» data object Response data
»» total integer Total amount
»» total_page integer Total pages
»» list array Query historical position list
»»» None object Position close history
»»»» position_id integer(int64) Position ID
»»»» symbol string Market / Trading symbol
»»»» realized_pnl string Realized PnL
»»»» realized_pnl_rate string Realized return rate
»»»» volume string Position size / Maximum position size
»»»» volume_closed string Close volume
»»»» price_open string Average Opening Price
»»»» position_dir string Position Direction
- Long: Long Position
- Short: Short Position
»»»» price_tp string Take profit price
»»»» price_sl string Stop loss price
»»»» counterparty_price string Counterparty price
»»»» close_price string Close price
»»»» time_create string Open time (timestamp in seconds)
»»»» time_close string Close time (timestamp in seconds)
»»»» position_status string Position Status
- 1: Fully Closed
- 2: Forced Liquidation
»»»» close_detail object|null Liquidation details (null for normal close)
»»»»» margin_level string Margin ratio (multiplied by 100)
»»»»» margin string Margin
»»»»» equity string Net equity
»»»»» stop_out_level string Liquidation ratio (multiplied by 100)
»»»» realized_pnl_detail object Realized P&L details
»»»»» closed_pnl string Close Position P&L
»»»»» swap string Swap fee
»»»»» fee string fee

# Enumerated Values

Property Value
position_dir Long
position_dir Short

Status Code 400

TradFiError

Name Type Description
» label string Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
» message string Return message, returned when request error occurs
» timestamp integer(int64) Server timestamp (milliseconds)

WARNING

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

# Schemas

# Klines

{
  "timestamp": 0,
  "data": {
    "list": [
      {}
    ]
  }
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Response data
» list array false none Kline data list
»» None object false none Single kline data
»»» o string false none Open price
»»» c string false none Close price
»»» h string false none High price
»»» l string false none Low price
»»» t integer(int64) false none Timestamp (Unix seconds)

# UserAssetResp

{
  "timestamp": 0,
  "data": {
    "equity": "0.00",
    "margin_level": "0.00",
    "balance": "0.00",
    "margin": "0.00",
    "margin_free": "0.00",
    "unrealized_pnl": "0.00",
    "mt5_uid": "10122"
  }
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Response data
» equity string false none Account equity
» margin_level string false none Margin level (percentage)
» balance string false none Account Balance
» margin string false none Used margin
» margin_free string false none Available Margin
» unrealized_pnl string false none Unrealized PNL
» mt5_uid string false none MT5 userID

# TradFiError

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "timestamp": 0
}

TradFiError

# Properties

Name Type Required Restrictions Description
label string false none Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false none Return message, returned when request error occurs
timestamp integer(int64) false none Server timestamp (milliseconds)

# TradFiOrderUpdateRequest

{
  "price": "2",
  "price_tp": "1.5",
  "price_sl": "0.8"
}

Modify order price and take profit/stop loss parameters

# Properties

Name Type Required Restrictions Description
price string true none Price
Description:
- Required
price_tp string|null false none Take Profit Price
Description:
- If not provided or set to "0": The original take profit price will be cleared
- If you do not want to clear it, pass the original take profit price returned by the interface
price_sl string|null false none Stop Loss Price
Description:
- If not provided or set to "0": The original stop loss price will be cleared
- If you do not want to clear it, pass the original stop loss price returned by the interface

# DeletePosition

{
  "timestamp": 0,
  "data": {}
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none none

# TradFiClosePositionRequest

{
  "close_type": 1,
  "close_volume": "1"
}

Close position request parameters

# Properties

Name Type Required Restrictions Description
close_type integer true none Close Type
Description:
- 1: Partial Close (close_volume is required)
- 2: Full Close (close_volume is not required)
close_volume string|null false none Close Volume
Description:
- Required when close_type = 1
- Ignored when close_type = 2

# Enumerated Values

Property Value
close_type 1
close_type 2

# OrderHistoryList

{
  "timestamp": 0,
  "data": {
    "list": [
      {}
    ]
  }
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Response data
» list array false none Historical order list
»» None object false none Order detail
»»» order_id integer false none Order ID
»»» symbol string false none Currency pair
»»» symbol_desc string false none Symbol description
»»» price_type string false none Trade type (market=market price, trigger=trigger price)
»»» order_opt_type integer false none Order operation type (1=sell, 2=buy, 3=close long, 4=close short, 5=force close long, 6=force close short)
»»» state integer false none Order status code
»»» state_desc string false none Order status description
»»» side integer false none Side (1=sell, 2=buy)
»»» volume string false none Order quantity
»»» fill_volume string false none Trading size
»»» close_pnl string false none Close Position P&L
»»» price string false none Average fill price
»»» trigger_price string false none Trigger price
»»» price_tp string false none Take profit price
»»» price_sl string false none Stop loss price
»»» time_setup integer(int64) false none Order time (Unix timestamp in seconds)
»»» time_done integer(int64) false none End time (Unix timestamp in seconds)

# Enumerated Values

Property Value
price_type market
price_type trigger
order_opt_type 1
order_opt_type 2
order_opt_type 3
order_opt_type 4
order_opt_type 5
order_opt_type 6
side 1
side 2

# ContractDetail

{
  "timestamp": 0,
  "data": {
    "list": [
      {}
    ]
  }
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Response data
» list array false none Contract Details List
»» None object false none Futures contract details
»»» symbol string false none Trading symbol code
»»» symbol_desc string false none Trading symbol description
»»» category_name string false none Category name
»»» contract_volume string false none Contract Volume
»»» settlement_currency string false none Settle currency
»»» max_order_volume string false none Maximum Order Volume
»»» min_order_volume string false none Minimum Order Volume
»»» leverage string false none Leverage multiplier
»»» price_precision integer false none Price precision (decimal places)
»»» price_sl_level string false none Stop Loss Price Level
»»» swap_cost_type string false none Swap Cost Type
»»» buy_swap_cost_rate string false none Buy Swap Cost Rate
»»» sell_swap_cost_rate string false none Sell Swap Cost Rate
»»» swap_cost_3day string false none 3-Day Swap Cost
»»» trade_timezone string false none Trading Timezone
»»» trade_mode string false none Trading mode code (0=disabled, 1=long only, 2=short only, 3=close only, 4=full trading access)
»»» icon_link string false none Symbol icon URL

# PositionList

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "timestamp": 0,
  "data": {
    "list": [
      {}
    ]
  }
}

# Properties

Name Type Required Restrictions Description
label string false none Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false none Return message, returned when request error occurs
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Response data
» list array false none Position information
»» None object false none Position information
»»» position_id integer false none Position ID
»»» symbol string false none Trading market code
»»» symbol_desc string false none Market description
»»» margin string false none Used margin
»»» unrealized_pnl string false none Unrealized PNL
»»» unrealized_pnl_rate string false none Unrealized return rate
»»» volume string false none Position size
»»» price_open string false none Average Opening Price
»»» position_dir string false none Position direction (Long=long position, Short=short position)

# CreateTransaction

{
  "timestamp": 0,
  "data": {}
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none none

# TradFiOrderRequest

{
  "price": "0.9",
  "price_type": "trigger",
  "side": 2,
  "symbol": "EURUSD",
  "volume": "10",
  "price_tp": "1.5",
  "price_sl": "0.8"
}

Place order request parameters

# Properties

Name Type Required Restrictions Description
price string true none Order price
price_type string true none Price type (trigger=trigger price, market=market price)
side integer true none Side (1=sell, 2=buy)
symbol string true none Trading symbol code
volume string true none Order quantity
price_tp string false none Take profit price (optional)
price_sl string false none Stop loss price (optional)

# Enumerated Values

Property Value
price_type trigger
price_type market
side 1
side 2

# CreateUserResp

{
  "timestamp": 0,
  "data": {
    "status": 0,
    "leverage": 0,
    "mt5_uid": "string"
  }
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none none
» status integer false none Status (1=not opened, 2=pending review, 3=opened)
» leverage integer false none Leverage
» mt5_uid string false none mt5uid

# TradFiTransactionRequest

{
  "asset": "USDT",
  "change": "10",
  "type": "withdraw"
}

Fund Transfer Request Body

# Properties

Name Type Required Restrictions Description
asset string true none Asset type, e.g., USDT, currently only USDT is supported
change string true none Change Quantity, supports up to two decimal places
type string true none Transaction Type (deposit - transfer in, withdraw - transfer out)

# Enumerated Values

Property Value
type deposit
type withdraw

# OrderLog

{
  "timestamp": 0,
  "data": {
    "order_id": 2648991,
    "log_id": 87699,
    "symbol": "USDCAD",
    "price_type": "market",
    "state": 4,
    "side": 2,
    "volume": "0.05",
    "price": "1.3689"
  }
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Response data
» order_id integer false none Order ID
» log_id integer false none logID
» symbol string false none Trading pair of the order
» price_type string false none Trade type (market=market price, trigger=trigger price)
» state integer false none Order status code (1=placed, 2=canceled, 3=partially filled, 4=filled, 5=rejected)
» side integer false none Side (1=sell, 2=buy)
» volume string false none Order quantity
» price string false none Average fill price

# Enumerated Values

Property Value
price_type market
price_type trigger
side 1
side 2

# Categories

{
  "timestamp": 0,
  "data": {
    "list": [
      {}
    ]
  }
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Data
» list array false none none
»» None object false none Category information
»»» category_id integer false none Category ID
»»» is_favorite boolean false none Whether it is a custom category, generally no need to pay attention
»»» category_name string false none Category name

# TradFiPositionUpdateRequest

{
  "price_tp": "1",
  "price_sl": "1"
}

Modify position take profit/stop loss parameters

# Properties

Name Type Required Restrictions Description
price_tp string|null false none Take Profit Price
Description:
- If not provided or set to "0": The original take profit price will be cleared
- If you do not want to clear it, pass the original take profit price returned by the interface
price_sl string|null false none Stop Loss Price
Description:
- If not provided or set to "0": The original stop loss price will be cleared
- If you do not want to clear it, pass the original stop loss price returned by the interface

# CreateOrder

{
  "timestamp": 0,
  "data": {
    "id": "117"
  }
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Order result
» id string false none Queue Task ID (not task ID)

# TransactionList

{
  "data": {
    "total": 2,
    "total_page": 1,
    "list": [
      {}
    ]
  },
  "timestamp": 1769332996590
}

# Properties

Name Type Required Restrictions Description
data object false none none
» total integer false none Total Records
» total_page integer false none Total pages
» list array false none Record List
»» asset string false none Asset Type
»» type string false none Trading Type
»» type_desc string false none Transaction Type Description
»» change string false none Change amount
»» balance string false none Current Balance
»» time integer(int64) false none Occurrence Time (Second-level Timestamp)
» timestamp integer(int64) false none Server timestamp (milliseconds)

# Enumerated Values

Property Value
type deposit-转入
type withdraw-转出
type dividend-分红结息
type fill_negative-填平负余额

# Symbols

{
  "timestamp": 0,
  "data": {
    "list": [
      {}
    ]
  }
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Response data
» list array false none Trading symbol list
»» None object false none Trading symbol information
»»» symbol string false none Trading symbol code
»»» symbol_desc string false none Trading symbol description
»»» category_id integer false none Category ID
»»» status string false none Trading status (open=tradable, closed=non-tradable)
»»» trade_mode string false none Trading mode code (0=disabled, 1=long only, 2=short only, 3=close only, 4=full trading access)
»»» icon_link string false none Symbol icon URL
»»» close_time integer(int64) false none Close time (Unix timestamp in seconds)
»»» open_time integer(int64) false none Open time (Unix timestamp in seconds)
»»» next_open_time integer(int64) false none Next open time (Unix timestamp in seconds, 0 means none)
»»» settlement_currency string false none Settlement currency
»»» settlement_currency_symbol string false none Settlement currency symbol
»»» price_precision integer false none Price precision (decimal places)

# SymbolCommissions

{
  "timestamp": 0,
  "data": {
    "list": [
      {}
    ]
  }
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Response data
» list array false none List of symbol commission rates
»» None object false none Symbol commission rate
»»» category_code string false none Category code
»»» symbol string false none Trading symbol code
»»» fee_per_lot string false none Commission rate per lot

# UpdatePosition

{
  "timestamp": 0,
  "data": {}
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none none

# PositionHistoryList

{
  "timestamp": 0,
  "data": {
    "total": 0,
    "total_page": 0,
    "list": [
      {}
    ]
  }
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Response data
» total integer false none Total amount
» total_page integer false none Total pages
» list array false none Query historical position list
»» None object false none Position close history
»»» position_id integer(int64) true none Position ID
»»» symbol string true none Market / Trading symbol
»»» realized_pnl string true none Realized PnL
»»» realized_pnl_rate string false none Realized return rate
»»» volume string true none Position size / Maximum position size
»»» volume_closed string true none Close volume
»»» price_open string true none Average Opening Price
»»» position_dir string true none Position Direction
- Long: Long Position
- Short: Short Position
»»» price_tp string false none Take profit price
»»» price_sl string false none Stop loss price
»»» counterparty_price string false none Counterparty price
»»» close_price string true none Close price
»»» time_create string true none Open time (timestamp in seconds)
»»» time_close string true none Close time (timestamp in seconds)
»»» position_status string true none Position Status
- 1: Fully Closed
- 2: Forced Liquidation
»»» close_detail object|null false none Liquidation details (null for normal close)
»»»» margin_level string false none Margin ratio (multiplied by 100)
»»»» margin string false none Margin
»»»» equity string false none Net equity
»»»» stop_out_level string false none Liquidation ratio (multiplied by 100)
»»» realized_pnl_detail object true none Realized P&L details
»»»» closed_pnl string false none Close Position P&L
»»»» swap string false none Swap fee
»»»» fee string false none fee

# Enumerated Values

Property Value
position_dir Long
position_dir Short

# TradFiTicker

{
  "label": "INVALID_ARGUMENT",
  "message": "无效参数",
  "timestamp": 0,
  "data": {
    "highest_price": "5093.04",
    "lowest_price": "5003.61",
    "price_change": "1.32",
    "price_change_amount": "66.13",
    "today_open_price": "5008.06",
    "last_today_close_price": "4989.92",
    "last_price": "5074.19",
    "bid_price": "5073.83",
    "ask_price": "5074.06",
    "favorite": false,
    "status": "open",
    "close_time": 1769464800,
    "open_time": 1769378400,
    "next_open_time": 0,
    "trade_mode": "4",
    "category_name": "Metals"
  }
}

TradFiTicker

# Properties

Name Type Required Restrictions Description
label string false none Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false none Return message, returned when request error occurs
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Response data
» highest_price string false none High price
» lowest_price string false none Low price
» price_change string false none Price change percentage (multiplied by 100)
» price_change_amount string false none Price change amount
» today_open_price string false none Today's open price
» last_today_close_price string false none Previous close price
» last_price string false none Last trading price
» bid_price string false none Bid price
» ask_price string false none Ask price
» favorite boolean false none Is favorited
» status string false none Trading status (open=tradable, closed=non-tradable)
» close_time integer(int64) false none Close time (Unix timestamp in seconds)
» open_time integer(int64) false none Open time (Unix timestamp in seconds)
» next_open_time integer(int64) false none Next open time (0 means none)
» trade_mode string false none Trading mode code
» category_name string false none Category name

# Mt5Account

{
  "code": 0,
  "message": "ok",
  "timestamp": 0,
  "data": {
    "mt5_uid": 0,
    "leverage": 100,
    "stop_out_level": "50%",
    "status": 1
  }
}

# Properties

Name Type Required Restrictions Description
code integer false none Business Status Code; Non-zero Indicates Business Exception, Please Check Message
message string false none Response message
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Response data
» mt5_uid integer false none MT5 userID
» leverage integer false none Leverage multiplier
» stop_out_level string false none Liquidation margin ratio
» status integer false none Account status (1=not opened, 2=pending review, 3=active)

# UpdateOrder

{
  "timestamp": 0,
  "data": {
    "order_id": 2630591,
    "symbol": "USDCHF",
    "state": 1,
    "volume": "1.6",
    "price": "5.000000",
    "price_tp": "5.200000",
    "price_sl": "4.800000"
  }
}

Order modification result

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Response data
» order_id integer false none Order ID
» symbol string false none Currency pair
» state string false none Order status code
» volume string false none Order quantity
» price string false none Current price
» price_tp string false none Current take profit price
» price_sl string false none Current stop loss price

# OrderList

{
  "timestamp": 0,
  "data": {
    "list": [
      {}
    ]
  }
}

# Properties

Name Type Required Restrictions Description
timestamp integer(int64) false none Server timestamp (milliseconds)
data object false none Response data
» list array false none Order list
»» None object false none Order detail
»»» order_id integer false none Order ID
»»» symbol string false none Currency pair
»»» symbol_desc string false none Symbol description
»»» price_type string false none Trade type (market=market price, trigger=trigger price)
»»» state integer false none Order status code
»»» state_desc string false none Order status description
»»» finished integer false none Is completed (0=shown in active order list, 1=not shown in active list)
»»» side integer false none Side (1=sell, 2=buy)
»»» volume string false none Order quantity
»»» price string false none Trigger price
»»» price_tp string false none Take profit price
»»» price_sl string false none Stop loss price
»»» time_setup integer(int64) false none Order time (Unix timestamp in seconds)

# Enumerated Values

Property Value
price_type market
price_type trigger
finished 0
finished 1
side 1
side 2