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.

  • REST API BaseURL for live trading: https://api.gateio.ws/api/v4/
  • Help Center (opens new window)
  • CFD Trading (opens new window)
  • Before using this business API, make sure the user has enabled CFD business. You can call the create CFD user endpoint or log in to the app to enable it
  • For lead trading via APIv4, add the request header x-gate-trader-copy-type: cfd_copy. This does not apply to CFD user activation or fund transfer endpoints.

# 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": {
    "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

Type Constraints
Mt5Account

Properties

Name Type Required Constraints Description
code integer false Business Status Code; Non-zero Indicates Business Exception, Please Check Message
message string false Response message
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
leverage integer false Leverage multiplier
stop_out_level string false Liquidation margin ratio
status integer false Account status (1=not opened, 2=pending review, 3=active)

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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

Type Constraints
Categories

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Data

data

Data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false

data / list

Type Constraints
array

data / list / items

Category information

Type Constraints
object

Properties

Name Type Required Constraints Description
category_id integer false Category ID
is_favorite boolean false Whether it is a custom category, generally no need to pay attention
category_name string false Category name

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

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

# Query symbol commission rates

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/symbols/commissions'
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/symbols/commissions"
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/symbols/commissions

Query symbol commission rates

Parameters

Name In Type Required Description
symbols query string false Comma-separated instrument symbols. Provide at least one of symbols and category_code.
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

Type Constraints
SymbolCommissions

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false List of symbol commission rates

data / list

List of symbol commission rates

Type Constraints
array

data / list / items

Symbol commission rate

Type Constraints
object

Properties

Name Type Required Constraints Description
category_code string false Category code
symbol string false Trading symbol code
fee_per_lot string false Commission rate per lot

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

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

WARNING

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

# 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

Type Constraints
Symbols

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false Trading symbol list

data / list

Trading symbol list

Type Constraints
array

data / list / items

Trading symbol information

Type Constraints
object

Properties

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

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

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

# Query trading symbol 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 = '/tradfi/symbols/detail'
query_param = 'symbols=EURUSD,XAGUSD'
# 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="/tradfi/symbols/detail"
query_param="symbols=EURUSD,XAGUSD"
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 /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

Type Constraints
ContractDetail

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false Contract Details List

data / list

Contract Details List

Type Constraints
array

data / list / items

Futures contract details

Type Constraints
object

Properties

Name Type Required Constraints Description
symbol string false Trading symbol code
symbol_desc string false Trading symbol description
category_name string false Category name
contract_volume string false Contract Volume
settlement_currency string false Settle currency
max_order_volume string false Maximum Order Volume
min_order_volume string false Minimum Order Volume
leverage string false Leverage multiplier
price_precision integer false Price precision (decimal places)
price_sl_level string false Stop Loss Price Level
swap_cost_type string false Swap Cost Type
buy_swap_cost_rate string false Buy Swap Cost Rate
sell_swap_cost_rate string false Sell Swap Cost Rate
swap_cost_3day string false 3-Day Swap Cost
trade_timezone string false Trading Timezone
trade_mode string false Trading mode code (0=disabled, 1=long only, 2=short only, 3=close only, 4=full trading access)
icon_link string false Symbol icon URL

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

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

WARNING

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

# 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

Type Constraints
Klines

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false Kline data list

data / list

Kline data list

Type Constraints
array

data / list / items

Single kline data

Type Constraints
object

Properties

Name Type Required Constraints Description
o string false Open price
c string false Close price
h string false High price
l string false Low price
t integer(int64) false Timestamp (Unix seconds)

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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

Ticker summary information

Type Constraints
TradFiTicker

Properties

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

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
highest_price string false High price
lowest_price string false Low price
price_change string false Price change percentage (multiplied by 100)
price_change_amount string false Price change amount
today_open_price string false Today's open price
last_today_close_price string false Previous close price
last_price string false Last trading price
bid_price string false Bid price
ask_price string false Ask price
favorite boolean false Is favorited
status string false Trading status (open=tradable, closed=non-tradable)
close_time integer(int64) false Close time (Unix timestamp in seconds)
open_time integer(int64) false Open time (Unix timestamp in seconds)
next_open_time integer(int64) false Next open time (0 means none)
trade_mode string false Trading mode code
category_name string false Category name

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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
  },
  "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

