NAV Navbar
curl python node.js

Introduction

Welcome to the AAX API developer documentation. This document should contain all the information required to properly implement applications using our API

API Key

In order to access the parts of the API which require authentication, you must generate an API key and API secret follow this link. You can generate as many API keys as you would like, and each of those keys can be customized in a few ways.

Permissions Read Write
Account info default optional
Spot Trading default optional
Futures Trading default optional
Withdraw default optional

By default, API Keys can only read basic user data, such as positions, margin, orders, and executions. They cannot submit orders or withdraw.

If you wish to execute spot or futures orders with your API Key, you must add the "Spot Trading" or "Futures Trading" permission upon creation.

Withdrawals are also possible with the "Withdraw" permission.

API Keys cannot be used to create other API Keys or modify user authentication.

REST

Overview

RESTful endpoint provides the widest range of data, based on HTTP protocol which works in Request-Reply scheme

Endpoints

Base URL: https://api.testnet.aax.com

Public Endpoints

Public APIs are available for acquiring information. Public requests do not require any verifications.

Private Endpoints

Private endpoints are available for order management, and account management. Every private request must be signed using the described authentication scheme.

Private endpoints require authentication using your API key. You can generate API keys.

Authentication

To authorize, use this code:

import hmac, hashlib, time, requests

API_KEY = '***YOUR_API_KEY***';
API_SECRET = '***YOUR_API_SECRET***';

class Auth(requests.auth.AuthBase):
    def __init__(self, api_key, secret_key):
        self.api_key = api_key
        self.secret_key = secret_key

    def __call__(self, request):
        nonce = str(int(1000 * time.time()))
        message = nonce + ':' + request.method + request.path_url + (request.body or '')
        signature = hmac.new(self.secret_key.encode(), message.encode(), hashlib.sha256).hexdigest()
        request.headers.update({
            'X-ACCESS-NONCE': nonce,
            'X-ACCESS-KEY': self.api_key,
            'X-ACCESS-SIGN': signature,
        })
        return request

auth = Auth(API_KEY, API_SECRET)

AAX offers SecretAPIKey for authentication. Never share your keys. Keep them guarded and secured. If you are logged in, please follow the link to manage your active keys.

Authentication is done by sending the following HTTP headers:

HTTP Requests

Each HTTP requests must contain the header Accept: application/x-www-form-urlencoded as all our responses.

HTTP Responses

All response will be returned in JSON format.

HTTP Success

Successful HTTP responses have the status code 200 and the body in a format according to documentation of the requested resource.

HTTP Errors

All HTTP requests with response status code different to 200 must be considered as failed and you should expect additional JSON inside the body of the response with the error message encapsulated inside it as shown in the example. we use the following error codes:

ERROR Code Meaning
400 Bad Request – There is something wrong with your request
401 Unauthorized – Your API key is wrong
403 Forbidden – Your API key doesnt’t have enough privileges to access this resource
429 Too many requests – You have exceeded your API key rate limits
500 Internal Server - Internal Server Error
503 Service Unavailable - Service is down for maintenance
504 Gateway Timeout. Request timeout expired
550 No data – You requested specific single item that we don’t have at this moment.

Rate Limits

All authenticated paths apart from cancel orders and close position: 10 per second, 150 per minute, 5000 per hour

Public Endpoints

Available endpoints
Method Path Description
GET common/v2/trading-pair Retrieve all trading pairs information

Trading Pair

import requests
response = requests.get('https://api.testnet.aax.com/common/v2/trading-pair').json()
print(response)

The above command returns JSON structured like this:

{"code":1,
"success":true,
"data":{
        "tradingPairs":[
                       {"baseCurrency": "BTC",
                        "bbStatus": "active",
                        "code": "FP",
                        "imRate": "0.01000",
                        "makerFee": "-0.00025",
                        "marginScale": "0.00000001",
                        "maxPrice": "999999.0000000000",
                        "maxQuantity": "99999999.0000000000",
                        "minPrice": "0.5000000000",
                        "minQuantity": "10.0000000000",
                        "mmRate": "0.00500",
                        "multiples": ["1",
                                      "2",
                                      "3",
                                      "5",
                                      "10",
                                      "25",
                                      "50",
                                      "100"],
                        "multiplier": "1.000000000000",
                        "orderValueScale": "0.00000001",
                        "priceScale": "0.5",
                        "qtyScale": "10",
                        "quoteCurrency": "USD",
                        "realisedPnlScale": "0.00000001",
                        "status": "enable",
                        "symbol": "BTCUSDFP",
                        "takerFee": "0.00075",
                        "type": "futures"}, ...
                        ]
         }               
}

The above command returns JSON structured like this:

Description

This endpoint is used to retrieve all trading pairs information.

HTTP Request

GET common/v2/trading-pair

Output variables
Variable Type Description
priceScale string Price is always a multiple of the price scale
qtyScale string Order quantity in base currency is always a multiple of the quantity scale
marginScale string Margin is always of a multiple of the margin scale
orderValueScale string Order value is always of a multiples of the order value scale
realisedPnlScale string Realised profit and loss is always of a multiple of the realised pnl scale
baseCurrency string Base currency in a trading pair
quoteCurrency string Quote currency in a trading pair
minQuantity string Minimum order amount in base currency for buying or selling
maxQuantity string Maximum order amount in base currency for buying or selling
minPrice string Minimum price that you can input
maxPrice string Maximum price that you can input
status string The status of the trading pair; Allowable values:enable, disable or readonly
symbol string Trading symbol
code string Applicable for Futures only. null for spot, "FP" for Futures
takerFee string Taker fee
makerFee string Maker fee
multiplier string Multiplier for futures, ignore for Spot
mmRate string Maintenance margin rate for Futures, ignore for Spot
imRate string Initial margin rate for Futures, ignore for Spot

Authenticated Endpoints

Available endpoints
Method Path Description
GET /common/v2/user/profile Retrieve user information
GET /common/v2/user/balances Retrieve user balance information
POST /exchange/v1/orders Place spot new order
POST /exchange/v1/orders/cancel/{orderNo} Cancel an spot order
POST /exchange/v1/orders/cancel/all Cancel all of your spot orders
GET /exchange/v1/users/detail Query trade details of spot order
GET /exchange/v1/users/my-orders Query historical spot orders
POST /exchange/v1/futures/orders Place futures new order
PUT /exchange/v1/futures/orders Amend the quantity of an open order
DELETE /exchange/v1/futures/orders/{orderNo} Cancel an futures order.
GET /exchange/v1/futures/position Get positions for all contracts
DELETE /exchange/v1/futures/orders/cancel/all Cancel all of yours futures orders
POST /exchange/v1/futures/position/close Close position
POST /exchange/v1/futures/position/leverage Setup leverage for position
GET /exchange/v1/futures/trades Retrieve trade details of an order
GET /exchange/v1/futures/orders Retrieve historical orders

Profile

import requests
response = requests.get('https://api.testnet.aax.com/common/v2/user/profile',  verify=True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {"identityStatus": None,
          "userInfo": {"avatar": None,
                       "country": "China",
                       "countryCode": "+86",
                       "createdTime": "2019-03-21T09:40:39.155Z",
                       "email": None,
                       "enableEmailVerify": False,
                       "enableMobileVerify": True,
                       "enableTOTP": False,
                       "fundsHash": None,
                       "id": 1019,
                       "identityType": None,
                       "imToken": "zsd***k",
                       "language": "zh-CN",
                       "lastLoginLocation": "Private IP",
                       "lastLoginTime": "2019-06-24T06:39:46.000Z",
                       "legalTender": "USD",
                       "level": "0",
                       "lockReason": None,
                       "mobile": "*******",
                       "nickname": "atom**",
                       "rfColor": False,
                       "role": "0",
                       "serialNo": "HZW3Q***Y3TXFJ",
                       "status": "0",
                       "timezone": "+8",
                       "timezoneName": "Asia/Beijing",
                       "unlockTime": None,
                       "updatedTime": "2019-06-24T06:39:45.000Z"}},
 "success": True}