Type Constraints
CreateUserResp

Properties

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

data

Type Constraints
object

Properties

Name Type Required Constraints Description
status integer false Status (1=not opened, 2=pending review, 3=opened)
leverage integer false Leverage

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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"
  }
}

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

Type Constraints
UserAssetResp

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
equity string false Account equity
margin_level string false Margin level (percentage)
balance string false Account Balance
margin string false Used margin
margin_free string false Available Margin
unrealized_pnl string false Unrealized PNL

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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

Type Constraints
TransactionList

Properties

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

data

Type Constraints
object

Properties

Name Type Required Constraints Description
total integer false Total Records
total_page integer false Total pages
list array false Record List

data / list

Record List

Type Constraints
array

data / list / items

Type Constraints
object

Properties

Name Type Required Constraints Description
asset string false Asset Type
type string false enum: ["deposit-转入","withdraw-转出","dividend-分红结息","fill_negative-填平负余额"] Trading Type
type_desc string false Transaction Type Description
change string false Change amount
balance string false Current Balance
time integer(int64) false Occurrence Time (Second-level Timestamp)

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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

# Request Body Schema

Fund Transfer Request Body

Type Constraints
TradFiTransactionRequest required: ["asset","change","type"]

Properties

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

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

Type Constraints
CreateTransaction

Properties

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

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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

Type Constraints
OrderList

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false Order list

data / list

Order list

Type Constraints
array

data / list / items

Order detail

Type Constraints
object

Properties

Name Type Required Constraints Description
order_id integer(int64) false Order ID
symbol string false Currency pair
symbol_desc string false Symbol description
price_type string false enum: ["market","trigger"] Trade type (market=market price, trigger=trigger price)
state integer false Order status code
state_desc string false Order status description
finished integer false enum: [0,1] Is completed (0=shown in active order list, 1=not shown in active list)
side integer false enum: [1,2] Side (1=sell, 2=buy)
volume string false Order quantity
price string false Trigger price
price_tp string false Take profit price
price_sl string false Stop loss price
time_setup integer(int64) false Order time (Unix timestamp in seconds)

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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","leverage":500}'
# 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","leverage":500}'
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",
  "leverage": 500
}

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 Base 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)
leverage body integer false Leverage multiplier (must be one of the leverage multipliers allowed for the symbol in the trading symbol details response)

# Enumerated Values

Parameter Value
price_type trigger
price_type market
side 1
side 2

# Request Body Schema

Place order request parameters

Type Constraints
TradFiOrderRequest required: ["price","price_type","side","symbol","volume"]

Properties

Name Type Required Constraints Description
price string true Order price
price_type string true enum: ["trigger","market"] Price type (trigger=trigger price, market=market price)
side integer true enum: [1,2] Side (1=sell, 2=buy)
symbol string true Base trading symbol code
volume string true Order quantity
price_tp string false Take profit price (optional)
price_sl string false Stop loss price (optional)
leverage integer false Leverage multiplier (must be one of the leverage multipliers allowed for the symbol in the trading symbol details response)

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

Type Constraints
CreateOrder

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Order result

data

Order result

Type Constraints
object

Properties

Name Type Required Constraints Description
id string false Queue Task ID (not order ID)

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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(int64) 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

# Request Body Schema

Modify order price and take profit/stop loss parameters

Type Constraints
TradFiOrderUpdateRequest required: ["price"]

Properties

Name Type Required Constraints Description
price string true Price
Description:
- Required
price_tp string|null false nullable: true 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 nullable: true 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

Type Constraints
UpdateOrder

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false required: ["order_id","symbol","state","volume","price","price_tp","price_sl"] Response data

data

Response data

Type Constraints
object required: ["order_id","symbol","state","volume","price","price_tp","price_sl"]

Properties

Name Type Required Constraints Description
order_id integer(int64) true Order ID
symbol string true Currency pair
state string true Order status code
volume string true Order quantity
price string true Current price
price_tp string true Current take profit price
price_sl string true Current stop loss price

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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(int64) 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

Type Constraints
object additionalProperties: false

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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

Type Constraints
OrderHistoryList

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false Historical order list

data / list

Historical order list

Type Constraints
array

data / list / items

Order detail

Type Constraints
object

Properties

Name Type Required Constraints Description
order_id integer(int64) false Order ID
symbol string false Currency pair
symbol_desc string false Symbol description
price_type string false enum: ["market","trigger"] Trade type (market=market price, trigger=trigger price)
order_opt_type integer false enum: [1,2,3,4,5,6] Order operation type (1=sell, 2=buy, 3=close long, 4=close short, 5=force close long, 6=force close short)
state integer false Order status code
state_desc string false Order status description
side integer false enum: [1,2] Side (1=sell, 2=buy)
volume string false Order quantity
fill_volume string false Trading size
close_pnl string false Close Position P&L
price string false Average fill price
trigger_price string false Trigger price
price_tp string false Take profit price
price_sl string false Stop loss price
time_setup integer(int64) false Order time (Unix timestamp in seconds)
time_done integer(int64) false End time (Unix timestamp in seconds)

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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(int64) 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

Type Constraints
OrderLog

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
order_id integer(int64) false Order ID
log_id integer(int64) false logID
symbol string false Trading pair of the order
price_type string false enum: ["market","trigger"] Trade type (market=market price, trigger=trigger price)
state integer false Order status code (1=placed, 2=canceled, 3=partially filled, 4=filled, 5=rejected)
side integer false enum: [1,2] Side (1=sell, 2=buy)
volume string false Order quantity
price string false Average fill price

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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

Type Constraints
PositionList

Properties

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

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false Position information

data / list

Position information

Type Constraints
array

data / list / items

Position information

Type Constraints
object

Properties

Name Type Required Constraints Description
position_id integer(int64) false Position ID
symbol string false Trading market code
symbol_desc string false Market description
margin string false Used margin
unrealized_pnl string false Unrealized PNL
unrealized_pnl_rate string false Unrealized return rate
volume string false Position size
price_open string false Average Opening Price
position_dir string false Position direction (Long=long position, Short=short position)

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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(int64) 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

# Request Body Schema

Modify position take profit/stop loss parameters

Type Constraints
TradFiPositionUpdateRequest

Properties

Name Type Required Constraints Description
price_tp string|null false nullable: true 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 nullable: true 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

Type Constraints
UpdatePosition

Properties

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

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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(int64) 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

# Request Body Schema

Close position request parameters

Type Constraints
TradFiClosePositionRequest required: ["close_type"]

Properties

Name Type Required Constraints Description
close_type integer true enum: [1,2] Close Type
Description:
- 1: Partial Close (close_volume is required)
- 2: Full Close (close_volume is not required)
close_volume string|null false nullable: true Close Volume
Description:
- Required when close_type = 1
- Ignored when 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

Type Constraints
DeletePosition

Properties

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

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

Name Type Required Constraints Description
label string false Business status code, non-empty indicates request exception, please refer to TradFi error enumeration in documentation
message string false Return message, returned when request error occurs
timestamp integer(int64) false 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 as a Unix timestamp in seconds. The earliest supported start 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

Type Constraints
PositionHistoryList

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
total integer false Total amount
total_page integer false Total pages
list array false Query historical position list

data / list

Query historical position list

Type Constraints
array

data / list / items

Position close history

Type Constraints
object required: ["position_id","symbol","realized_pnl","volume","volume_closed","price_open","position_dir","close_price","time_create","time_close","position_status","realized_pnl_detail"]

Properties

Name Type Required Constraints Description
position_id integer(int64) true Position ID
symbol string true Market / Trading symbol
realized_pnl string true Realized PnL
realized_pnl_rate string false Realized return rate
volume string true Position size / Maximum position size
volume_closed string true Close volume
price_open string true Average Opening Price
position_dir string true enum: ["Long","Short"] Position Direction
- Long: Long Position
- Short: Short Position
price_tp string false Take profit price
price_sl string false Stop loss price
counterparty_price string false Counterparty price
close_price string true Close price
time_create string true Open time (timestamp in seconds)
time_close string true Close time (timestamp in seconds)
position_status string true Position Status
- 1: Fully Closed
- 2: Forced Liquidation
close_detail object|null false nullable: true Liquidation details (null for normal close)
realized_pnl_detail object true Realized P&L details