Description

This endpoint is used to retrieve user information.

HTTP Request

GET /common/v2/user/profile

Balance

import requests
response = requests.get('https://api.testnet.aax.com/common/v2/user/balances',  verify=True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {"balances": [{"availableBalance": 0.35292796,
                        "availableBalanceString": "0.35292796",
                        "currencyCode": "BTC",
                        "type": "coin",
                        "unavailableBalance": 1.61315799,
                        "unavailableBalanceString": "1.61315799"},
                       {"availableBalance": 4.7580176,
                        "availableBalanceString": "4.75801760",
                        "currencyCode": "ETH",
                        "type": "coin",
                        "unavailableBalance": 0.08,
                        "unavailableBalanceString": "0.08000000"}
 "success": True}
Description

This endpoint is used to retrieve user balance information.

HTTP Request

GET /common/v2/user/balances

Output variables
Variable Type Description
availableBalance integer Your available balance for placing orders
availableBalanceString string
currencyCode string Name of currency
type string
unavailableBalance integer Locked balance
unavailableBalanceString string

Place Spot Order

import requests
data ={'type': 'LIMIT',
       'symbol': 'ETHBTC',
       'quantity': 0.02,
       'price': 0.02832,
       'baseCurrency': 'ETH',
       'quoteCurrency': 'BTC',
       'side': 'BUY',
       'clientSN': 'aax_client'}
response = requests.post('https://api.testnet.aax.com/exchange/v1/orders', data=data,verify = True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {"baseCurrency": "ETH",
          "clientSN": 'aax_client',
          "id": None,
          "liqType": 0,
          "marketPrice": "0.0283200000",
          "orderNo": "HjSUolzd8W",
          "orderType": 2,
          "price": "0.0283200000",
          "quantity": "0.02",
          "quoteCurrency": "BTC",
          "rejectCode": None,
          "rejectReason": None,
          "settleType": None,
          "side": 1,
          "status": 0,
          "stopPrice": None,
          "symbol": "ETHBTC",
          "userId": "1019"},
 "details": None,
 "message": "success",
 "timestamp": "2019-06-24 08:43:20"}
Description

This endpoint is used for placing spot orders. See individual fields below for more details on their use.

type

HTTP Request

POST /exchange/v1/orders

Parameters:

Name Required Type Description
type Yes string Accepted values,MARKET, LIMIT, STOP-LIMIT
symbol Yes string The trading symbol to trade. Convention is "Base currency" + "Quote Currency"
price No string The limit price in limit and stop-limit order
quantity Yes string The buying or selling quantity
baseCurrency Yes string Name (code) of base currency, for example, "BTC"
quoteCurrency Yes string Name of quote currency, for example, "USDT"
side Yes string BUY OR SELL the base currency
stopPrice No string Stop price of stop-limit order, only needed for stop-limit order
clientSN No string Order ID customized by yourself, The client_oid type should be comprised of alphabets + Strings or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported
Output variables
Variable Type Description
baseCurrency string Name of base currency
clientSN string Order ID customized by yourself
id string For internal purposes
liqType string 0-GENERAL,1-USER-CLOSE-LIQ,2-STOP-LIQ
marketPrice string The mark price for this contract, this is the price used for funding calculations
orderNo string This is AAX Order ID. You will need to quote this ID to cancel an order
orderType integer Order type,"1:Market Order 2: Limit Order 3: Stop Order ,4:Stop-Limit
price string The limit price in limit and stop-limit order
quantity string The buying or selling quantity
quoteCurrency string Name of quote currency
rejectCode integer Code specifying the reason for the reject.
rejectReason string The reason for the reject.
settleType string Inverse, Vanilla & Quanto
side integer BUY OR SELL the base currency, 1=Buy, 2=Sell
status integer Order status, "1= New, 2=Cancel, 3=Amend, 4=Reject,5=Fail,6=Error,9=Done"
stopPrice string The stop price of stop-limit order
userId string User id

Modify Spot Order

import requests
response=requests.put('https://api.testnet.aax.com/exchange/v1/orders',data= {'orderNo':'lsJ3KRBq8','quantity':3},verify=True,auth=auth).json()
print(response)

The above command returns JSON structured like this:

"code": 1,
 "data": {"baseCurrency": "BTC",
          "clientSN": None,
          "id": "281712",
          "liqType": 0,
          "marketPrice": "10878",
          "orderNo": "lsJ3KRBq8",
          "orderType": 1,
          "price": "10878.35",
          "quantity": "0.02",
          "quoteCurrency": "USDT",
          "rejectCode": None,
          "rejectReason": None,
          "settleType": None,
          "side": 1,
          "status": 2,
          "stopPrice": "0",
          "symbol": "BTCUSDT",
          "userId": "1019"},
 "details": None,
 "message": "success",
 "timestamp": "2019-06-24 08:43:22"}
Description

This endpoint is used to amend the quantity or price of an open order.

HTTP Request

PUT /exchange/v1/orders

Parameters

Name Required Type Description
orderNo Yes string The previously returned order id when order was created
quantity NO string The buying or selling quantity
price NO string The buying or selling price
stopPrice NO string The buying or selling stopPrice
Output variables
Variable Type Description
baseCurrency string Name of base currency
clientSN string Order ID customized by yourself
id string For internal purposes
liqType string 0-GENERAL,1-USER-CLOSE-LIQ,2-STOP-LIQ
marketPrice string The mark price for this contract, this is the price used for funding calculations
orderNo string This is AAX Order ID
orderType integer Order type,"1"=Market Order "2"=Limit Order "3"=Stop Order "4"=Stop-Limit
price string The limit price in limit and stop-limit order
quantity string The buying or selling quantity
quoteCurrency string Name of quote currency
rejectCode integer Code specifying the reason for the reject
rejectReason string The reason for the reject
side integer "BUY" OR "SELL" the base currency, 1=Buy, 2=Sell
status integer Order status, "1= New, 2=Cancel, 3=Amend, 4=Reject,5=Fail,6=Error,9=Done"
stopPrice string The stop price of stop-limit order
userId string User id

Cancel Spot Order

import requests
response = requests.post('https://api.testnet.aax.com/exchange/v1/orders/cancel/o5oV9E6o0X', verify=True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {"baseCurrency": "BTC",
          "clientSN": None,
          "id": "281712",
          "liqType": 0,
          "marketPrice": "10878.4000000000",
          "orderNo": "o5oV9E6o0X",
          "orderType": 1,
          "price": "10878.35",
          "quantity": "0.02",
          "quoteCurrency": "USDT",
          "rejectCode": None,
          "rejectReason": None,
          "settleType": None,
          "side": 1,
          "status": 2,
          "stopPrice": "0",
          "symbol": "BTCUSDT",
          "userId": "1019"},
 "details": None,
 "message": "success",
 "timestamp": "2019-06-24 08:43:22"}
Description

This endpoint is used to cancel an order.

HTTP Request

POST /exchange/v1/orders/cancel/{orderNo}

Parameters

Name Required Type Description
orderNo Yes string The previously returned order id when order was created
Output variables
Variable Type Description
baseCurrency string Name of base currency
clientSN string Order ID customized by yourself
id string For internal purposes
liqType string 0-GENERAL,1-USER-CLOSE-LIQ,2-STOP-LIQ
marketPrice string The mark price for this contract, this is the price used for funding calculations
orderNo string This is AAX Order ID
orderType integer Order type,"1"=Market Order "2"=Limit Order "3"=Stop Order "4"=Stop-Limit
price string The limit price in limit and stop-limit order
quantity string The buying or selling quantity
quoteCurrency string Name of quote currency
rejectCode integer Code specifying the reason for the reject
rejectReason string The reason for the reject
side integer "BUY" OR "SELL" the base currency, 1=Buy, 2=Sell
status integer Order status, "1= New, 2=Cancel, 3=Amend, 4=Reject,5=Fail,6=Error,9=Done"
stopPrice string The stop price of stop-limit order
userId string User id

Cancel All Spot Order

import requests
response = requests.delete('https://api.testnet.aax.com/exchange/v1/orders/cancel/all', verify=True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{
"code": 1,
 "data": None,
 "details": None,
 "message": "success",
 "timestamp": "2019-07-04 09:56:43",
 }
Description

This endpoint is used to cancel all of your orders.

HTTP Request

POST /exchange/v1/orders/cancel/all

Query Spot Order Detail

import requests
response = requests.get('https://api.testnet.aax.com/exchange/v1/users/detail', params={'baseCurrency': 'ETH', 'quoteCurrency': 'USDT'}, verify=True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {"endRow": 10,
          "firstPage": 1,
          "hasNextPage": True,
          "hasPreviousPage": False,
          "isFirstPage": True,
          "isLastPage": False,
          "lastPage": 8,
          "list": [{"averagePrice": "0",
                    "baseCurrency": "ETH",
                    "clientOrderNo": "D1x2BI1OKY",
                    "commission": "0",
                    "createTime": "2019-06-23 22:18:25",
                    "filledPrice": "311.5",
                    "filledQty": "0.1",
                    "id": "199608",
                    "lastUpdateTime": None,
                    "orderNo": "O0eQPP6xBQO8",
                    "orderType": 2,
                    "price": "311.5",
                    "quoteCurrency": "USDT",
                    "rejectCode": None,
                    "rejectReason": None,
                    "remainingQty": "0",
                    "remark": None,
                    "side": 1,
                    "status": 3,
                    "stopPrice": "0",
                    "symbol": "ETHUSDT",
                    "totalQty": "0.1",
                    "tradeTime": "2019-06-23 22:17:12",
                    "txnFilledQty": "0.018",
                    "userId": "1019", ...],
          "navigateFirstPage": 1,
          "navigateLastPage": 8,
          "navigatePages": 8,
          "navigatepageNums": [1, 2, 3, 4, 5, 6, 7, 8],
          "nextPage": 2,
          "pageNum": 1,
          "pageSize": 10,
          "pages": 809,
          "prePage": 0,
          "size": 10,
          "startRow": 1,
          "total": 8088},
 "details": None,
 "message": "success",
 "timestamp": "2019-06-24 08:43:23"}
Description

This endpoint is used to query trade details of order.

HTTP Request

GET /exchange/v1/users/detail

Parameters

Name Required Type Description
pageNo No integer Pagination page number, default "1"
pageSize No string Pagination page size, default "10"
clientOrderNo No string This is AAX Order ID. You will need to quote this ID to cancel order
baseCurrency No string Name (code) of base currency, for example, "BTC"
quoteCurrency No string Name (code) of quote currency, for example, "USDT"
startDate No string Search starts date, in format yyyy-mm-dd
endDate No string Search ends date, in format yyyy-mm-dd
side No string Filter on the direction of the trade, BUY or SELL
orderType No string The types of order to include in the search,MARKET, LIMIT,STOP-LIMIT
timeZone No string Search timezone, default is UTC
Output variables
Variable Type Description
averagePrice string The average trading price
baseCurrency string Name of base currency
clientOrderNo string This is AAX Order ID. You will need to quote this ID to cancel an order
commission string Total commission paid since opening the position
createTime string Order creation time
filledPrice string Filled price for the trade
filledQty string Cumulative filled quantity of the order
id string For internal purpose
lastUpdateTime string Last update time of the order
orderNo string For internal purpose
orderType integer Order type, "1"=Market Order,"2"=Limit Order,"3"=Stop Order","4"=Stop-Limit
price string The limit price in limit and stop-limit order
quoteCurrency string Name of quote currency
rejectCode string Code specifying the reason for the reject
rejectReason string The reason for the reject
remainingQty string The quantity in an order that remain to be bought/sold
side integer "BUY" OR "SELL" the base currency, "1"=Buy, "2"=Sell
status integer Order status,"0:Pending-New;1:New;2:Partially-Filled; 3:Filled; 4:Cancel-Reject;5:Canceled; 6:Rejected; 7:Suspended; 8:Pending-Replace; 9:Replaced; 10:Expired; 11:Business-Reject"
stopPrice string The stop price of stop-limit order
symbol string The trading symbol to trade. Convention is "Base currency" + "Quote Currency"
totalQty string The quantity in an order
tradeTime string The time at which order was executed
txnFilledQty string Filled quantity of the trade
userId string User id

Query Spot Historical Order(s)

import requests
response = requests.post('https://api.testnet.aax.com/exchange/v1/users/my-orders', params={'baseCurrency': 'BTC', 'quoteCurrency': 'USDT'}, verify=True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {"endRow": 10,
          "firstPage": 1,
          "hasNextPage": True,
          "hasPreviousPage": False,
          "isFirstPage": True,
          "isLastPage": False,
          "lastPage": 8,
          "list": [{"averagePrice": "0",
                    "baseCurrency": "BTC",
                    "clientOrderNo": "o5oV9E6o0X",
                    "clientSN": None,
                    "commission": "0",
                    "createTime": "2019-06-24 08:43:22",
                    "filledPrice": "0",
                    "filledQty": "0",
                    "hasHistory": False,
                    "id": "110936",
                    "lastUpdateTime": None,
                    "orderNo": None,
                    "orderType": 1,
                    "price": "10878.35",
                    "quoteCurrency": "USDT",
                    "rejectCode": None,
                    "rejectReason": None,
                    "remainingQty": "0",
                    "side": 1,
                    "status": 0,
                    "stopPrice": "0",
                    "symbol": "BTCUSDT",
                    "totalQty": "0.02",
                    "tradeTime": None,
                    "txnFilledQty": "0",
                    "userId": "1019"},...],
          "navigateFirstPage": 1,
          "navigateLastPage": 8,
          "navigatePages": 8,
          "navigatepageNums": [1, 2, 3, 4, 5, 6, 7, 8],
          "nextPage": 2,
          "pageNum": 1,
          "pageSize": 10,
          "pages": 1902,
          "prePage": 0,
          "size": 10,
          "startRow": 1,
          "total": 19011},
 "details": None,
 "message": "success",
 "timestamp": "2019-06-24 08:43:23"}
Description

This endpoint is used to query historical orders.

HTTP Request

GET /exchange/v1/users/my-orders

Parameters

Name Required Type Description
searchType No integer The states of order to include in the search,0:Open order and Partial order;1:Filled order and Cancel order
pageNo No integer Pagination page number, default "1"
pageSize No string Pagination page size, default "10"
symbol No string The trading symbol to trade. Convention is "Base currency" + "Quote Currency"
clientOrderNo No string This is AAX Order ID. You will need to quote this ID to cancel an order
baseCurrency No string Name (code) of base currency, for example, "BTC"
quoteCurrency No string Name (code) of quote currency, for example, "USDT"
status No integer The states of order to include in the search, '1:new;2:filled;3:cancel'
startDate No string Search starts date, in format yyyy-mm-dd
endDate No string Search ends date, in format yyyy-mm-dd
orderType No string The types of order to include in the search,MARKET, LIMIT, STOP-LIMIT
side No string Filter on the direction of the trade, BUY or SELL
orderType No string The types of order to include in the search,MARKET, LIMIT,STOP-LIMIT
timeZone No string Search timezone, default is UTC
clientSN No string Order ID customized by yourself, The client_oid type should be comprised of alphabets + Strings or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported
Output variables
Variable Type Description
averagePrice string The average trading price
baseCurrency string Name of base currency
clientOrderNo string This is AAX Order ID. You will need to quote this ID to cancel an order
clientSN string Order ID customized by yourself
commission string Total commission paid since opening the position
createTime string Order creation time
filledPrice string Filled price for the trade
filledQty string Cumulative filled quantity of the order
hasHistory string Order ID customized by yourself
id string For internal purpose
lastUpdateTime string Last update time of the order
orderNo string For internal purpose
orderType integer Order type, "1:Market Order 2: Limit Order 3: Stop Order"
price string The limit price in limit and stop-limit order
quoteCurrency string Name of quote currency
rejectCode string Code specifying the reason for the reject
rejectReason string The reason for the reject
remainingQty string The quantity in an order that remain to be bought/sold
side integer "BUY" OR "SELL" the base currency, 1=Buy, 2=Sell
status integer Order status,"0:Pending-New;1:New;2:Partially-Filled; 3:Filled; 4:Cancel-Reject;5:Canceled; 6:Rejected; 7:Suspended; 8:Pending-Replace; 9:Replaced; 10:Expired; 11:Business-Reject"
stopPrice string The stop price of stop-limit order
symbol string The trading symbol to trade. Convention is "Base currency" + "Quote Currency"
totalQty string The quantity in an order
tradeTime string The time at which order was executed
txnFilledQty string The quantity in an order that have been bought/sold
userId string User id

Place Futures Order

import requests
data={'type': 'LIMIT',
      'symbol': 'BTCUSDFP',
      'quantity': 100,
      'price': 10846.2500000000,
      'baseCurrency': 'BTC',
      'quoteCurrency': 'USD',
      'side': 'BUY',
      'clientSN': 'aax_client_fp'}
response=requests.post('https://api.testnet.aax.com/exchange/v1/futures/orders',data=data,verify=True,auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {"avgPrice": "0",
          "baseCurrency": "BTC",
          "clientSN": "aax_client_fp",
          "code": "FP",
          "commission": "0",
          "createTime": "2019-06-24 08:43:23",
          "currentQty": "0",
          "execPrice": "0",
          "id": "63308001212493824",
          "leavesQty": "100",
          "leverage": "1",
          "liqType": 0,
          "margin": None,
          "marketPrice": "10846.2500000000",
          "orderNo": "i7yNQoN3y",
          "orderQty": "100",
          "orderRejReason": None,
          "orderStatus": 0,
          "orderType": 2,
          "price": "10846.2500000000",
          "quoteCurrency": "USD",
          "settleType": "INVERSE",
          "side": 1,
          "stopPrice": None,
          "symbol": "BTCUSDFP",
          "transactTime": None,
          "userId": "1019"},
 "details": None,
 "message": "success",
 "timestamp": "2019-06-24 08:43:23"}
Description

This endpoint is used for placing futures orders. See individual fields below for more details on their use.

type

timeInForce

Time in Force is a special instruction used when placing a trade to indicate how long an order will remain active before it is executed or expired.

HTTP Request

POST /exchange/v1/futures/orders

Parameters

Name Required Type Description
type Yes string Accepted values, MARKET, LIMIT, STOP-LIMIT
symbol Yes string The trading symbol to trade. Convention is "Base currency" + "Quote Currency" + "FP"
price No string The limit price in limit and stop-limit order
quantity Yes string This is the quantity of contracts you wish to buy or sell
baseCurrency Yes string Name (code) of base currency, for example, "BTC"
quoteCurrency Yes string Name of quote currency, for example, "USD"
side Yes string Direction of the trade. Long="BUY", Short="Sell" the contract
stopPrice No string Stop price of stop-limit order, only needed for stop-limit order
clientSN No string Order ID customized by yourself, The client_oid type should be comprised of alphabets + Strings or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported
timeInForce No string GTC/IOC/FOK
Output variables

liqType

General:means not normal transactions USER-CLOSE-LIQ: means the order is initiated by a user initiating position closure STOP-LIQ: means order is initiated by AAX due to liquidation

Variable Type Description
avgPrice string The average trading price
baseCurrency string Base currency in a trading pair
clientSN string Order ID customized by yourself
code string Applicable for Futures only. null for spot, "FP" for Futures
commission string Total commission paid since opening the position
createTime string The time at which order was submitted
currentQty string The value of the contracts bought/sold on this execution
execPrice string The price of this particular execution.This may be equal to or better than the order price
id string For internal purpose
leavesQty string Number of contracts in an order that remain to be bought/sold
leverage string The leverage at the time when the trade was executed
liqType string Liquidation type for futures,"0=General,1=USER-CLOSE-LIQ, 2=STOP-LIQ". "0" means not normal transactions, "1" means the order is initiated by a user initiating position closure, "2" means order is initiated by AAX due to liquidation
margin string The amount of margin locked by each position in BTC
marketPrice string The mark price for this contract, this is the price used for funding calculations
orderNo string This is AAX Order ID. You will need to quote this ID to cancel an order
orderQty string The buying or selling quantity
orderRejReason string The reason of order was rejected
orderStatus string Order status, "0=Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 7:Suspended, 8:Pending-Replace, 9:Replaced,10:Expired,11:Business-Reject"
orderType integer The type of the order,"1:Market Order 2: Limit Order 3: Stop Order"
price string The limit price in limit and stop-limit order
quoteCurrency string Quote currency in a trading pair
settleType string SINVERSE, VANILLA or QUANTO
side integer "Long" or "Short" the base currency, 1=Long, 2=Short
stopPrice string The stop price of stop-limit order
symbol string The trading symbol to trade. Convention is "Base currency" + "Quote Currency + FP"
transactTime string The time at which the trade was executed
userId string User id

Modify Futures Order

import requests
response=requests.put('https://api.testnet.aax.com/exchange/v1/futures/orders',data= {'orderNo':'lsJ3KRBq8','quantity':3},verify=True,auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {"avgPrice": "0",
          "baseCurrency": "BTC",
          "clientSN": "aax_",
          "code": "FP",
          "commission": "0",
          "createTime": "2019-07-26 13:47:22",
          "currentQty": "0",
          "execPrice": "0",
          "id": "74980910041477120",
          "leavesQty": "3",
          "leverage": "1",
          "liqType": 0,
          "margin": None,
          "marketPrice": "9775.25",
          "orderNo": "lsJ3KRBq8",
          "orderQty": "3",
          "orderRejReason": None,
          "orderStatus": 0,
          "orderType": 2,
          "price": "9000",
          "quoteCurrency": "USD",
          "settleType": "INVERSE",
          "side": 1,
          "stopPrice": "0",
          "symbol": "BTCUSDFP",
          "timeInForce": None,
          "transactTime": None,
          "userId": "5498"},
 "details": None,
 "message": "success",
 "timestamp": "2019-07-26 13:47:22"}
Description

This endpoint is used to amend the quantity or price of an open order.

HTTP Request

PUT /exchange/v1/futures/orders

Parameters

Name Required Type Description
orderNo Yes string The previously returned order id when order was created
quantity NO string The buying or selling quantity
price NO string The buying or selling price
stopPrice NO string The buying or selling stopPrice
Output variables
Variable Type Description
avgPrice string The average trading price
baseCurrency string Base currency in a trading pair
clientSN string Order ID customized by yourself
code string Applicable for Futures only. null for spot, "FP" for Futures
commission string Total commission paid since opening the position
createTime string The time at which order was submitted
currentQty string The value of the contracts bought/sold on this execution
execPrice string The price of this particular execution.This may be equal to or better than the order price
id string For internal purpose
leavesQty string Number of contracts in an order that remain to be bought/sold
leverage string The leverage at the time when the trade was executed
liqType string Liquidation type for futures,"0=General,1=USER-CLOSE-LIQ, 2=STOP-LIQ . "0" means not normal transactions, "1" means the order is initiated by a user initiating position closure, "2" means order is initiated by AAX due to liquidation
margin string The amount of margin locked by each position in BTC
marketPrice string The mark price for this contract, this is the price used for funding calculations
orderNo string This is AAX Order ID. You will need to quote this ID to cancel an order
orderQty string The buying or selling quantity
orderRejReason string The reason of order was rejected
orderStatus string Order status, "0=Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 7:Suspended, 8:Pending-Replace, 9:Replaced,10:Expired,11:Business-Reject"
orderType integer The type of the order,"1:Market Order 2: Limit Order 3: Stop Order"
price string The limit price in limit and stop-limit order
quoteCurrency string Quote currency in a trading pair
settleType string Inverse, Vanilla & Quanto
side integer "Long" or "Short" the base currency, 1=Long, 2=Short
stopPrice string The stop price of stop-limit order
symbol string The trading symbol to trade. Convention is "Base currency" + "Quote Currency + FP"
transactTime string The time at which the trade was executed
userId string User id

Cancel Futures Order

import requests
response = requests.delete('https://api.testnet.aax.com/exchange/v1/futures/orders/i7yNUnaSs', verify=True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {"avgPrice": "0",
          "baseCurrency": "BTC",
          "clientSN": None,
          "code": "FP",
          "commission": "0",
          "createTime": "2019-06-24 08:43:23",
          "currentQty": "0",
          "execPrice": "0",
          "id": "63308002152017920",
          "leavesQty": "3",
          "leverage": "1",
          "liqType": 0,
          "margin": None,
          "marketPrice": "10846.25",
          "orderNo": "i7yNUnaSs",
          "orderQty": "3",
          "orderRejReason": None,
          "orderStatus": 0,
          "orderType": 2,
          "price": "8000",
          "quoteCurrency": "USD",
          "settleType": "INVERSE",
          "side": 1,
          "stopPrice": "0",
          "symbol": "BTCUSDFP",
          "transactTime": None,
          "userId": "1019"},
 "details": None,
 "message": "success",
 "timestamp": "2019-06-24 08:43:24"}
Description

This endpoint is used to cancel an order.

HTTP Request

DELETE /exchange/v1/futures/orders/{orderNo}

Parameters

Name Required Type Description
orderNo Yes string This is AAX Order ID. You will need to quote this ID to amend an order
Output variables
Variable Type Description
avgPrice string The average trading price
baseCurrency string Base currency in a trading pair
clientSN string Order ID customized by yourself
code string Applicable for Futures only. null for spot, "FP" for Futures
commission string Total commission paid since opening the position
createTime string The time at which order was submitted
currentQty string The value of the contracts bought/sold on this execution
execPrice string The price of this particular execution.This may be equal to or better than the order price
id string For internal purpose
leavesQty string Number of contracts in an order that remain to be bought/sold
leverage string The leverage at the time when the trade was executed
liqType string Liquidation type for futures,"0=General,1=USER-CLOSE-LIQ, 2=STOP-LIQ". "0" means not normal transactions, "1" means the order is initiated by a user initiating position closure, "2" means order is initiated by AAX due to liquidation
margin string The amount of margin locked by each position
marketPrice string The mark price for this contract, this is the price used for funding calculations
orderNo string This is AAX Order ID. You will need to quote this ID to cancel an order
orderQty string The buying or selling quantity
orderRejReason string The reason of order was rejected
orderStatus string Order status, "0=Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 7:Suspended, 8:Pending-Replace, 9:Replaced,10:Expired,11:Business-Reject"
orderType integer The type of the order,"1:Market Order 2: Limit Order 3: Stop Order"
price string The limit price in limit and stop-limit order
quoteCurrency string Quote currency in a trading pair
settleType string Inverse, Vanilla & Quanto
side integer "Long" or "Short" the base currency, 1=Long, 2=Short
stopPrice string The stop price of stop-limit order
symbol string The trading symbol to trade. Convention is "Base currency" + "Quote Currency + FP"
transactTime string The time at which the trade was executed
userId string User id

Get Futures Position

import requests
response = requests.get('https://api.testnet.aax.com/exchange/v1/futures/position', verify=True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {"endRow": 1,
          "firstPage": 1,
          "hasNextPage": False,
          "hasPreviousPage": False,
          "isFirstPage": True,
          "isLastPage": True,
          "lastPage": 1,
          "list": [{
                    "avgEntryPrice": "10419.38583659597526",
                    "bankruptPrice": "11586.74707869",
                    "baseCurrency": "BTC",
                    "code": "FP",
                    "commission": "0",
                    "currentQty": "-60423",
                    "funding": "0.02556955",
                    "fundingStatus": 1,
                    "id": "121",
                    "initMargin": "0",
                    "leverage": "10",
                    "liquidationPrice": "11514",
                    "marketPrice": None,
                    "openingTimestamp": "2019-06-21 04:40:13",
                    "posState": "new",
                    "quoteCurrency": "USD",
                    "realisedPnl": "-0.01487704",
                    "riskyPrice": "11497",
                    "settleType": "INVERSE",
                    "symbol": "BTCUSDFP",
                    "unrealisedPnl": "0",
                    "userId": "1019"}],
          "navigateFirstPage": 1,
          "navigateLastPage": 1,
          "navigatePages": 8,
          "navigatepageNums": [1],
          "nextPage": 0,
          "pageNum": 1,
          "pageSize": 10,
          "pages": 1,
          "prePage": 0,
          "size": 1,
          "startRow": 1,
          "total": 1},
 "details": None,
 "message": "success",
 "timestamp": "2019-06-24 08:43:24"}
Description

This endpoint is used to get positions for all contracts.

HTTP Request

GET /exchange/v1/futures/position

Parameters

Output variables
Variable Type Description
avgEntryPrice string Average executed buy/sell price for your current long/short position
bankruptPrice string The bankruptcy price
baseCurrency string Base currency in a trading pair
code string Applicable for Futures only. null for spot, "FP" for Futures
commission string Total commission paid since opening the position
currentQty string Your current position on this instrument. If positive, you are long, if negative, short
funding string Funding amount in BTC received/paid since opening the position. Positive sign means receive
fundingStatus string The funding status, "0:settling,1:settled"
id string For internal purpose
initMargin string Initial margin rate for the position
leverage string The leverage at the time when the trade was executed
liquidationPrice string The liquidation price after the trade was processed
marketPrice string The mark price for this contract, this is the price used for funding calculations
openingTimestamp string Position creation timestamp in UTC
posState string For internal purpose
quoteCurrency string Quote currency in a trading pair
realisedPnl string Realised profit and loss since opening this position
riskyPrice string Risky price, this is for internal processing only
settleType string Inverse, Vanilla & Quanto
symbol string The trading symbol to trade. Convention is "Base currency" + "Quote Currency + FP"
unrealisedPnl string Unrealised profit and loss on this contract, and return on equity percentage
userId string User id

Cancel All Futures Order

import requests
response = requests.delete('https://api.testnet.aax.com/exchange/v1/futures/orders/cancel/all', verify=True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{
"code": 1,
 "data": None,
 "details": None,
 "message": "success",
 "timestamp": "2019-07-04 09:56:43",
 }
Description

This endpoint is used to cancel all of yours orders.

HTTP Request

DELETE /exchange/v1/futures/orders/cancel/all

Get Futures Closed Position

import requests
response = requests.get('https://api.testnet.aax.com/exchange/v1/futures/position/closed', param={'symbol': 'BTCUSDFP'}, verify=True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {"endRow": 4,
          "firstPage": 1,
          "hasNextPage": False,
          "hasPreviousPage": False,
          "isFirstPage": True,
          "isLastPage": True,
          "lastPage": 1,
          "list": [{"baseCurrency": "BTC",
                    "closeTimestamp": "2019-06-21 03:10:59",
                    "code": "FP",
                    "commission": "-0.00002674",
                    "funding": "0",
                    "globalId": 80456603949732591,
                    "id": "62137186731319296",
                    "openTimestamp": None,
                    "pnl": "0.00001421",
                    "quoteCurrency": "USD",
                    "realisedPnl": "-0.00001253",
                    "symbol": "BTCUSDFP",
                    "userId": "1019"}],
          "navigateFirstPage": 1,
          "navigateLastPage": 1,
          "navigatePages": 8,
          "navigatepageNums": [1],
          "nextPage": 0,
          "pageNum": 1,
          "pageSize": 10,
          "pages": 1,
          "prePage": 0,
          "size": 1,
          "startRow": 1,
          "total": 1},
 "details": None,
 "message": "success",
 "timestamp": "2019-06-24 08:43:24"}
Description

This endpoint is used to retrieve closed position.

HTTP Request

GET /exchange/v1/futures/position/closed

Parameters

Name Required Type Description
pageNo No integer Pagination page number, default "1"
symbol No string The trading symbol to trade. Convention is "Base currency" + "Quote Currency" + "FP"
startDate No string Search starts date, in format yyyy-mm-dd
endDate No string Search ends date, in format yyyy-mm-dd
pnlType No string The pnl type, "profit or loss"
timeZone No string Search timezone, default is UTC, e.g "8"
beforeHours No integer Search orders before n hours, e.g "8"
Output variables
Variable Type Description
baseCurrency string Base currency in a trading pair
closeTimestamp string The time which order was submitted to close
code string Applicable for Futures only. null for spot, "FP" for Futures
commission string Total commission paid or received from opening to closing the position.Positive sign means receive
funding string Total funding paid or received from opening to closing the position. Positive sign means receive
globalId string For internal purpose
id string For internal purpose
openTimestamp string The time which order was submitted to open
pnl string The retained profit and loss
quoteCurrency string Quote currency in a trading pair
realisedPnl string Realised profit and loss since opening this position
symbol string The trading symbol to trade. Convention is "Base currency" + "Quote Currency" + "FP"
userId string User id

Futures Close Position

import requests
response = requests.post('https://api.testnet.aax.com/exchange/v1/futures/position/close', data={'symbol': 'BTCUSDFP'}, verify=True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {"avgPrice": "0",
          "baseCurrency": "BTC",
          "clientSN": None,
          "code": "FP",
          "commission": "0",
          "costPrice": "9500.0000000000",
          "createTime": None,
          "currentQty": "0",
          "execPrice": "0",
          "id": None,
          "leavesQty": "10",
          "leverage": "1",
          "liqType": 1,
          "margin": None,
          "marketPrice": "9500.0000000000",
          "orderNo": "jmwdWRcyY",
          "orderQty": "10",
          "orderRejReason": None,
          "orderStatus": 0,
          "orderType": 1,
          "price": "9500.0000000000",
          "quoteCurrency": "USD",
          "reserved": "0",
          "settleType": "INVERSE",
          "side": 2,
          "stopPrice": None,
          "symbol": "BTCUSDFP",
          "timeInForce": None,
          "transactTime": None,
          "userId": "6827"},
 "details": None,
 "message": "success",
 "timestamp": "2019-07-06 07:54:14"}
Description

This endpoint is used to close position.

HTTP Request

POST /exchange/v1/futures/position/close

Parameters

Name Required Type Description
symbol Yes string The trading symbol to trade. Convention is "Base currency + Quote Currency + FP"
Output variables
Variable Type Description
avgPrice string The average trading price
baseCurrency string Base currency in a trading pair
clientSN string Order ID customized by yourself
code string Applicable for Futures only. null for spot, "FP" for Futures
commission string Total commission paid since opening the position
createTime string The time at which order was submitted
currentQty string The value of the contracts bought/sold on this execution
execPrice string The price of this particular execution.This may be equal to or better than the order price
id string For internal purpose
leavesQty string Number of contracts in an order that remain to be bought/sold
leverage string The leverage at the time when the trade was executed
liqType string Liquidation type for futures,"0=General,1=USER-CLOSE-LIQ, 2=STOP-LIQ". "0" means not normal transactions, "1" means the order is initiated by a user initiating position closure, "2" means order is initiated by AAX due to liquidation
margin string The amount of margin locked by each position
marketPrice string The mark price for this contract, this is the price used for funding calculations
orderNo string This is AAX Order ID. You will need to quote this ID to cancel an order
orderQty string The buying or selling quantity
orderRejReason string The reason of order was rejected
orderStatus string Order status, "0=Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 7:Suspended, 8:Pending-Replace, 9:Replaced,10:Expired,11:Business-Reject"
orderType integer The type of the order,"1:Market Order 2: Limit Order 3: Stop Order"
price string The limit price in limit and stop-limit order
quoteCurrency string Quote currency in a trading pair
settleType string Inverse, Vanilla & Quanto
side integer "Long" or "Short" the base currency, 1=Long, 2=Short
stopPrice string The stop price of stop-limit order
symbol string The trading symbol to trade. Convention is "Base currency" + "Quote Currency + FP"
transactTime string The time at which the trade was executed
userId string User id

Futures Choose Leverage

import requests
response = requests.post('https://api.testnet.aax.com/exchange/v1/futures/position/leverage', data={'symbol': 'BTCUSDFP', 'leverage': 10}, verify=True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {
          "avgEntryPrice": "10419.38583659597526",
          "bankruptPrice": "12116.4389785842",
          "baseCurrency": "BTC",
          "code": "FP",
          "commission": "0",
          "currentQty": "-60423",
          "funding": "0.02556955",
          "fundingStatus": 1,
          "id": "121",
          "initMargin": "0",
          "leverage": "10",
          "liquidationPrice": "12037",
          "marketPrice": None,
          "openingTimestamp": "2019-06-21 04:40:13",
          "posState": "new",
          "quoteCurrency": "USD",
          "realisedPnl": "-0.01487704",
          "riskyPrice": "12018.5",
          "settleType": "INVERSE",
          "symbol": "BTCUSDFP",
          "unrealisedPnl": "0",
          "userId": "1019"},
 "details": None,
 "message": "success",
 "timestamp": "2019-06-24 08:43:25"}
Description

This endpoint is used to setup leverage for position.

HTTP Request

POST /exchange/v1/futures/position/leverage

Parameters

Name Required Type Description
symbol Yes string The trading symbol to trade. Convention is "Base currency" + "Quote Currency" + "FP"
leverage Yes number 1-100x leverage, e.g "10"
Output variables
Variable Type Description
avgEntryPrice string Average executed buy/sell price for your current long/short position
bankruptPrice string The bankruptcy price
baseCurrency string Base currency in a trading pair
code string Applicable for Futures only. null for spot, "FP" for Futures
commission string Total commission paid since opening the position
currentQty string Your current position on this instrument. If positive, you are long, if negative, short
funding string Funding amount in BTC received/paid since opening the position. Positive sign means receive
fundingStatus string The funding status, "0:settling,1:settled"
id string For internal purpose
initMargin string Initial margin rate for the position
leverage string The leverage at the time when the trade was executed
liquidationPrice string The liquidation price after the trade was processed
marketPrice string The mark price for this contract, this is the price used for funding calculations
openingTimestamp string Position creation timestamp in UTC
posState string For internal purpose
quoteCurrency string Quote currency in a trading pair
realisedPnl string Realised profit and loss since opening this position
riskyPrice string Risky price, this is for internal processing only
settleType string Inverse, Vanilla & Quanto
symbol string The trading symbol to trade. Convention is "Base currency" + "Quote Currency + FP"
unrealisedPnl string Unrealised profit and loss on this contract, and return on equity percentage
userId string User id

Query Futures Order Detail

import requests
response = requests.get('https://api.testnet.aax.com/exchange/v1/futures/trades', params={'symbol': 'BTCUSDFP'}, verify=True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {"endRow": 10,
          "firstPage": 1,
          "hasNextPage": True,
          "hasPreviousPage": False,
          "isFirstPage": True,
          "isLastPage": False,
          "lastPage": 8,
          "list": [{"baseCurrency": "BTC",
                    "commission": "-0.00000007",
                    "executedPrice": "10712.5",
                    "executedQuantity": "3",
                    "executionType": None,
                    "filledOrderStatus": 2,
                    "id": "63048159520485376",
                    "leavesQuantity": "547",
                    "leverage": None,
                    "liqType": 0,
                    "liquidationPrice": None,
                    "margin": "0",
                    "orderNo": "i2WxRf0Ag",
                    "orderType": 2,
                    "quoteCurrency": "USDT",
                    "realisedPnl": "-0.00000788",
                    "side": 1,
                    "symbol": "BTCUSDFP",
                    "transactTime": "2019-06-23 15:29:40",
                    "userId": "1019"},...],
           "navigateFirstPage": 1,
          "navigateLastPage": 8,
          "navigatePages": 8,
          "navigatepageNums": [1, 2, 3, 4, 5, 6, 7, 8],
          "nextPage": 2,
          "pageNum": 1,
          "pageSize": 10,
          "pages": 26,
          "prePage": 0,
          "size": 10,
          "startRow": 1,
          "total": 260},
 "details": None,
 "message": "success",
 "timestamp": "2019-06-24 08:43:25"}
Description

This endpoint is used to retrieve trade details of an order.

HTTP Request

GET /exchange/v1/futures/trades

Parameters

Name Required Type Description
pageNo No integer Pagination page number, default "1"
pageSize No string Pagination page size, default "10"
clientOrderNo NO string This is AAX Order ID. You will need to quote this ID to cancel or amend an order
symbol No string The trading symbol to trade. Convention is "Base currency" + "Quote Currency" + "FP"
baseCurrency No string Name (code) of base currency, for example, "BTC"
quoteCurrency No string Name (code) of quote currency, for example, "USDT"
startDate No string Search starts date, in format yyyy-mm-dd
endDate No string Search ends date, in format yyyy-mm-dd
side No string Filter on the direction of the trade, "BUY" or "SELL", Long="BUY", Short="SELL"
orderType No string The types of order to include in the search,MARKET, LIMIT,STOP-LIMIT
timeZone No string Search timezone, default is UTC
Output variables
Variable Type Description
baseCurrency string Base currency in a trading pair
commission string Total commission paid since opening the position
executedPrice string Calculated average price of all fills in this order
executedQuantity string Number of contracts in an order that have been bought/sold. If the order has completed, this is equal to the quantity
filledOrderStatus integer Order status,"0:Pending-New;1:New;2:Partially-Filled; 3:Filled; 4:Cancel-Reject;5:Canceled; 6:Rejected; 7:Suspended; 8:Pending-Replace; 9:Replaced; 10:Expired; 11:Business-Reject"
id string For internal purpose
leavesQuantity string Number of contracts in an order that remain to be bought/sold
leverage string The leverage at the time when the trade was executed
liqType integer Liquidation type for futures,"0=General,1=USER-CLOSE-LIQ, 2=STOP-LIQ". "0" means not normal transactions, "1" means the order is initiated by a user initiating position closure, "2" means order is initiated by AAX due to liquidation
liquidationPrice string The liquidation price after the trade was processed
margin string The amount of margin locked by each position
orderNo string This is AAX Order ID. You will need to quote this ID to cancel or amend an order
orderType integer Order type,"1:Market Order 2: Limit Order 3: Stop Order
quoteCurrency string Quote currency in a trading pair
realisedPnl string Realised profit and loss since opening this position
side integer "Long" or "Short" the base currency, 1=Long, 2=Short
symbol string The trading symbol to trade. Convention is "Base currency + Quote Currency + FP"
transactTime string The time at which the trade was executed
userId string User id

Query Futures Historical Order(s)

import requests
response = requests.post('https:/api.testnet.aax.com/exchange/v1/futures/orders', params={'symbol': 'BTCUSDFP', 'searchType': 0}, verify=True, auth=auth).json()
print(response)

The above command returns JSON structured like this:

{"code": 1,
 "data": {"endRow": 2,
          "firstPage": 1,
          "hasNextPage": False,
          "hasPreviousPage": False,
          "isFirstPage": True,
          "isLastPage": True,
          "lastPage": 1,
          "list": [{"avgPrice": "0",
                    "baseCurrency": "BTC",
                    "clientSN": None,
                    "code": "FP",
                    "commission": "0",
                    "createTime": "2019-06-24 08:43:23",
                    "currentQty": "0",
                    "execPrice": "0",
                    "id": "63308002152017920",
                    "leavesQty": "3",
                    "leverage": "1",
                    "liqType": 0,
                    "margin": None,
                    "marketPrice": "10846.25",
                    "orderNo": "i7yNUnaSs",
                    "orderQty": "3",
                    "orderRejReason": None,
                    "orderStatus": 0,
                    "orderType": 2,
                    "price": "8000",
                    "quoteCurrency": "USD",
                    "settleType": "INVERSE",
                    "side": 1,
                    "stopPrice": "0",
                    "symbol": "BTCUSDFP",
                    "transactTime": None,
                    "userId": "1019"},...]
           "navigateFirstPage": 1,
          "navigateLastPage": 1,
          "navigatePages": 8,
          "navigatepageNums": [1],
          "nextPage": 0,
          "pageNum": 1,
          "pageSize": 10,
          "pages": 1,
          "prePage": 0,
          "size": 2,
          "startRow": 1,
          "total": 2},
 "details": None,
 "message": "success",
 "timestamp": "2019-06-24 08:43:26"}
Description

This endpoint is used to retrieve historical orders.

HTTP Request

GET /exchange/v1/futures/orders

Parameters

Name Required Type Description
searchType No integer The states of order to include in the search,0:Open order and Partial order;1:Filled order and Cancel order
pageNo No integer Pagination page number, default "1"
pageSize No string Pagination page size, default "10"
symbol No string The trading symbol to trade. Convention is "Base currency" + "Quote Currency" + "FP"
clientOrderNo No string This is AAX Order ID. You will need to quote this ID to cancel or amend an order
baseCurrency No string Name (code) of base currency, for example, "BTC"
quoteCurrency No string Name (code) of quote currency, for example, "USDT"
status No integer The states of order to include in the search, '1:new;2:filled;3:cancel'
startDate No string Search starts date, in format yyyy-mm-dd
endDate No string Search ends date, in format yyyy-mm-dd
orderType No string The types of order to include in the search,MARKET, LIMIT, STOP-LIMIT
side No string Filter on the direction of the trade, "BUY" or "SELL", Long="BUY", Short="SELL"
orderType No string The types of order to include in the search,MARKET, LIMIT,STOP-LIMIT
timeZone No string Search timezone, default is UTC
clientSN No string Order ID customized by yourself , The client_oid type should be comprised of alphabets + Strings or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported
Output variables
Variable Type Description
avgPrice string The average trading price
baseCurrency string Base currency in a trading pair
clientSN string Order ID customized by yourself
code string Applicable for Futures only. null for spot, "FP" for Futures
commission string Total commission paid since opening the position
createTime string The time at which order was submitted
currentQty string The value of the contracts bought/sold on this execution
execPrice string The price of this particular execution.This may be equal to or better than the order price
id string For internal purpose
leavesQty string Number of contracts in an order that remain to be bought/sold
leverage string The leverage at the time when the trade was executed
liqType string Liquidation type for futures,"0=General,1=USER-CLOSE-LIQ, 2=STOP-LIQ"."0" means not normal transactions, "1" means the order is initiated by a user initiating position closure, "2" means order is initiated by AAX due to liquidation
margin string The amount of margin locked by each position
marketPrice string The mark price for this contract, this is the price used for funding calculations
orderNo string This is AAX Order ID. You will need to quote this ID to cancel an order
orderQty string The buying or selling quantity
orderRejReason string The reason of order was rejected
orderStatus string Order status, "0=Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 7:Suspended, 8:Pending-Replace, 9:Replaced,10:Expired,11:Business-Reject"
orderType integer The type of the order,"1:Market Order 2: Limit Order 3: Stop Order"
price string The limit price in limit and stop-limit order
quoteCurrency string Quote currency in a trading pair
settleType string Inverse, Vanilla & Quanto
side integer "Long" or "Short" the base currency, 1=Long, 2=Short
stopPrice string The stop price of stop-limit order
symbol string The trading symbol to trade. Convention is "Base currency" + "Quote Currency + FP"
transactTime string The time at which the trade was executed
userId string User id

Websocket

Overview

WebSocket endpoint provides real-time market data streaming which works in Subscribe-Publish communication model.

Endpoints

Production endpoint, requires or not API key for authentication and providing real data:

wss://stream.testnet.aax.com

Message encoding

Each message sent and received via the AAX's websocket channel is encoded in JSON format.

Public Streams

Authenticated Streams

Authentication

If you wish to subscribe to user-locked streams, you must authenticate first. Note that invalid authentication will break the current authentication. As same as RESTFul API, You need login, and generate an API Key.

sample message like: {"event":"login","data":{"apiKey":"e04019b***","nonce":1557386524650,"signature":"114422***"}}

Rate Limits

Public Endpoints

Orderbook

import websocket

def on_message(ws, message):
    print(message)

def on_error(ws, error):
    print(error)

def on_close(ws):
    print("Connection closed")

if __name__ == "__main__":
    websocket.enableTrace(True)
    ws = websocket.WebSocketApp( 'wss://stream.testnet.aax.com/marketdata/v1/orderbooks/BTCUSDT@book_50',
                                on_message=on_message,
                                on_error=on_error,
                                on_close=on_close)
    ws.run_forever(ping_timeout=30)

The above command returns JSON structured like this:

{
"asks":[["10823.00000000","0.004000"],["10823.10000000","0.100000"],["10823.20000000","0.010000"]],
 "bids":[["10821.20000000","0.002000"],["10821.10000000","0.005000"],["10820.40000000","0.013000"]],
 "e":"BTCUSDT@book_50",
 "t":1561543614756,
 }

Snapshots of the top N1 bids and asks, update every N2 milliseconds.

Message variable
Variable Description Type
e Event name string
t Event time milliseconds
asks Asks to be updated list
bids Bids to be updated list

Trades

import websocket

def on_message(ws, message):
    print(message)

def on_error(ws, error):
    print(error)

def on_close(ws):
    print("Connection closed")

if __name__ == "__main__":
    websocket.enableTrace(True)
    ws = websocket.WebSocketApp( 'wss://stream.testnet.aax.com/marketdata/v1/trades/BTCUSDT@trade',
                                on_message=on_message,
                                on_error=on_error,
                                on_close=on_close)
    ws.run_forever(ping_timeout=30)

Trade message JSON is structured like this::

{
"e":"BTCUSDT@trade",
 "p":"10924.30000000",
 "q":"0.002000",
 "t":1561445393223,
 }

For each new connection, our server sends the last 50 trades to it. There is a rate limit on how many trades our server will send to clients.

Message variable
Variable Description Type
e Event name string
t Event time milliseconds
p Price(Buy: postitive, Sell: negative, e.g -6573.2 for Sell) string
q Quantity string

Tickers

import websocket

def on_message(ws, message):
    print(message)

def on_error(ws, error):
    print(error)

def on_close(ws):
    print("Connection closed")

if __name__ == "__main__":
    websocket.enableTrace(True)
    ws = websocket.WebSocketApp( 'wss://stream.testnet.aax.com/marketdata/v1/tickers',
                                on_message=on_message,
                                on_error=on_error,
                                on_close=on_close)
    ws.run_forever(ping_timeout=30)

Ticker message JSON is structured like this::

{
"e":"tickers",
"tickers":[{
            "c":"0.05050010",
             "h":"0.05050010",
             "l":"0.05050010",
             "o":"0.05050010",
             "s":"BCHABCBTCFP",
             "v":"0.00000000",
             },
             {
              "c":"0.00004780",
              "h":"0.00004780",
              "l":"0.00004780",
              "o":"0.00004780",
              "s":"XRPBTCFP", 
              "v":"0.00000000"}
             ]
}

It contains open, high, low, close and volume of the last 24 hrs. Server initially sends all the tickers to client immediately after connected, and then it sends only the tickers that are changed since the last update every N seconds.

Message variable
Variable Description Type
e Event name string
s Symbol string
o Open price string
h High price string
l Low price string
c Close price string
v Quote volume string

Candlesticks

import websocket

def on_message(ws, message):
    print(message)

def on_error(ws, error):
    print(error)

def on_close(ws):
    print("Connection closed")

if __name__ == "__main__":
    websocket.enableTrace(True)
    ws = websocket.WebSocketApp( 'wss://stream.testnet.aax.com/marketdata/v1/candles/BTCUSDT@1m_candles',
                                on_message=on_message,
                                on_error=on_error,
                                on_close=on_close)
    ws.run_forever(ping_timeout=30)

Candlesticks message JSON is structured like this::

{
 "c":"10821.30000000",
 "e":"BTCUSDT@1m_candles",
 "h":"10821.30000000",
 "l":"10821.30000000",
 "o":"10821.30000000",
 "s":1561543560,
 "t":1561543560,
 "v":"0.00000000",
 }

Real-time candlesticks.

Message variable
Variable Description Type
e Event name string
t Event time string
h High price string
l Low price string
o Open price string
s Start time of the candlestick(seconds) string
v Trade volume string
c Close price string

Authenticated Endpoints

Notification

from socketclusterclient import Socketcluster
import hmac
import hashlib
import time
import json

API_KEY = 'YOUR API KEY HERE'
API_SECRET = 'YOUR API SECRET HERE'
USER_ID = 'YOUR USER ID HERE'

def onconnect(socket):
    print("on connect got called")
    socket.subscribe("public")
    nonce = str(int(1000 * time.time()))
    message = nonce + ':' + API_KEY
    signature = hmac.new(API_SECRET.encode(), message.encode(), hashlib.sha256).hexdigest()
    socket.emit("login", {"apiKey": API_KEY, "nonce": nonce, "signature": signature})

def ondisconnect(socket):
    print("on disconnect got called")

def onConnectError(socket, error):
    print("On connect error got called")

def onSetAuthentication(socket, token):
    print("Token received " + token)
    socket.subscribe("user/"+USER_ID)

def onAuthentication(socket, isauthenticated):
    print("Authenticated is " + str(isauthenticated))

def onChannelMsg(key, msg):
    print('Channel: [' + key + ']' + json.dumps(msg))

if __name__ == "__main__":
    socket = Socketcluster.socket("wss://stream.testnet.aax.com/notification/v1/")
    socket.setBasicListener(onconnect, ondisconnect, onConnectError)
    socket.setAuthenticationListener(onSetAuthentication, onAuthentication)
    socket.onchannel('public', onChannelMsg)
    socket.onchannel("user/"+USER_ID, onChannelMsg)
    socket.connect()

The above command returns JSON structured like this:


more detail, see SocketCluster Client.

Channel & Event
Type Channel Event Description Sample Message
Public public PRICE avg/exchange avg exchange
Private user/{USER ID} USER_BALANCE user-balance
Private user/{USER_ID} USER_PROFILE user-profile
Private user/{USER ID} TRADE_ORDER for Spot spot
Private user/{USER ID} FUTURES for Futures futures