data / list / items / close_detail

Liquidation details (null for normal close)

Type Constraints
object|null nullable: true

Properties

Name Type Required Constraints Description
margin_level string false Margin ratio (multiplied by 100)
margin string false Margin
equity string false Net equity
stop_out_level string false Liquidation ratio (multiplied by 100)

data / list / items / realized_pnl_detail

Realized P&L details

Type Constraints
object

Properties

Name Type Required Constraints Description
closed_pnl string false Close Position P&L
swap string false Swap fee
fee string false fee

Status Code 400

TradFiError

Type Constraints
TradFiError

Properties

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

WARNING

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

# Schemas

# Symbols

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

Type Constraints
object

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false Trading symbol list

data / list

Trading symbol list

Type Constraints
array

data / list / items

Trading symbol information

Type Constraints
object

Properties

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

# TradFiOrderUpdateRequest

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

Modify order price and take profit/stop loss parameters

Type Constraints
object required: ["price"]

Properties

Name Type Required Constraints Description
price string true Price
Description:
- Required
price_tp string|null false nullable: true 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 nullable: true 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

# CreateUserResp

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

Type Constraints
object

Properties

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

data

Type Constraints
object

Properties

Name Type Required Constraints Description
status integer false Status (1=not opened, 2=pending review, 3=opened)
leverage integer false Leverage

# 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"
  }
}

Type Constraints
object

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
equity string false Account equity
margin_level string false Margin level (percentage)
balance string false Account Balance
margin string false Used margin
margin_free string false Available Margin
unrealized_pnl string false Unrealized PNL

# 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

Type Constraints
object

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false required: ["order_id","symbol","state","volume","price","price_tp","price_sl"] Response data

data

Response data

Type Constraints
object required: ["order_id","symbol","state","volume","price","price_tp","price_sl"]

Properties

Name Type Required Constraints Description
order_id integer(int64) true Order ID
symbol string true Currency pair
state string true Order status code
volume string true Order quantity
price string true Current price
price_tp string true Current take profit price
price_sl string true Current stop loss price

# PositionList

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

Type Constraints
object

Properties

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

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false Position information

data / list

Position information

Type Constraints
array

data / list / items

Position information

Type Constraints
object

Properties

Name Type Required Constraints Description
position_id integer(int64) false Position ID
symbol string false Trading market code
symbol_desc string false Market description
margin string false Used margin
unrealized_pnl string false Unrealized PNL
unrealized_pnl_rate string false Unrealized return rate
volume string false Position size
price_open string false Average Opening Price
position_dir string false Position direction (Long=long position, Short=short position)

# TradFiOrderRequest

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

Place order request parameters

Type Constraints
object required: ["price","price_type","side","symbol","volume"]

Properties

Name Type Required Constraints Description
price string true Order price
price_type string true enum: ["trigger","market"] Price type (trigger=trigger price, market=market price)
side integer true enum: [1,2] Side (1=sell, 2=buy)
symbol string true Base trading symbol code
volume string true Order quantity
price_tp string false Take profit price (optional)
price_sl string false Stop loss price (optional)
leverage integer false Leverage multiplier (must be one of the leverage multipliers allowed for the symbol in the trading symbol details response)

# ContractDetail

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

Type Constraints
object

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false Contract Details List

data / list

Contract Details List

Type Constraints
array

data / list / items

Futures contract details

Type Constraints
object

Properties

Name Type Required Constraints Description
symbol string false Trading symbol code
symbol_desc string false Trading symbol description
category_name string false Category name
contract_volume string false Contract Volume
settlement_currency string false Settle currency
max_order_volume string false Maximum Order Volume
min_order_volume string false Minimum Order Volume
leverage string false Leverage multiplier
price_precision integer false Price precision (decimal places)
price_sl_level string false Stop Loss Price Level
swap_cost_type string false Swap Cost Type
buy_swap_cost_rate string false Buy Swap Cost Rate
sell_swap_cost_rate string false Sell Swap Cost Rate
swap_cost_3day string false 3-Day Swap Cost
trade_timezone string false Trading Timezone
trade_mode string false Trading mode code (0=disabled, 1=long only, 2=short only, 3=close only, 4=full trading access)
icon_link string false Symbol icon URL

# 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"
  }
}

Type Constraints
object

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
order_id integer(int64) false Order ID
log_id integer(int64) false logID
symbol string false Trading pair of the order
price_type string false enum: ["market","trigger"] Trade type (market=market price, trigger=trigger price)
state integer false Order status code (1=placed, 2=canceled, 3=partially filled, 4=filled, 5=rejected)
side integer false enum: [1,2] Side (1=sell, 2=buy)
volume string false Order quantity
price string false Average fill price

# TradFiClosePositionRequest

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

Close position request parameters

Type Constraints
object required: ["close_type"]

Properties

Name Type Required Constraints Description
close_type integer true enum: [1,2] Close Type
Description:
- 1: Partial Close (close_volume is required)
- 2: Full Close (close_volume is not required)
close_volume string|null false nullable: true Close Volume
Description:
- Required when close_type = 1
- Ignored when close_type = 2

# Klines

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

Type Constraints
object

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false Kline data list

data / list

Kline data list

Type Constraints
array

data / list / items

Single kline data

Type Constraints
object

Properties

Name Type Required Constraints Description
o string false Open price
c string false Close price
h string false High price
l string false Low price
t integer(int64) false Timestamp (Unix seconds)

# 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

Ticker summary information

Type Constraints
object

Properties

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

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
highest_price string false High price
lowest_price string false Low price
price_change string false Price change percentage (multiplied by 100)
price_change_amount string false Price change amount
today_open_price string false Today's open price
last_today_close_price string false Previous close price
last_price string false Last trading price
bid_price string false Bid price
ask_price string false Ask price
favorite boolean false Is favorited
status string false Trading status (open=tradable, closed=non-tradable)
close_time integer(int64) false Close time (Unix timestamp in seconds)
open_time integer(int64) false Open time (Unix timestamp in seconds)
next_open_time integer(int64) false Next open time (0 means none)
trade_mode string false Trading mode code
category_name string false Category name

# SymbolCommissions

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

Type Constraints
object

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false List of symbol commission rates

data / list

List of symbol commission rates

Type Constraints
array

data / list / items

Symbol commission rate

Type Constraints
object

Properties

Name Type Required Constraints Description
category_code string false Category code
symbol string false Trading symbol code
fee_per_lot string false Commission rate per lot

# DeletePosition

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

Type Constraints
object

Properties

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

# Categories

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

Type Constraints
object

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Data

data

Data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false

data / list

Type Constraints
array

data / list / items

Category information

Type Constraints
object

Properties

Name Type Required Constraints Description
category_id integer false Category ID
is_favorite boolean false Whether it is a custom category, generally no need to pay attention
category_name string false Category name

# OrderList

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

Type Constraints
object

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false Order list

data / list

Order list

Type Constraints
array

data / list / items

Order detail

Type Constraints
object

Properties

Name Type Required Constraints Description
order_id integer(int64) false Order ID
symbol string false Currency pair
symbol_desc string false Symbol description
price_type string false enum: ["market","trigger"] Trade type (market=market price, trigger=trigger price)
state integer false Order status code
state_desc string false Order status description
finished integer false enum: [0,1] Is completed (0=shown in active order list, 1=not shown in active list)
side integer false enum: [1,2] Side (1=sell, 2=buy)
volume string false Order quantity
price string false Trigger price
price_tp string false Take profit price
price_sl string false Stop loss price
time_setup integer(int64) false Order time (Unix timestamp in seconds)

# CreateTransaction

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

Type Constraints
object

Properties

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

# Mt5Account

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

Type Constraints
object

Properties

Name Type Required Constraints Description
code integer false Business Status Code; Non-zero Indicates Business Exception, Please Check Message
message string false Response message
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
leverage integer false Leverage multiplier
stop_out_level string false Liquidation margin ratio
status integer false Account status (1=not opened, 2=pending review, 3=active)

# TradFiError

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

TradFiError

Type Constraints
object

Properties

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

# PositionHistoryList

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

Type Constraints
object

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
total integer false Total amount
total_page integer false Total pages
list array false Query historical position list

data / list

Query historical position list

Type Constraints
array

data / list / items

Position close history

Type Constraints
object required: ["position_id","symbol","realized_pnl","volume","volume_closed","price_open","position_dir","close_price","time_create","time_close","position_status","realized_pnl_detail"]

Properties

Name Type Required Constraints Description
position_id integer(int64) true Position ID
symbol string true Market / Trading symbol
realized_pnl string true Realized PnL
realized_pnl_rate string false Realized return rate
volume string true Position size / Maximum position size
volume_closed string true Close volume
price_open string true Average Opening Price
position_dir string true enum: ["Long","Short"] Position Direction
- Long: Long Position
- Short: Short Position
price_tp string false Take profit price
price_sl string false Stop loss price
counterparty_price string false Counterparty price
close_price string true Close price
time_create string true Open time (timestamp in seconds)
time_close string true Close time (timestamp in seconds)
position_status string true Position Status
- 1: Fully Closed
- 2: Forced Liquidation
close_detail object|null false nullable: true Liquidation details (null for normal close)
realized_pnl_detail object true Realized P&L details

data / list / items / close_detail

Liquidation details (null for normal close)

Type Constraints
object|null nullable: true

Properties

Name Type Required Constraints Description
margin_level string false Margin ratio (multiplied by 100)
margin string false Margin
equity string false Net equity
stop_out_level string false Liquidation ratio (multiplied by 100)

data / list / items / realized_pnl_detail

Realized P&L details

Type Constraints
object

Properties

Name Type Required Constraints Description
closed_pnl string false Close Position P&L
swap string false Swap fee
fee string false fee

# OrderHistoryList

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

Type Constraints
object

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Response data

data

Response data

Type Constraints
object

Properties

Name Type Required Constraints Description
list array false Historical order list

data / list

Historical order list

Type Constraints
array

data / list / items

Order detail

Type Constraints
object

Properties

Name Type Required Constraints Description
order_id integer(int64) false Order ID
symbol string false Currency pair
symbol_desc string false Symbol description
price_type string false enum: ["market","trigger"] Trade type (market=market price, trigger=trigger price)
order_opt_type integer false enum: [1,2,3,4,5,6] Order operation type (1=sell, 2=buy, 3=close long, 4=close short, 5=force close long, 6=force close short)
state integer false Order status code
state_desc string false Order status description
side integer false enum: [1,2] Side (1=sell, 2=buy)
volume string false Order quantity
fill_volume string false Trading size
close_pnl string false Close Position P&L
price string false Average fill price
trigger_price string false Trigger price
price_tp string false Take profit price
price_sl string false Stop loss price
time_setup integer(int64) false Order time (Unix timestamp in seconds)
time_done integer(int64) false End time (Unix timestamp in seconds)

# UpdatePosition

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

Type Constraints
object

Properties

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

# TransactionList

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

Type Constraints
object

Properties

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

data

Type Constraints
object

Properties

Name Type Required Constraints Description
total integer false Total Records
total_page integer false Total pages
list array false Record List

data / list

Record List

Type Constraints
array

data / list / items

Type Constraints
object

Properties

Name Type Required Constraints Description
asset string false Asset Type
type string false enum: ["deposit-转入","withdraw-转出","dividend-分红结息","fill_negative-填平负余额"] Trading Type
type_desc string false Transaction Type Description
change string false Change amount
balance string false Current Balance
time integer(int64) false Occurrence Time (Second-level Timestamp)

# TradFiPositionUpdateRequest

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

Modify position take profit/stop loss parameters

Type Constraints
object

Properties

Name Type Required Constraints Description
price_tp string|null false nullable: true 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 nullable: true 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"
  }
}

Type Constraints
object

Properties

Name Type Required Constraints Description
timestamp integer(int64) false Server timestamp (milliseconds)
data object false Order result

data

Order result

Type Constraints
object

Properties

Name Type Required Constraints Description
id string false Queue Task ID (not order ID)

# TradFiTransactionRequest

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

Fund Transfer Request Body

Type Constraints
object required: ["asset","change","type"]

Properties

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