NAV Navbar
shell python

Introduction

Connect your custom trading applications and strategies to AAX via our feature-rich API.

The REST endpoints offer you secure access to manage your orders and positions. Low-latency WebSocket channels are also available for you to subscribe to market data, your orders status and more.

You will also find code samples in Shell and Python alongside our documentation to guide you through your implementation.

Change Log

2020.10.16

New

Improvements

2020.09.01

New

2020.08.15

New

2020.07.20

New

Improvements

2020.07.08

New

Improvements

2020.06.12

Improvements

2020.04.30

New

2020.04.28

New

2020.03.23

New

2020.02.24

New

Improvements

2019.12.11

New

Improvements

API Key

The API key and the API secret are required to access the authenticated part of the API. You can generate as many API keys as you need on this page. Below table shows the different permissions you can set for each API key.

Permissions Read Write
Account info Default --
Spot Trading Default Optional
Futures Trading Default Optional

By default, API keys have read-only access to user data such as positions, margins, orders and executions. In order to be able to send and manage orders, please set “Spot Trading” and/or “Futures Trading” to “Write”.

REST

Overview

RESTful endpoints provide a wide range of data using HTTPS, a secure request-response protocol.

Endpoints

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

Public Endpoints

Public endpoints are available to retrieve data, such as instrument details, without authentication.

Private Endpoints

Private endpoints are available for order management and retrieving account details such as positions. To use private endpoints, you must authenticate using your API keys.

Authentication

To authenticate using your API key, 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()))
        strBody = request.body.decode() if request.body else ''
        message = nonce + ':' + request.method + request.path_url + (strBody 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 SecretAPIKey secured. When you are logged in, please follow the link to manage your active keys.

Authentication is done by sending the following HTTP headers:

X-ACCESS-KEY: Your public API key.

X-ACCESS-NONCE: A UNIX timestamp in milliseconds after which the request is no longer valid. This is to prevent replay attacks.

X-ACCESS-SIGN: Signature for your API request. It is calculated as follows: HEX(HMAC_SHA256(apiSecret, str(nonce) + ':' + verb + path + data)). The data part of the HMAC construction should be exactly equal to the raw message body you wish to send to the server and needs to be a JSON-encoded.

In order to check if your signature calculation is correct, try the inputs in the following examples and see if the results match:

# Below apiKey and apiSecret are just examples for testing purpose
import hmac, hashlib
apiKey = 'a0R6FlTcxM6IidDB9GCQPkkktU'
apiSecret = 'ce353da330bc73ef5cfbc85c70a5cf96'


# GET
verb = 'GET'
path = '/v2/futures/orders?symbol=BTCUSDFP'
expires = 1573617003403 # 2019-11-13T03:50:03.403Z
data = ''

# HEX(HMAC_SHA256(apiSecret, '1573617003403:GET/v2/futures/orders?symbol=BTCUSDFP'))
# Result is: 'cad62d62f09c142ab05c01418483b5a66090f107c002c45d072013aa95a63655'
signature = hmac.new(apiSecret.encode(), (str(expires) + ':' + verb + path + data).encode(), hashlib.sha256).hexdigest()


# POST
verb = 'POST'
path = '/v2/spot/orders'
expires = 1573617153689 # 2019-11-13T03:52:53.689Z
data = '{"orderType": "MARKET", "symbol": "BTCUSDT", "orderQty": 0.02, "side": "BUY"}'

# HEX(HMAC_SHA256(apiSecret, '1573617153689:POST/v2/spot/orders{"orderType": "MARKET", "symbol": "BTCUSDT", "orderQty": 0.02, "side": "BUY"}'
# Result is: '7beec00f1f10ad3351eaaad72764e494ddba6a45cdc949cfd33dcedc451656ae'
signature = hmac.new(apiSecret.encode(), (str(expires) + ':' + verb + path + data).encode(), hashlib.sha256).hexdigest()


# PUT
verb = 'PUT'
path = '/v2/spot/orders'
expires = 1573617359274 # 2019-11-13T03:55:59.274Z
data = '{"orderID": "wPy5no0Rr", "orderQty": 0.05}'

# HEX(HMAC_SHA256(apiSecret, '1573617359274:PUT/v2/spot/orders{"orderID": "wPy5no0Rr", "orderQty": 0.05}'
# Result is: '1492cbdf1c0b63756ad081851ba88db84e381f3d8b6a611edd81ec1c0a96c17d'
signature = hmac.new(apiSecret.encode(), (str(expires) + ':' + verb + path + data).encode(), hashlib.sha256).hexdigest()


# DELETE
verb = 'DELETE'
path = '/v2/spot/orders/cancel/all'
expires = 1573617359532 # 2019-11-13T03:55:59.3532Z
data = '{"symbol": "BTCUSDT"}'

# HEX(HMAC_SHA256(apiSecret, '1573617359532:DELETE/v2/spot/orders/cancel/all{"symbol": "BTCUSDT"}'
# Result is: '60213445ca0f7e08b16c6dd0f1172f32a0effba1c74077e408e34b54424ebeda'
signature = hmac.new(apiSecret.encode(), (str(expires) + ':' + verb + path + data).encode(), hashlib.sha256).hexdigest()
# Below apiKey and apiSecret are just examples for testing purpose
#!/usr/bin/env bash

apiKey='a0R6FlTcxM6IidDB9GCQPkkktU'
apiSecret='ce353da330bc73ef5cfbc85c70a5cf96'


# GET
verb='GET'
path='/v2/futures/orders?symbol=BTCUSDFP'
expires=1573617003403 # 2019-11-13T03:50:03.403Z
data=''

# HEX(HMAC_SHA256(apiSecret, '1573617003403:GET/v2/futures/orders?symbol=BTCUSDFP'))
# Result is: 'cad62d62f09c142ab05c01418483b5a66090f107c002c45d072013aa95a63655'
signature=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${apiSecret}`


# POST
verb='POST'
path='/v2/spot/orders'
expires=1573617153689 # 2019-11-13T03:52:53.689Z
data={"orderType": "MARKET", "symbol": "BTCUSDT", "orderQty": 0.02, "side": "BUY"}

# HEX(HMAC_SHA256(apiSecret, '1573617153689:POST/v2/spot/orders{"orderType": "MARKET", "symbol": "BTCUSDT", "orderQty": 0.02, "side": "BUY"}'
# Result is: '7beec00f1f10ad3351eaaad72764e494ddba6a45cdc949cfd33dcedc451656ae'
signature=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${apiSecret}`


# PUT
verb='PUT'
path='/v2/spot/orders'
expires=1573617359274 # 2019-11-13T03:55:59.274Z
data={"orderID": "wPy5no0Rr", "orderQty": 0.05}

# HEX(HMAC_SHA256(apiSecret, '1573617359274:PUT/v2/spot/orders{"orderID": "wPy5no0Rr", "orderQty": 0.05}'
# Result is: '1492cbdf1c0b63756ad081851ba88db84e381f3d8b6a611edd81ec1c0a96c17d'
signature=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${apiSecret}`


# DELETE
verb = 'DELETE'
path = '/v2/spot/orders/cancel/all'
expires = 1573617359532 # 2019-11-13T03:55:59.3532Z
data = {"symbol": "BTCUSDT"}

# HEX(HMAC_SHA256(apiSecret, '1573617359532:DELETE/v2/spot/orders/cancel/all{"symbol": "BTCUSDT"}'
# Result is: '60213445ca0f7e08b16c6dd0f1172f32a0effba1c74077e408e34b54424ebeda'
signature=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${apiSecret}`

HTTP Request

Each HTTP request must contain the header Accept: application/json.

HTTP Responses

All the responses are returned in JSON format.

HTTP Success

Successful HTTP responses have the status code 200. Examples of responses are provided for each endpoint in the documentation.

HTTP Errors

All HTTP requests with response status code not equal to 200 must be considered as failed. Below is the list of errors you may find in the response body if your request fails:

Error Code Meaning
400 Bad Request – There is something wrong with your request
401 Unauthorized – Your API key or signature is wrong
403 Forbidden – Your API key does not 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 data that is not available at this moment

Rate Limits

Request rate limit for each endpoint for a given API key:

API Per Second Per Minute Per Hour
Cancel Spot Order 20 200 6000
Cancel Futures Order 20 200 6000
Cancel All Spot Orders 2 30 600
Cancel All Futures Orders 2 30 600
Close Futures Position 2 30 600
Update Futures position Leverage 15 200
All Other Authenticated Endpoints 10 150 5000

Market Data

Method Path Description
GET /v2/announcement/maintenance System Maintenance Notice
GET /v2/instruments Retrieve all trading pairs information
GET /v2/market/orderbook Order Book
GET /v2/futures/position/openInterest Open Interest
GET /v2/market/tickers Get the Last 24h Market Summary
GET /v2/market/candles Get Current Candlestick
GET /v2/market/trades Get the Most Recent Trades
GET /v2/market/markPrice Get Current Mark Price
GET /v2/futures/funding/predictedFunding/{symbol} Get Predicted Funding Rate
GET /v2/futures/funding/prevFundingRate/{symbol} Get Last Funding Rate
GET /v2/market/candles/index Get Current Index Candlestick

System Maintenance Notice

Description

This endpoint returns information related to planned and ongoing system maintenance.

HTTP Request
import requests

response = requests.get('https://api.aax.com/v2/announcement/maintenance').json()
print(response)
domain="https://api.aax.com"
path="/v2/announcement/maintenance"
verb="GET"
output=`curl -s -H "accept: application/json;charset=UTF-8" -X ${verb} "${domain}${path}"`
echo "result: $output"

GET /v2/announcement/maintenance

Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "startTime":"2020-06-25T02:15:00.000Z",
      "endTime":"2020-06-25T02:45:00.000Z"
      "description":"Spot Trading :UTC Jun 25, 2020 02:15 to 02:45 (HKT Jun 25 10:15 to 10:45),Futures Trading: UTC Jun 25, 2020 02:15 to 02:45 (HKT Jun 25 10:15 to 10:45).We apologize for any inconvenience caused. Thank you for your patience and understanding.Should you have any enquiries, please do not hesitate our live chat support or via email at cs@aax.com."
    }
   "message":"success",
   "ts":1593043237000
}
Variable Data Type Description
startTime String Estimated start time of system maintenance
endTime String Estimated end time of system maintenance
description String System maintenance information

Instruments

Description

This endpoint is used to retrieve information for all the instruments.

HTTP Request
import requests

response = requests.get('https://api.aax.com/v2/instruments').json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
path="/v2/instruments"
verb="GET"
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -X ${verb} "${domain}${path}"`
echo "result: $output"

GET /v2/instruments

Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":[
      {
         "tickSize":"0.1",
         "lotSize":"0.0001",
         "base":"BTC",
         "quote":"USDT",
         "settleType":null,
         "settleCurrency":null,
         "minQuantity":"0.0010000000",
         "maxQuantity":"999900.0000000000",
         "minPrice":"0.1000000000",
         "maxPrice":"10000000.0000000000",
         "status":"enable",
         "symbol":"BTCUSDT",
         "code":null,
         "takerFee":"0.00000",
         "makerFee":"0.00000",
         "multiplier":"1.000000000000",
         "mmRate":"0.02500",
         "imRate":"0.05000",
         "type":"spot"
      },
      ...
   ],
   "message":"success",
   "ts":1573561743499
}
Variable Data Type Description
tickSize String Minimum price movement for this specific instrument
lotSize String The intervals that a quantity can be increased/decreased by
base String Base Currency in a trading pair
quote String Quote Currency in a trading pair
settleType String Settlement type (INVERSE, VANILLA or QUANTO) More details on Settlement types.
settleCurrency String Settlement currency
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/stopPrice allowed
maxPrice String Maximum price/stopPrice allowed
status String Status of the trading pair (enable, disable or readonly)
symbol String The trading symbol to trade. For spot, convention is 'Base Currency + Quote Currency', i.e. BTCUSDT; for futures, convention is 'Base Currency + Quote Currency +FP', i.e. BTCUSDTP
code String Applicable for futures only. 'FP' for perpetual futures, null for spot
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
type String Trading pairs type i.e. spot or futures

Order Book

import requests

params = {"symbol": "BTCUSDFP", "level": 20}
response = requests.get('https://api.aax.com/v2/market/orderbook', params=params).json()
print(response)
domain="https://api.aax.com"
path="/v2/market/orderbook?symbol=BTCUSDFP&level=20"
verb="GET"

output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -X ${verb} "${domain}${path}"`

echo "result: $output"
Functional description

This endpoint allows you to retrieve the current order book for a specific symbol.

HTTP Request

GET /v2/market/orderbook

Parameters
Parameter Required Data Type Default Description
symbol Yes String The trading symbol to trade. For spot, convention is 'Base Currency + Quote Currency', i.e. BTCUSDT; for futures, convention is 'Base Currency + Quote Currency +FP', i.e. BTCUSDTP
level Yes Integer depth.Support 20, 50
Message Variable

The above command returns JSON structured like this:

{
   "asks":[
      [
         "10823.00000000", #price
         "0.004000"  #size
      ],
      [
         "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
}
Variable Data Type Description
e String Event name
t Integer Event time (unit: milliseconds)
asks Array List of asks currently in orderbook[price, size]
bids Array List of bids currently in orderbook[price, size]

Open Interest

Description

The endpoint allows you retrieve the current open interest for a specific symbol.

HTTP Request

GET /v2/futures/position/openInterest

Query String Parameters
import requests

params = {
            "symbol": "BTCUSDFP"
          }
response = requests.get('https://api.aax.com/v2/futures/position/openInterest', params=params).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
path="/v2/futures/position/openInterest?symbol=BTCUSDFP"
verb="GET"
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -X ${verb} "${domain}${path}"`
echo "result: $output"
Name Required Data Type Description
symbol Yes String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "symbol":"BTCUSDFP",
      "openInterest":"1034600",
      "openInterestUSD":"1034600"
   },
   "message":"success",
   "ts":1573542445411
}
Variable Data Type Description
openInterest String Number of contracts in open interest
openInterestUSD String Open interest in USD value
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'

Get the Last 24h Market Summary

import requests

response = requests.get('https://api.aax.com/v2/market/tickers').json()
print(response)
domain="https://api.aax.com"
path="/v2/market/tickers"
verb="GET"

output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -X ${verb} "${domain}${path}"`

echo "result: $output"
Functional description

This endpoint allows you to retrieve the trading summary for all the symbols over the past 24 hours.

HTTP Request

GET /v2/market/tickers

Message Variable

The above command returns JSON structured like this:

{
 e: "tickers",
 t: 1592568022678,
 tickers:
 [
  {
   a: "0.00000000",
   c: "52.50000000",
   d: "-0.94339623",
   h: "53.00000000",
   l: "50.80000000",
   o: "53.00000000",
   s: "ZECUSDT",
   v: "42525.11699994"
},
 {
  a: "0.00000000",
  c: "0.00000222",
  d: "-5.53191489",
  h: "0.00000236",
  l: "0.00000216",
  o: "0.00000235",
  s: "ZILBTC",
  v: "5.84912230"
},
   ]
}
Variable Data Type Description
e String Event name
t Integer Event time (unit: milliseconds)
s String The trading symbol to trade. For spot, convention is 'Base Currency + Quote Currency', i.e. BTCUSDT; for futures, convention is 'Base Currency + Quote Currency +FP', i.e. BTCUSDTP
o String Open price
h String High price
l String Low price
c String Close price
v String The trading volume in quote currency of last 24 hours
a String The trading volume in USD in the last 24 hours(only support Futures)

Get Current Candlestick

import requests

params = {"symbol": "BTCUSDFP", "timeFrame": "1m"}
response = requests.get('https://api.aax.com/v2/market/candles', params=params).json()
print(response)
domain="https://api.aax.com"
path="/v2/market/candles?symbol=BTCUSDFP&timeFrame=1m"
verb="GET"

output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -X ${verb} "${domain}${path}"`

echo "result: $output"
Functional description

This endpoint allows you to retrieve candlestick data for a specific symbol.

HTTP Request

GET /v2/market/candles

Parameters
Parameter Required Data Type Default Description
symbol Yes String The trading symbol to trade. For spot, convention is 'Base Currency + Quote Currency', i.e. BTCUSDT; for futures, convention is 'Base Currency + Quote Currency +FP', i.e. BTCUSDTP
timeFrame Yes String The period of each candlesticks , 1m, 3m, 5m, 15m, 30m, 1h, 2h, 3h, 4h, 8h, 1d
Message Variable

The above command returns JSON structured like this:

{
   c: "9308.34000000",
   e: "BTCUSDT@1m_candles",
   h: "9316.97000000",
   l: "9304.82000000",
   o: "9304.82000000",
   s: 1592548440,
   t: 1592548470,
   v: "4806.98608000"
}
Variable Data Type Description
e String Event name
t Integer Event time (unit: milliseconds)
h String High price
l String Low price
o String Open price
s Integer Start time of the candlestick(seconds)
v String Trade volume
c String Close price

Get the Most Recent Trades

import requests

params = {"symbol": "BTCUSDFP", "limit": 2}
response = requests.get('https://api.aax.com/v2/market/trades', params=params).json()
print(response)
domain="https://api.aax.com"
path="/v2/market/trades?symbol=BTCUSDFP&limit=2"
verb="GET"

output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -X ${verb} "${domain}${path}"`

echo "result: $output"
Functional description

This endpoint allows you to retrieve the most recent trades(up to last 2000)

HTTP Request

GET /v2/market/trades

Parameters
Parameter Required Data Type Default Description
symbol Yes String The trading symbol to trade. For spot, convention is 'Base Currency + Quote Currency', i.e. BTCUSDT; for futures, convention is 'Base Currency + Quote Currency +FP', i.e. BTCUSDTP
limit Yes Integer Number of trade records. Max 2000
Message Variable

The above command returns JSON structured like this:

{
  "e":"BTCUSDFP@trades",
  "trades":
      [ { "p":"9395.50000000",
         "q":"50.000000",
         "t":1592563996718
       },
      {  "p":"9395.50000000",
         "q":"50.000000",
         "t":1592563993577
      }]
}
Variable Data Type Description
e String Event name
t Integer Event time (unit: milliseconds)
p String Price (Positive for Buy, Negative for Sell, e.g. -6573.2 for Sell)
q String Quantity

Get Current Mark Price

import requests

params = {"symbol": "BTCUSDFP"}
response = requests.get('https://api.aax.com/v2/market/markPrice', params=params).json()
print(response)
domain="https://api.aax.com"
path="v2/market/markPrice?symbol=BTCUSDFP"
verb="GET"

output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -X ${verb} "${domain}${path}"`

echo "result: $output"
Description

This endpoint allows you to retrieve the current mark price for a specific futures symbol.

HTTP Request

GET /v2/market/markPrice

Parameters
Parameter Required Data Type Description
symbol Yes String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
{
  "e":"BTCUSDFP@mark",  // event name
  "p":"9000.12000000",  // price
  "t":1572858173963     // Event time (milliseconds)
}
Variable Data Type Description
e String Event name
p String Mark price
t Integer Event time (unit: milliseconds)

Get Predicted Funding Rate

Description

This endpoint is used to get Predicted funding rate without authentication

HTTP Request

GET /v2/futures/funding/predictedFunding/{symbol}

Path Parameters
import requests

response = requests.get('https://api.aax.com/v2/futures/funding/predictedFunding/BTCUSDFP').json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
path='/v2/futures/funding/predictedFunding/BTCUSDFP'
verb='GET'
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -X ${verb} "${domain}${path}"`
echo "result: $output"
Name Required Data Type Description
symbol Yes String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "predictedFundingRate": "0.001",
      "nextFundingTime":  "2020-02-12T08:00:00Z"
   },
   "message":"success",
   "ts":1573542445411
}
Variable Data Type Description
predictedFundingRate String Predicted funding rate. When the funding rate is positive, longs pay shorts. When it is negative, shorts pay longs.
nextFundingTime String Next funding time with UTC time

Get Last Funding Rate

import requests

response = requests.post('https://api.aax.com/v2/futures/funding/prevFundingRate/BTCUSDFP', json=data, auth=auth).json()
print(response)
# !/usr/bin/env bash

domain="https://api.aax.com"
path='/v2/futures/funding/prevFundingRate/'
data="BTCUSDFP"
verb='GET'
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -X ${verb} "${domain}${path}"`
echo "result: $output"
Description

This endpoint is used to get last funding rate without authentication. The funding rate is generated every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC.

HTTP Request

GET /v2/futures/funding/prevFundingRate/{symbol}

Parameters
Parameter Required Data Type Description
symbol Yes String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
{
   "code":1,
   "data":{
      "symbol": "BTCUSDFP",
      "markPrice": "11192.5",
      "fundingRate": “0.001”,
      "fundingTime":  “2020-08-12T08:00:00Z”,
      "nextFundingTime":  “2020-08-12T16:00:00Z”
   },
   "message":"success",
   "ts":1573542445411
}
Variable Data Type Description
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
markPrice String Mark price
fundingRate String The latest funding rate. When the funding rate is positive, longs pay shorts. When it is negative, shorts pay longs.
fundingTime String The funding time with UTC time
nextFundingTime String The next funding time with UTC time

Get Current Index Candlestick

import requests

params = {"symbol": "BTCUSDFP", "timeFrame": "1m"}
response = requests.get('https://api.aax.com/v2/market/index/candles', params=params).json()
print(response)
domain="https://api.aax.com"
path="v2/market/index/candles?symbol=BTCUSDFP&timeFrame=1m"
verb="GET"

output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -X ${verb} "${domain}${path}"`

echo "result: $output"
Description

This endpoint allows you to retrieve index candlestick data for a specific symbol. Supported symbols: BTCUSD, BTCUSDT, ETHUSD.

HTTP Request

GET /v2/market/candles/index

Parameters
Parameter Required Data Type Description
symbol Yes String The trading symbol to trade. Convention is 'Base Currency + Quote Currency'
timeFrame Yes String The period of each candlesticks , 1m, 3m, 5m, 15m, 30m, 1h, 2h, 3h, 4h, 8h, 1d
{
   c: "9308.34000000",
   e: "BTCUSD_INDEX@1m_candles",
   h: "9316.97000000",
   l: "9304.82000000",
   o: "9304.82000000",
   s: 1592548440,
   t: 1592548470,
   v: "4806.98608000"
}
Variable Data Type Description
e String Event name
t Integer Event time (unit: milliseconds)
h String High price
l String Low price
o String Open price
s Integer Start time of the candlestick(seconds)
v String Trade volume
c String Close price

Authenticated Endpoints

Available endpoints
Variable Path Description
GET /v2/user/info Retrieve user information
GET /v2/account/balances Get Account Balances
POST /v2/account/transfer Asset Transfer
POST /v2/spot/orders Create a new spot order
PUT /v2/spot/orders Amend spot order
DELETE /v2/spot/orders/cancel Cancel a spot order
DELETE /v2/spot/orders/cancel/all Batch cancel spot orders
POST /v2/spot/orders/cancelAllOnTimeout Automatically cancel all your spot orders after a specified timeout.
GET /v2/spot/trades Retrieve trades details for a spot order
GET /v2/spot/openOrders Retrieve spot open orders
GET /v2/spot/orders Retrieve historical spot orders
POST /v2/futures/orders Create a new futures order
PUT /v2/futures/orders Amend the quantity of an open futures order
DELETE /v2/futures/orders/cancel Cancel a futures order
DELETE /v2/futures/orders/cancel/all Batch cancel futures orders
POST /v2/futures/orders/cancelAllOnTimeout Automatically cancel all your futures orders after a specified timeout.
GET /v2/futures/position Get positions for all contracts
POST /v2/futures/position/close Close position
GET /v2/futures/position/closed Get closed positions
POST /v2/futures/position/leverage Update leverage for position
POST /v2/futures/position/margin Modify Isolated Position Margin
GET /v2/futures/trades Retrieve trade details for a futures order
GET /v2/futures/openOrders Retrieve futures open orders
GET /v2/futures/Orders Retrieve historical futures orders
GET /v2/futures/funding/predictedFundingFee/{symbol} Get predicted funding fee

Account

User information

Description

Retrieve the user ID associated with the API key used.

HTTP Request
import requests

response = requests.get('https://api.aax.com/v2/user/info', auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/user/info'
verb='GET'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"`
echo "result: $output"

GET /v2/user/info

Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "userID":"216214"
   },
   "message":"success",
   "ts":1573530400495
}
Variable Data Type Description
userID String user id

Get Account Balances

Description

This endpoint allows you to retrieve your accounts balance.

Account types
HTTP Request
import requests

params= {'purseType': "FUTP"}
response = requests.get('https://api.aax.com/v2/account/balances', params=params, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/account/balances?purseType=FUTP'
verb='GET'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"`
echo "result: $output"

GET /v2/account/balances

Request Body Parameters
Name Required Data Type Description
purseType No String Account Type, e.g 'SPTP, FUTP, F2CP, VLTP, RWDP'
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":[
         {
            "purseType":"FUTP",
            "currency":"BTC",
            "available":"0.41000000",
            "unavailable":"0.00000000"
         },
         {
            "purseType":"FUTP",
            "currency":"USDT",
            "available":"0.21000000",
            "unvaliable":"0.00000000"
         }
      ]
 "message":"success",
 "ts":1573530401020
}
Variable Data Type Description
unavailable String Locked balance
available String Available balance for placing orders
currency String Currency code (e.g. BTC)
purseType String Account types

Asset Transfer

Description

This endpoint is used to transfer different coins between your own accounts. You can use this endpoint to transfer coins from your Spot account (SPTP) to your other accounts (Futures, OTC or Savings accounts) or vice-versa.

HTTP Request

POST /v2/account/transfer

Request Body Parameters
import requests

data= {"fromPurse": "FUTP",
       "toPurse": "SPTP",
       "currency": "BTC",
       "quantity": 0.001
      }
response = requests.post('https://api.aax.com/v2/account/transfer', json=data, auth=auth).json()
print(response)
# !/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/account/balances?fromPurse=FUTP&toPurse=SPTP&currency=BTC&quantity=0.001'
verb='POST'
std_sign=`echo -n "${expires}:${verb}${path}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"`
echo "result: $output"
Name Required Data Type Description
fromPurse Yes String Sending account (Valid values: SPTP, FUTP, F2CP, VLTP)
toPurse Yes String Receiving account (Valid values: SPTP, FUTP, F2CP, VLTP)
currency Yes String Currency code (e.g. BTC)
quantity Yes Decimal Quantity to transfer
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
           "transferID": "177",
           "transferTime": "2020-09-06 12:00:00.000Z"
          }
 "message":"success",
 "ts":1573530401020
}
Variable Data Type Description
transferID Integer Transfer ID
transferTime String Transfer time

Spot Trading

Place Spot Order

Description

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

orderType

HTTP Request

POST /v2/spot/orders

Request Body Parameters
import requests

data = {
           "orderType":"LIMIT",
           "symbol":"BTCUSDT",
           "price":8000,
           "orderQty":0.02,
           "side":"BUY",
           "clOrdID":"aax"
        }


response = requests.post('https://api.aax.com/v2/spot/orders', json=data, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/spot/orders'
data="{\"orderType\":\"LIMIT\",\"symbol\":\"BTCUSDT\",\"price\":8000,\"orderQty\":0.02,\"side\":\"BUY\", \"clOrdID\":\"aax\"}"
verb='POST'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"\
 -d "${data}"`
echo "result: $output"
Name Required Data Type Description
orderType Yes String Accepted values: MARKET, LIMIT,STOP, STOP-LIMIT
symbol Yes String Trading symbol to trade. Convention is 'Base Currency' + 'Quote Currency'
price No String Limit price in limit and stop-limit order
orderQty Yes String Buying or selling quantity
side Yes String “BUY” or “SELL” the Base Currency
stopPrice No String Trigger price for stop-limit order or stop order
clOrdID No String Your customized Order ID. The clOrdID type should only use letters. Both uppercase and lowercase letters are supported and a maximum of 20 characters are allowed.
timeInForce No String GTC/IOC/FOK, default is GTC
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "avgPrice":"0",
      "base":"BTC",
      "clOrdID":"aax",
      "commission":"0",
      "createTime":null,
      "cumQty":"0",
      "id":null,
      "isTriggered":null,
      "lastPrice":"0",
      "lastQty":"0",
      "leavesQty":"0",
      "orderID":"wJ4L366KB",
      "orderQty":"0.02",
      "orderStatus":0,
      "orderType":2,
      "price":"8000",
      "quote":"USDT",
      "rejectCode":null,
      "rejectReason":null,
      "side":1,
      "stopPrice":null,
      "symbol":"BTCUSDT",
      "transactTime":null,
      "updateTime":null,
      "timeInForce":1,
      "userID":"216214"
   },
   "message":"success",
   "ts":1573530401264
}
Variable Data Type Description
avgPrice String Average execution price
base String Base Currency code, for example, 'BTC'
clOrdID String Your customized Order ID. The clOrdID type should only use letters. Both uppercase and lowercase letters are supported and a maximum of 20 characters are allowed.
commission String Total commission paid/received for this order.
createTime String Time at which the order was submitted
lastPrice String Price of the last fill
lastQty String Quantity of the last fill
cumQty String Cumulative filled quantity of the order
updateTime String Last update time of the order
isTriggered Boolean Used by STOP_LIMIT and STOP, True or False
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
price String Limit price in limit and stop-limit order
quote String Quote Currency code, for example, 'BTC'
rejectCode String Order rejection code
rejectReason String Reason why the order was rejected
leavesQty String Outstanding quantity of the order that remains to be filled
orderID String AAX order ID
side Integer Buy or Sell the Base Currency, '1:Buy, 2:Sell'
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
stopPrice String Trigger price for stop-limit order or stop order
symbol String The trading symbol to trade. Convention is 'Base Currency + Quote Currency'
orderQty String Order quantity
transactTime String Last execution time
timeInForce String '1: GTC, 3: IOC, 4: FOK'
userID String User id

Modify Spot Order

Description

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

HTTP Request

PUT /v2/spot/orders

Request Body Parameters
import requests

data = {
           "orderID":"wJ4L366KB",
           "orderQty":0.05
       }
response=requests.put('https://api.aax.com/v2/spot/orders',json=data, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/spot/orders'
data="{\"orderID\":\"wJ4L366KB\",\"orderQty\":0.05}"
verb='PUT'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"\
 -d "${data}"`
echo "result: $output"
Name Required Data Type Description
orderID Yes String Modify Spot Order
orderQty No String Order quantity
price No String Limit price in limit and stop-limit order
stopPrice No String Trigger price for stop-limit order or stop order
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "avgPrice":"0",
      "base":"BTC",
      "clOrdID":"aax",
      "commission":"0",
      "createTime":"2019-11-12T03:46:41Z",
      "cumQty":"0",
      "id":"114330021504606208",
      "isTriggered":false,
      "lastPrice":"0",
      "lastQty":"0",
      "leavesQty":"0.05",
      "orderID":"wJ4L366KB",
      "orderQty":"0.05",
      "orderStatus":1,
      "orderType":2,
      "price":"8000",
      "quote":"USDT",
      "rejectCode":0,
      "rejectReason":null,
      "side":1,
      "stopPrice":"0",
      "symbol":"BTCUSDT",
      "transactTime":null,
      "updateTime":"2019-11-12T03:46:41Z",
      "timeInForce":1,
      "userID":"216214"
   },
   "message":"success",
   "ts":1573530401494
}
Variable Data Type Description
avgPrice String Average execution price
base String Base Currency code, for example, 'BTC'
orderID String AAX order ID
clOrdID String Your customized Order ID. The clOrdID type should only use letters. Both uppercase and lowercase letters are supported and a maximum of 20 characters are allowed.
commission String Total commission paid/received for this order.
createTime String Time at which the order was submitted
lastPrice String Price of the last fill
lastQty String Quantity of the last fill
cumQty String Cumulative filled quantity of the order
updateTime String Last update time of the order
isTriggered Boolean Used by STOP_LIMIT and STOP, True or False
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
price String Limit price in limit and stop-limit order
quote String Quote Currency code, for example, 'BTC'
rejectCode String Order rejection code
rejectReason String Reason why the order was rejected
leavesQty String Outstanding quantity of the order that remains to be filled
side Integer Buy or Sell the Base Currency, '1:Buy, 2:Sell'
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
stopPrice String Trigger price for stop-limit order or stop order
symbol String The trading symbol to trade. Convention is 'Base Currency + Quote Currency'
orderQty String Order quantity
transactTime String Last execution time
timeInForce String '1: GTC, 3: IOC, 4: FOK'
userID String User id

Cancel Spot Order

Description

This endpoint is used to cancel an order.

HTTP Request

DELETE /v2/spot/orders/cancel/{orderID}

Path Parameters
import requests

response = requests.delete('https://api.aax.com/v2/spot/orders/cancel/vuULm8UEM', auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/spot/orders/cancel'
data="/vuULm8UEM"
verb='DELETE'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}${data}"`
echo "result: $output"
Name Required Data Type Description
orderID Yes String Order ID of the order to cancel
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "avgPrice":"0",
      "base":"BTC",
      "clOrdID":"aax",
      "commission":"0",
      "createTime":"2019-11-12T03:46:41Z",
      "cumQty":"0",
      "id":"114330021504606208",
      "isTriggered":false,
      "lastPrice":"0",
      "lastQty":"0",
      "leavesQty":"0",
      "orderID":"wJ4L366KB",
      "orderQty":"0.05",
      "orderStatus":1,
      "orderType":2,
      "price":"8000",
      "quote":"USDT",
      "rejectCode":0,
      "rejectReason":null,
      "side":1,
      "stopPrice":"0",
      "symbol":"BTCUSDT",
      "transactTime":null,
      "updateTime":"2019-11-12T03:46:41Z",
      "timeInForce":1,
      "userID":"216214"
   },
   "message":"success",
   "ts":1573530402029
}
Variable Data Type Description
avgPrice String Average execution price
base String Base Currency code, for example, 'BTC'
orderID String AAX order ID
clOrdID String Your customized Order ID. The clOrdID type should only use letters. Both uppercase and lowercase letters are supported and a maximum of 20 characters are allowed.
commission String Total commission paid/received for this order.
createTime String Time at which the order was submitted
lastPrice String Price of the last fill
lastQty String Quantity of the last fill
cumQty String Cumulative filled quantity of the order
updateTime String Last update time of the order
isTriggered Boolean Used by STOP_LIMIT and STOP, True or False
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
price String Limit price in limit and stop-limit order
quote String Quote Currency code, for example, 'BTC'
rejectCode String Order rejection code
rejectReason String Reason why the order was rejected
leavesQty String Outstanding quantity of the order that remains to be filled
side Integer Buy or Sell the Base Currency, '1:Buy, 2:Sell'
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
stopPrice String Trigger price for stop-limit order or stop order
symbol String The trading symbol to trade. Convention is 'Base Currency + Quote Currency'
orderQty String Order quantity
transactTime String Last execution time
timeInForce String '1: GTC, 3: IOC, 4: FOK'
userID String User id

Batch Cancel Spot Order

Description

This endpoint is used to batch cancel your spot orders. By default, all spot orders for the specified trading symbol will be cancelled. You can choose to only cancel a specific list of orders by either providing a list of ordersID or clOrdID.

HTTP Request

DELETE /v2/spot/orders/cancel/all

Request Body Parameters
import requests

data = {
          "orderID": "vBCc46OI0,vBC9rXsEE",
          "symbol" :"BTCUSDT"
       }
response = requests.delete('https://api.aax.com/v2/spot/orders/cancel/all',json=data, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/spot/orders/cancel/all'
data="{\"symbol\":\"BTCUSDT\"}"
verb='DELETE'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"\
 -d ${data}`
echo "result: $output"
Name Required Data Type Description
symbol Yes String Trading symbol to trade. Convention is 'Base Currency' + 'Quote Currency'
orderID No String List of order IDs to cancel. Use a comma ',' to separate
clOrdID No String Your customized Order IDs. Use a comma ',' to separate
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":[
      "vBC9rXsEE",
      "vBCc46OI0"
   ],
   "message":"success",
   "ts":1572597435470
}
Variable Data Type Description
data Array List of orderID that will be cancelled

Cancel All Spot Orders On Timeout

Description

This endpoint can be used as protection against the events of unexpected issues such as loss of your datacenter connectivity or other network issues where you would be losing control over your orders. One can call this endpoint to set a timer (in milliseconds). The endpoint will have to be called again to 'reset the timer' before time runs out. If time runs out, all your Spot orders for all symbols will be cancelled.

In order to cancel the timer and keep your orders alive, you can pass a 'timeout' of '0'.

We recommend not to set the timeout to less than 5 seconds to avoid seeing your orders being cancelled in case of short network blips or congestion.

HTTP Request

POST /v2/spot/orders/cancelAllOnTimeout

Request Body Parameters
import requests

data = {
          "timeout": 30000
       }
response = requests.post('https://api.aax.com/v2/spot/orders/cancelAllOnTimeout',json=data, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/spot/orders/cancelAllOnTimeout'
data="{\"timeout\":30000}"
verb='POST'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"\
 -d ${data}`
echo "result: $output"
Name Required Data Type Description
timeout Yes Integer Timeout in ms. Set to 0 to cancel this timer. Max timeout is 1hour
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
       "endTime": "2020-03-13T08:26:55Z",
       "startTime": "2020-03-13T08:26:25Z",
   }
   "message":"success",
   "ts":158408795346
}
Variable Data Type Description
startTime String Unix Time
endTime String Unix Time

Retrieve Spot Trades

Description

This endpoint is used to retrieve your orders execution details.

HTTP Request

GET /v2/spot/trades

Query String Parameters
import requests
params = {
           "pageNum":1,
           "pageSize":1,
           "base":"BTC",
           "quote":"USDT"
         }
response = requests.get('https://api.aax.com/v2/spot/trades', params=params, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/spot/trades'
data="?pageNum=1&pageSize=1&base=BTC&quote=USDT"
verb='GET'
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}${data}"`
echo "result: $output"
Name Required Data Type Description
pageNum No Integer Pagination page number, default '1'
pageSize No Integer Pagination page size, default '10'
orderID No String Specify order id if you want to retrieve trade details related to specific order
base No String Base Currency code, for example, 'BTC'
quote No String Quote Currency code, for example, 'BTC'
startDate No String Search starts date, format to use: yyyy-mm-dd
endDate No String Search ends date, format to use: yyyy-mm-dd
side No String Filter on the direction of the trade, BUY or SELL
orderType No String Types of order to include in the search, 'MARKET, LIMIT, STOP, STOP-LIMIT'
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "list":[
         {
            "avgPrice":"8000",
            "base":"BTC",
            "commission":"0.00000888",
            "createTime":"2019-11-12T03:18:35Z",
            "cumQty":"0.0148",
            "filledPrice":"8000",
            "filledQty":"0.0148",
            "id":"114322949580906499",
            "leavesQty":"0.0052",
            "orderID":"wFo9ZPxAJ",
            "tradeID":"E03GseMJLjfn",
            "orderQty":"0.02",
            "orderStatus":2,
            "orderType":2,
            "price":"8000",
            "quote":"USDT",
            "rejectCode":0,
            "rejectReason":null,
            "side":1,
            "stopPrice":"0",
            "symbol":"BTCUSDT",
            "taker":false,
            "transactTime":"2019-11-12T03:16:16Z",
            "updateTime":null,
            "userID":"216214"
         }
      ],
      "pageNum":1,
      "pageSize":1,
      "total":10
   },
   "message":"success",
   "ts":1573532934832
}
Variable Data Type Description
avgPrice String Average execution price
base String Base Currency code, for example, 'BTC'
orderID String AAX order ID
tradeID String Trade ID
commission String Total commission paid/received for this order.
createTime String Time at which the order was submitted
filledPrice String Price of the last fill
cumQty String Cumulative filled quantity of the order
updateTime String Last update time of the order
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
price String Limit price in limit and stop-limit order
quote String Quote Currency code, for example, 'BTC'
rejectCode String Order rejection code
rejectReason String Reason why the order was rejected
leavesQty String Outstanding quantity of the order that remains to be filled
side Integer Buy or Sell the Base Currency, '1:Buy, 2:Sell'
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
stopPrice String Trigger price for stop-limit order or stop order
symbol String The trading symbol to trade. Convention is 'Base Currency + Quote Currency'
orderQty String Order quantity
transactTime String Last execution time
filledQty String Filled quantity for the trade
taker Boolean True: taker, False: maker
userID String User id
pageNum Integer Pagination page number
pageSize Integer Pagination page size
total Integer Total number of records returned from the search

Retrieve Spot Open Orders

Description

This endpoint is used to retrieve spot open orders.

HTTP Request

GET /v2/spot/openOrders

Query String Parameters
import requests

params = {
           "symbol":"BTCUSDT"
         }
response = requests.get('https://api.aax.com/v2/spot/openOrders', params=params, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/spot/openOrders'
data="?symbol=BTCUSDT"
verb='GET'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}${data}"`
echo "result: $output"
Name Required Data Type Description
pageNum No Integer Pagination page number, default '1'
pageSize No Integer Pagination page size, default '10'
symbol No String Trading symbol to trade. Convention is 'Base Currency' + 'Quote Currency'
orderID No String AAX order ID
side No String Filter on the direction of the trade, BUY or SELL
clOrdID No String Your customized Order ID. The clOrdID type should only use letters. Both uppercase and lowercase letters are supported and a maximum of 20 characters are allowed.
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "list":[
         {
            "avgPrice":"0",
            "base":"BTC",
            "clOrdID":"aax",
            "commission":"0",
            "createTime":"2019-11-12T03:41:52Z",
            "cumQty":"0",
            "id":"114328808516083712",
            "isTriggered":false,
            "lastPrice":"0",
            "lastQty":"0",
            "leavesQty":"0",
            "orderID":"wJ3qitASB",
            "orderQty":"0.02",
            "orderStatus":1,
            "orderType":2,
            "price":"8000",
            "quote":"USDT",
            "rejectCode":0,
            "rejectReason":null,
            "side":1,
            "stopPrice":"0",
            "symbol":"BTCUSDT",
            "transactTime":null,
            "updateTime":"2019-11-12T03:41:52Z",
            "timeInForce":1,
            "userID":"216214"
         },
         ...
      ],
      "pageNum":1,
      "pageSize":2,
      "total":2
   },
   "message":"success",
   "ts":1573553718212
}
Variable Data Type Description
avgPrice String Average execution price
base String Base Currency code, for example, 'BTC'
orderID String AAX order ID
clOrdID String Your customized Order ID. The clOrdID type should only use letters. Both uppercase and lowercase letters are supported and a maximum of 20 characters are allowed.
commission String Total commission paid/received for this order.
createTime String Time at which the order was submitted
lastPrice String Price of the last fill
lastQty String Quantity of the last fill
cumQty String Cumulative filled quantity of the order
updateTime String Last update time of the order
isTriggered Boolean Used by STOP_LIMIT and STOP, True or False
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
price String Limit price in limit and stop-limit order
quote String Quote Currency code, for example, 'BTC'
rejectCode String Order rejection code
rejectReason String Reason why the order was rejected
leavesQty String Outstanding quantity of the order that remains to be filled
side Integer Buy or Sell the Base Currency, '1:Buy, 2:Sell'
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
stopPrice String Trigger price for stop-limit order or stop order
symbol String The trading symbol to trade. Convention is 'Base Currency + Quote Currency'
orderQty String Order quantity
transactTime String Last execution time
timeInForce String '1: GTC, 3: IOC, 4: FOK'
userID String User id
pageNum Integer Pagination page number
pageSize Integer Pagination page size
total Integer Total number of records returned from the search

Retrieve Spot Historical Order(s)

Description

This endpoint is used to query historical orders.

HTTP Request

GET /v2/spot/orders

Query String Parameters
import requests

params = {
           "orderID":"vBGlDcLwk",
           "side":"BUY"
         }
response = requests.get('https://api.aax.com/v2/spot/orders', params=params, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/spot/orders'
data="?orderID=vBGlDcLwk&side=BUY"
verb='GET'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}${data}"`
echo "result: $output"
Name Required Data Type Description
pageNum No Integer Pagination page number, default '1'
pageSize No Integer Pagination page size, default '10'
symbol No String Trading symbol to trade. Convention is 'Base Currency' + 'Quote Currency'
orderID No String AAX order ID
base No String Base Currency code, for example, 'BTC'
quote No String Quote Currency code, for example, 'BTC'
orderStatus No Integer Status of orders to include in the search, '1:new, 2:filled, 3:cancel'
startDate No String Search starts date, format to use: yyyy-mm-dd
endDate No String Search ends date, format to use: yyyy-mm-dd
orderType No String Types of order to include in the search, 'MARKET, LIMIT, STOP, STOP-LIMIT'
side No String Filter on the direction of the trade, BUY or SELL
clOrdID No String Your customized Order ID. The clOrdID type should only use letters. Both uppercase and lowercase letters are supported and a maximum of 20 characters are allowed.
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "total":19,
      "pageSize":10,
      "list":[
         {
            "orderType":2,
            "symbol":"BTCUSDT",
            "avgPrice":"0",
            "orderStatus":0,
            "userID":"7225",
            "quote":"USDT",
            "rejectReason":null,
            "rejectCode":null,
            "price":"0",
            "orderQty":"0.002",
            "commission":"0",
            "id":"110419975166304256",
            "isTriggered":null,
            "side":1,
            "orderID":"vBGlDcLwk",
            "cumQty":"0",
            "leavesQty":"0",
            "updateTime":null,
            "clOrdID":"0001",
            "lastQty":"0",
            "stopPrice":"0",
            "createTime":"2019-11-01T08:49:33Z",
            "transactTime":null,
            "timeInForce":1,
            "base":"BTC",
            "lastPrice":"0"
         }
      ],
      "pageNum":1
   },
   "message":"success",
   "ts":1572598173682
}
Variable Data Type Description
avgPrice String Average execution price
base String Base Currency code, for example, 'BTC'
orderID String AAX order ID
clOrdID String Your customized Order ID. The clOrdID type should only use letters. Both uppercase and lowercase letters are supported and a maximum of 20 characters are allowed.
commission String Total commission paid/received for this order.
createTime String Time at which the order was submitted
lastPrice String Price of the last fill
lastQty String Quantity of the last fill
cumQty String Cumulative filled quantity of the order
updateTime String Last update time of the order
isTriggered Boolean Used by STOP_LIMIT and STOP, True or False
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
price String Limit price in limit and stop-limit order
quote String Quote Currency code, for example, 'BTC'
rejectCode String Order rejection code
rejectReason String Reason why the order was rejected
leavesQty String Outstanding quantity of the order that remains to be filled
side Integer Buy or Sell the Base Currency, '1:Buy, 2:Sell'
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
stopPrice String Trigger price for stop-limit order or stop order
symbol String The trading symbol to trade. Convention is 'Base Currency + Quote Currency'
orderQty String Order quantity
transactTime String Last execution time
timeInForce String '1: GTC, 3: IOC, 4: FOK'
userID String User id
pageNum Integer Pagination page number
pageSize Integer Pagination page size
total Integer Total number of records returned from the search

Futures Trading

Place Futures Order

Description

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

orderType

TimeInForce

timeInForce is a special instruction used when placing an order to indicate how long the order will remain active before it is executed or expires.

liqType

settleType

Name Settlement currency Example Description
Inverse Settlement Base Currency Settlement BTCUSDFP The settlement of the futures contract is calculated using BTC, the Base Currency
Quanto Settlement Cross Currency Settlement ETHUSDFP The settlement of the futures contract is calculated using BTC which is not the base nor the Quote Currency
Vanilla Settlement Quote Currency Settlement EOSBTCFP The settlement of the futures contract is calculated using BTC, the Quote Currency
HTTP Request

POST /v2/futures/orders

Request Body Parameters
import requests

data= {
       "orderType":"LIMIT",
       "symbol":"BTCUSDFP",
       "price":8000,
       "orderQty":100,
       "side":"BUY",
       "clOrdID":"aax_futures"
      }
response=requests.post('https://api.aax.com/v2/futures/orders',json=data, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/orders'
data="{\"orderType\":\"LIMIT\",\"symbol\":\"BTCUSDFP\",\"price\":8000,\"orderQty\":100,\"side\":\"BUY\", \"clOrdID\":\"aax_futures\"}"
verb='POST'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"\
 -d "${data}"`
echo "result: $output"
Name Required Data Type Description
orderType Yes String Accepted values: MARKET, LIMIT,STOP, STOP-LIMIT
symbol Yes String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
price No String Limit price in limit and stop-limit order
orderQty Yes String This is the quantity of contracts you wish to buy or sell
side Yes String 'Long' or 'Short' the contract. e.g. 'BUY, SELL'
stopPrice No String Trigger price for stop-limit order or stop order
clOrdID No String Client order ID
execInst No String Optional execution instructions. Valid options: Post-Only. By using Post-Only orders, your order limit order will be cancelled if this order would have executed on placement
timeInForce No String GTC/IOC/FOK, default is GTC
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "avgPrice":"0",
      "base":"BTC",
      "clOrdID":"aax_futures",
      "code":"FP",
      "commission":"0",
      "createTime":null,
      "cumQty":"0",
      "id":"114375893764395008",
      "isTriggered":null,
      "lastPrice":"0",
      "lastQty":null,
      "leavesQty":"100",
      "leverage":"1",
      "liqType":0,
      "marketPrice":"8760.7500000000",
      "orderID":"wJTewQc81",
      "orderQty":"100",
      "orderStatus":0,
      "orderType":2,
      "price":"8000",
      "quote":"USD",
      "rejectCode":null,
      "rejectReason":null,
      "settleType":"INVERSE",
      "side":1,
      "stopPrice":null,
      "symbol":"BTCUSDFP",
      "transactTime":null,
      "updateTime":null,
      "timeInForce":1,
      "execInst": "",
      "userID":"216214"
   },
   "message":"success",
   "ts":1573541338074
}
Variable Data Type Description
avgPrice String Average execution price
base String Base Currency code, for example, 'BTC'
clOrdID String Client order ID
code String Applicable for futures only. 'FP' for futures, null for spot
commission String Total commission paid/received for this order.
createTime String Time at which the order was submitted
cumQty String Cumulative filled quantity of the order
lastPrice String Price of the last fill
leavesQty String Outstanding quantity of the order that remains to be filled
leverage String leverage
liqType Integer Liquidation type for futures,'0:General,1:USER-CLOSE-LIQ, 2:LIQ, 3:TAKE-PROFIT-LIQ, 4:STOP-LOSS-LIQ'. More details on liqType.
marketPrice String Market price. (best bid + best ask)/2
orderID String AAX order ID
orderQty String Order quantity
rejectCode String Order rejection code
rejectReason String Reason why the order was rejected
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
price String Limit price in limit and stop-limit order
quote String Base Currency code, for example, 'BTC'
settleType String Settlement type (INVERSE, VANILLA or QUANTO) More details on Settlement types.
side Integer 'Long' or 'Short' the contract. e.g. 'BUY, SELL'
stopPrice String Trigger price for stop-limit order or stop order
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
transactTime String Last execution time
updateTime String Last update time of the order
execInst String Post-Only or ''
timeInForce String '1: GTC, 3: IOC, 4: FOK'
userID String User id

Modify Futures Order

Description

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

HTTP Request

PUT /v2/futures/orders

Request Body Parameters
import requests

data = {
           "orderID":"wJTewQc81",
           "orderQty":300
       }
response=requests.put('https://api.aax.com/v2/futures/orders',json=data,auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/orders'
data="{\"orderID\":\"wJTewQc81\",\"orderQty\":300}"
verb='PUT'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"\
 -d "${data}"`
echo "result: $output"
Name Required Data Type Description
orderID Yes String Order ID of the order to amend
orderQty No String Order quantity
price No String Limit price in limit and stop-limit order
stopPrice No String Trigger price for stop-limit order or stop order
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "avgPrice":"0",
      "base":"BTC",
      "clOrdID":"aax_futures",
      "code":"FP",
      "commission":"0",
      "createTime":"2019-11-12T06:48:58Z",
      "cumQty":"0",
      "id":"114375893764395008",
      "isTriggered":false,
      "lastPrice":"0",
      "lastQty":null,
      "leavesQty":"100",
      "leverage":"1",
      "liqType":0,
      "marketPrice":"8760.75",
      "orderID":"wJTewQc81",
      "orderQty":"100",
      "orderStatus":1,
      "orderType":2,
      "price":"8000",
      "quote":"USD",
      "rejectCode":0,
      "rejectReason":null,
      "settleType":"INVERSE",
      "side":1,
      "stopPrice":"0",
      "symbol":"BTCUSDFP",
      "transactTime":null,
      "updateTime":"2019-11-12T06:48:58Z",
      "timeInForce":1,
      "execInst": "",
      "userID":"216214"
   },
   "message":"success",
   "ts":1573541338322
}
Variable Data Type Description
avgPrice String Average execution price
base String Base Currency code, for example, 'BTC'
clOrdID String Client order ID
code String Applicable for futures only. 'FP' for futures, null for spot
commission String Total commission paid/received for this order.
createTime String Time at which the order was submitted
cumQty String Cumulative filled quantity of the order
lastPrice String Price of the last fill
leavesQty String Outstanding quantity of the order that remains to be filled
leverage String leverage
liqType Integer Liquidation type for futures,'0:General,1:USER-CLOSE-LIQ, 2:LIQ, 3:TAKE-PROFIT-LIQ, 4:STOP-LOSS-LIQ'. More details on liqType.
marketPrice String Market price. (best bid + best ask)/2
orderID String AAX order ID
orderQty String Order quantity
rejectCode String Order rejection code
rejectReason String Reason why the order was rejected
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
price String Limit price in limit and stop-limit order
quote String Base Currency code, for example, 'BTC'
settleType String Settlement type (INVERSE, VANILLA or QUANTO) More details on Settlement types.
side Integer 'Long' or 'Short' the contract. e.g. 'BUY, SELL'
stopPrice String Trigger price for stop-limit order or stop order
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
transactTime String Last execution time
updateTime String Last update time of the order
timeInForce String '1: GTC, 3: IOC, 4: FOK'
userID String User id

Cancel Futures Order

Description

This endpoint is used to cancel an order.

HTTP Request

DELETE /v2/futures/orders/cancel/{orderID}

Path Parameters
import requests

response = requests.delete('https://api.aax.com/v2/futures/orders/cancel/wJTewQc81', auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/orders/cancel'
data="/wJTewQc81"
verb='DELETE'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}${data}"`
echo "result: $output"
Name Required Data Type Description
orderID Yes String Order ID of the order to cancel
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "avgPrice":"0",
      "base":"BTC",
      "clOrdID":"aax_futures",
      "code":"FP",
      "commission":"0",
      "createTime":"2019-11-12T06:48:58Z",
      "cumQty":"0",
      "id":"114375893764395008",
      "isTriggered":false,
      "lastPrice":"0",
      "lastQty":null,
      "leavesQty":"300",
      "leverage":"1",
      "liqType":0,
      "marketPrice":"8760.75",
      "orderID":"wJTewQc81",
      "orderQty":"300",
      "orderStatus":1,
      "orderType":2,
      "price":"8000",
      "quote":"USD",
      "rejectCode":0,
      "rejectReason":null,
      "settleType":"INVERSE",
      "side":1,
      "stopPrice":"0",
      "symbol":"BTCUSDFP",
      "transactTime":"2019-11-12T06:48:58Z",
      "updateTime":"2019-11-12T06:48:58Z",
      "timeInForce":1,
      "execInst": "",
      "userID":"216214"
   },
   "message":"success",
   "ts":1573541642970
}
Variable Data Type Description
avgPrice String Average execution price
base String Base Currency code, for example, 'BTC'
clOrdID String Client order ID
code String Applicable for futures only. 'FP' for futures, null for spot
commission String Total commission paid/received for this order.
createTime String Time at which the order was submitted
cumQty String Cumulative filled quantity of the order
lastPrice String Price of the last fill
leavesQty String Outstanding quantity of the order that remains to be filled
leverage String leverage
liqType Integer Liquidation type for futures,'0:General,1:USER-CLOSE-LIQ, 2:LIQ, 3:TAKE-PROFIT-LIQ, 4:STOP-LOSS-LIQ'. More details on liqType.
marketPrice String Market price. (best bid + best ask)/2
orderID String AAX order ID
orderQty String Order quantity
rejectCode String Order rejection code
rejectReason String Reason why the order was rejected
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
price String Limit price in limit and stop-limit order
quote String Base Currency code, for example, 'BTC'
settleType String Settlement type (INVERSE, VANILLA or QUANTO) More details on Settlement types.
side Integer 'Long' or 'Short' the contract. e.g. 'BUY, SELL'
stopPrice String Trigger price for stop-limit order or stop order
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
transactTime String Last execution time
updateTime String Last update time of the order
execInst String Post-Only or ''
timeInForce String '1: GTC, 3: IOC, 4: FOK'
userID String User id

Batch Cancel Futures Order

Description

This endpoint is used to batch cancel your futures orders.

HTTP Request

DELETE /v2/futures/orders/cancel/all

Request Body Parameters
import requests

data = {
           "symbol":"BTCUSDFP"
       }
response = requests.delete('https://api.aax.com/v2/futures/orders/cancel/all', json=data,auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/orders/cancel/all'
data="{\"symbol\":\"BTCUSDFP\"}"
verb='DELETE'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"\
 -d ${data}`
echo "result: $output"
Name Required Data Type Description
symbol Yes String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
orderID No String List of order IDs to cancel. Use a comma ',' to separate
clOrdID No String Your customized Order IDs. Use a comma ',' to separate
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":[
      "wKQf3hpV7"
   ],
   "message":"success",
   "ts":1573556374435
}
Variable Data Type Description
data Array List of orderID that will be cancelled

Cancel All Futures Orders On Timeout

Description

This endpoint can be used as protection against the events of unexpected issues such as loss of your datacenter connectivity or other network issues where you would be losing control over your orders. One can call this endpoint to set a timer (in milliseconds). The endpoint will have to be called again to 'reset the timer' before time runs out. If time runs out, all your Spot orders for all symbols will be cancelled.

In order to cancel the timer and keep your orders alive, you can pass a 'timeout' of '0'.

We recommend not to set the timeout to less than 5 seconds to avoid seeing your orders being cancelled in case of short network blips or congestion.

HTTP Request

POST /v2/futures/orders/cancelAllOnTimeout

Request Body Parameters
import requests

data = {
          "timeout": 30000
       }
response = requests.post('https://api.aax.com/v2/futures/orders/cancelAllOnTimeout',json=data, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/orders/cancelAllOnTimeout'
data="{\"timeout\":30000}"
verb='POST'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"\
 -d ${data}`
echo "result: $output"
Name Required Data Type Description
timeout Yes Integer Timeout in ms. Set to 0 to cancel this timer. Max timeout is 1hour
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
       "endTime": "2020-03-13T08:26:55Z",
       "startTime": "2020-03-13T08:26:25Z",
   }
   "message":"success",
   "ts":158408795346
}
Variable Data Type Description
startTime String Unix Time
endTime String Unix Time

Retrieve Futures Position

Description

This endpoint is used to get positions for all contracts.

HTTP Request

GET /v2/futures/position

Query String Parameters
import requests

params = {
           "symbol":"BTCUSDFP"
         }
response = requests.get('https://api.aax.com/v2/futures/position', params=params, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/position'
data="?symbol=BTCUSDFP"
verb='GET'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}${data}"`
echo "result: $output"
Name Required Data Type Description
symbol No String Specify a futures contract symbol if you would like to see your position only for that futures. Convention is 'Base Currency + Quote Currency + FP'
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":[
      {
         "avgEntryPrice":"0",
         "bankruptPrice":null,
         "base":"BTC",
         "code":"FP",
         "commission":"0",
         "funding":"0",
         "currentQty":"0",
         "fundingStatus":0,
         "id":"114375893760200704",
         "leverage":"1",
         "liquidationPrice":null,
         "marketPrice":null,
         "openTime":null,
         "posLeverage":"1",
         "posMargin":"0",
         "quote":"USD",
         "stopLossPrice":"9211",
         "stopLossSource":1,
         "takeProfitPrice":"9400",
         "takeProfitSource":1,
         "realisedPnl":"0",
         "unrealisedPnl":"0",
         "riskLimit":"1000000",
         "riskyPrice":"0",
         "settleType":"INVERSE",
         "symbol":"BTCUSDFP",
         "userID":"216214"
      }
   ],
   "message":"success",
   "ts":1573541723519
}
Variable Data Type Description
avgEntryPrice String Average executed buy/sell price for your current long/short position
bankruptPrice String Bankruptcy price
base String Base Currency code, for example, 'BTC'
code String Applicable for futures only. 'FP' for futures, null for spot
commission String Total commission paid/received since opening the position.Positive sign means received
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 received, negative means paid
fundingStatus Integer Funding status, 0:settling, 1:settled
posMargin String Position margin
leverage String Position leverage
liquidationPrice String The liquidation price after the trade was processed
marketPrice String Market price. (best bid + best ask)/2
openTime String Position creation timestamp in UTC
quote String Base Currency code, for example, 'BTC'
stopLossPrice String Stop loss price
stopLossSource Integer Trigger price type.'1: Last Price'
takeProfitPrice String Take profit price
takeProfitSource Integer Trigger price type.'1: Last Price'
realisedPnl String Realised profit and loss since opening this position
unrealisedPnl String Unrealised profit and loss
riskyPrice String Risky price, this is for internal processing only
settleType String Settlement type (INVERSE, VANILLA or QUANTO) More details on Settlement types.
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
userID String User id

Set Position Take Profit and Stop Loss

Description

This endpoint is used to set take profit and stop loss orders for an opening position

HTTP Request

POST /v2/futures/position/sltp

Request Body Parameters
import requests

data =
{
  "stopLossPrice": 9211,
  "stopLossStatus": 1,
  "symbol": "BTCUSDFP",
  "takeProfitPrice": 9400,
  "takeProfitStatus": 1
}
response = requests.post('https://api.aax.com/v2/futures/position/sltp', json=data, auth=auth).json()
print(response)
# !/usr/bin/env bash
domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/position/sltp'
data=[{\"stopLossPrice\": “9211”,\"stopLossStatus\": 1,\"symbol\": \"BTCUSDFP\",\"takeProfitPrice\": \"9400\",\"takeProfitStatus\": 1}]
verb='POST'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"\
 -d "${data}"`
echo "result: $output"
Name Required Data Type Description
symbol Yes String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
side Yes String 'Long' or 'Short' the contract. e.g. 'BUY, SELL'
stopLossPrice No String Stop loss price
stopLossStatus No Integer Enable stop loss. '0: No, 1: Yes'
takeProfitPrice No String Take profit price
takeProfitStatus No Integer Enable take profit. '0: No, 1: Yes'

Note

Output Variable

The above command returns JSON structured like this:

{
    "code":1,
    "data":{
        "side":"1",
        "stopLossExpiration":"2020-08-02T11:36:13Z",
        "stopLossOrderId":"WnzsF613y",
        "stopLossPrice":"9211",
        "stopLossSource":1,
        "stopLossStatus":1,
        "symbol":"BTCUSDTFP",
        "takeProfitExpiration":"2020-08-02T11:36:13Z",
        "takeProfitOrderId":"WnzsF8drO",
        "takeProfitPrice":"9400",
        "takeProfitSource":1,
        "takeProfitStatus":1
    },
    "message":"success",
    "timestamp":"2020-07-16 10:55:44"
}
Variable Data Type Description
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
side Integer Take Profit and Stop Loss Direction.'1:Long,2:Short'
stopLossPrice String Stop loss price
stopLossSource Integer Trigger price type.'1: Last Price'
stopLossStatus Integer Enable stop loss. '0: No, 1: Yes'
stopLossOrderID String Stop loss order ID
stopLossExpiration String Stop loss expiration
takeProfitPrice String Take profit price
takeProfitSource Integer Trigger price type.'1: Last Price, 2, Mark Price, 3: Index Price,4: Mid Price'
takeProfitStatus Integer Enable take profit. '0: No, 1: Yes'
takeProfitOrderID String Take profit order ID
takeProfitExpiration String Take profit expiration

Close Futures Position

Description

This endpoint is used to close position.

HTTP Request

POST /v2/futures/position/close

Request Body Parameters
import requests

data = {
           "symbol":"BTCUSDFP"
       }
response = requests.post('https://api.aax.com/v2/futures/position/close', json=data, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/position/close'
data="{\"symbol\": \"BTCUSDFP\"}"
verb='POST'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"\
 -d "${data}"`
echo "result: $output"
Name Required Data Type Description
symbol Yes String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
price No String Limit price

Note

Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "avgPrice":"0",
      "base":"BTC",
      "clOrdID":null,
      "code":"FP",
      "commission":"0",
      "createTime":null,
      "cumQty":"0",
      "id":null,
      "isTriggered":null,
      "lastPrice":"0",
      "lastQty":null,
      "leavesQty":"100",
      "leverage":"1",
      "liqType":1,
      "marketPrice":"8769.7500000000",
      "orderID":"wJXURIFBT",
      "orderQty":"100",
      "orderStatus":0,
      "orderType":1,
      "price":"8769.7500000000",
      "stopLossPrice":"9211",
      "stopLossSource":1,
      "takeProfitPrice":"9400",
      "takeProfitSource":1,
      "quote":"USD",
      "rejectCode":null,
      "rejectReason":null,
      "settleType":"INVERSE",
      "side":2,
      "stopPrice":null,
      "symbol":"BTCUSDFP",
      "transactTime":null,
      "updateTime":null,
      "userID":"216214"
   },
   "message":"success",
   "ts":1573542352735
}
Variable Data Type Description
avgPrice String Average execution price
base String Base Currency code, for example, 'BTC'
clOrdID String Client order ID
code String Applicable for futures only. 'FP' for futures, null for spot
commission String Total commission paid/received since opening the position.Positive sign means received
createTime String Time at which the order was submitted
cumQty String Cumulative filled quantity of the order
lastPrice String Price of the last fill
leavesQty String Outstanding quantity of the order that remains to be filled
leverage String Position leverage
liqType Integer Liquidation type for futures,'0:General,1:USER-CLOSE-LIQ, 2:LIQ, 3:TAKE-PROFIT-LIQ, 4:STOP-LOSS-LIQ'. More details on liqType.
marketPrice String Market price. (best bid + best ask)/2
orderID String AAX order ID
orderQty String Order quantity
rejectCode String Order rejection code
rejectReason String Reason why the order was rejected
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
price String Limit price in limit and stop-limit order
stopLossPrice String Stop loss price
stopLossSource Integer Trigger price type.'1: Last Price'
takeProfitPrice String Take profit price
takeProfitSource Integer Trigger price type.'1: Last Price'
quote String Base Currency code, for example, 'BTC'
settleType String Settlement type (INVERSE, VANILLA or QUANTO) More details on Settlement types.
side Integer 'Long' or 'Short' the contract. e.g. 'BUY, SELL'
stopPrice String Trigger price for stop-limit order or stop order
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
transactTime String Last execution time
updateTime String Last update time of the order
userID String User id

Retrieve Futures Closed Position

Description

This endpoint is used to retrieve closed position.

HTTP Request

GET /v2/futures/position/closed

Query String Parameters
import requests

params = {
           "symbol":"BTCUSDFP"
         }
response = requests.get('https://api.aax.com/v2/futures/position/closed', params=params, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/position'
path='/v2/futures/position/closed'
data="?symbol=BTCUSDFP"
verb='GET'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}${data}"`
echo "result: $output"
Name Required Data Type Description
pageNum No Integer Pagination page number, default '1'
pageSize No Integer Pagination page size, default '10'
symbol No String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
startDate No String Search starts date, format to use: yyyy-mm-dd
endDate No String Search ends date, format to use: yyyy-mm-dd
pnlType No String The pnl type, 'profit or loss'
beforeHours No Integer Search orders before n hours, e.g '8'
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "list":[
         {
            "base":"BTC",
            "closeTime":"2019-11-07T07:23:56Z",
            "code":"FP",
            "commission":"0.00000625",
            "funding":"0",
            "id":"112572754530816000",
            "openTime":"2019-11-07T07:23:35Z",
            "pnl":"-0.00030901",
            "quote":"USD",
            "stopLossPrice":"9211",
            "stopLossSource":1,
            "takeProfitPrice":"9400",
            "takeProfitSource":1,
            "realisedPnl":"-0.00030276",
            "symbol":"BTCUSDFP",
            "userID":"216214"
         },
         {
            "base":"BTC",
            "closeTime":"2019-11-06T09:02:37Z",
            "code":"FP",
            "commission":"0.00000957",
            "funding":"-0.00000128",
            "id":"112235202187776000",
            "openTime":"2019-11-06T08:50:48Z",
            "pnl":"-0.00001255",
            "quote":"USD",
            "stopLossPrice":"9211",
            "stopLossSource":1,
            "takeProfitPrice":"9400",
            "takeProfitSource":1,
            "realisedPnl":"-0.0000017",
            "symbol":"BTCUSDFP",
            "userID":"216214"
         }
      ],
      "pageNum":1,
      "pageSize":10,
      "total":2
   },
   "message":"success",
   "ts":1573542067453
}
Variable Data Type Description
base String Base Currency code, for example, 'BTC'
closeTime String Close position time
code String Applicable for futures only. 'FP' for futures, null for spot
commission String Total commission paid/received since opening the position.Positive sign means received
funding String Funding amount in BTC received/paid since opening the position. Positive sign means received, negative means paid
openTime String Position creation timestamp in UTC
pnl String The retained profit and loss
quote String Base Currency code, for example, 'BTC'
stopLossPrice String Stop loss price
stopLossSource Integer Trigger price type.'1: Last Price'
takeProfitPrice String Take profit price
takeProfitSource Integer Trigger price type.'1: Last Price'
realisedPnl String Realised profit and loss since opening this position
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
userID String User id
pageNum Integer Pagination page number
pageSize Integer Pagination page size
total Integer Total number of records returned from the search

Futures Update Leverage

Description

This endpoint is used to update the leverage for a futures position.

HTTP Request

POST /v2/futures/position/leverage

Request Body Parameters
import requests

data = {
           "symbol":"BTCUSDFP",
           "leverage":10
       }
response = requests.post('https://api.aax.com/v2/futures/position/leverage', json=data, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/position/leverage'
data="{\"symbol\": \"BTCUSDFP\", \"leverage\": 10}"
verb='POST'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"\
 -d "${data}"`
echo "result: $output"
Name Required Data Type Description
symbol Yes String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
leverage Yes Integer 1-100x leverage, e.g. 10
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "avgEntryPrice":"0",
      "bankruptPrice":"0",
      "base":"BTC",
      "code":"FP",
      "commission":"0",
      "currentQty":"0",
      "funding":"0",
      "fundingStatus":0,
      "id":"114375893760200704",
      "leverage":"10",
      "liquidationPrice":"0",
      "marketPrice":null,
      "openTime":null,
      "posLeverage":"0",
      "posMargin":"0",
      "quote":"USD",
      "realisedPnl":"0",
      "unrealisedPnl":"0",
      "riskLimit":"1000000",
      "riskyPrice":"0",
      "settleType":"INVERSE",
      "symbol":"BTCUSDFP",
      "userID":"216214"
   },
   "message":"success",
   "ts":1573542445411
}
Variable Data Type Description
avgEntryPrice String Average executed buy/sell price for your current long/short position
bankruptPrice String Bankruptcy price
base String Base Currency code, for example, 'BTC'
code String Applicable for futures only. 'FP' for futures, null for spot
commission String Total commission paid/received since opening the position.Positive sign means received
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 received, negative means paid
fundingStatus Integer Funding status, 0:settling, 1:settled
posMargin String Position margin
leverage String Position leverage
liquidationPrice String The liquidation price after the trade was processed
marketPrice String Market price. (best bid + best ask)/2
openTime String Position creation timestamp in UTC
quote String Base Currency code, for example, 'BTC'
realisedPnl String Realised profit and loss since opening this position
unrealisedPnl String Unrealised profit and loss
riskyPrice String Risky price, this is for internal processing only
settleType String Settlement type (INVERSE, VANILLA or QUANTO) More details on Settlement types.
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
userID String User id

Modify Isolated Position Margin

Description

The endpoint uses to modify isolated position margin.

HTTP Request

POST /v2/futures/position/margin

Request Body Parameters
import requests

data = {
           "symbol":"BTCUSDFP",
           "margin":0.001
       }
response = requests.post('https://api.aax.com/v2/futures/position/margin', json=data, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/position/margin'
data="{\"symbol\": \"BTCUSDFP\", \"margin\": 0.001}"
verb='POST'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"\
 -d "${data}"`
echo "result: $output"
Name Required Data Type Description
symbol Yes String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
margin Yes Integer Margin
Output Variable

The above command returns JSON structured like this:

{"code": 1,
 "data": {"avgEntryPrice": "9236.00000000042578",
          "bankruptPrice": "9301.8425207",
          "base": "BTC",
          "code": "FP",
          "commission": "0.00017138",
          "currentQty": "-2320",
          "funding": "0",
          "fundingStatus": 0,
          "id": "173181324568178688",
          "leverage": "10",
          "liquidationPrice": "9247.5",
          "marketPrice": None,
          "openTime": None,
          "posLeverage": "141.28",
          "posMargin": "0.001",
          "quote": "USD",
          "realisedPnl": "-0.00060578",
          "riskLimit": "1000000",
          "riskyPrice": "9242.5",
          "settleType": "INVERSE",
          "stopLossPrice": None,
          "stopLossSource": None,
          "symbol": "BTCUSDFP",
          "takeProfitPrice": None,
          "takeProfitSource": None,
          "userID": "213409"},
 "message": "success",
 "ts": 1594214994104}
Variable Data Type Description
avgEntryPrice String Average executed buy/sell price for your current long/short position
bankruptPrice String Bankruptcy price
base String Base Currency code, for example, 'BTC'
code String Applicable for futures only. 'FP' for futures, null for spot
commission String Total commission paid/received since opening the position.Positive sign means received
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 received, negative means paid
fundingStatus Integer Funding status, 0:settling, 1:settled
posMargin String Position margin
leverage String Position leverage
liquidationPrice String The liquidation price after the trade was processed
marketPrice String Market price. (best bid + best ask)/2
openTime String Position creation timestamp in UTC
quote String Base Currency code, for example, 'BTC'
realisedPnl String Realised profit and loss since opening this position
unrealisedPnl String Unrealised profit and loss
riskyPrice String Risky price, this is for internal processing only
settleType String Settlement type (INVERSE, VANILLA or QUANTO) More details on Settlement types.
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
userID String User id

Retrieve Futures Trades

Description

This endpoint is used to retrieve execution details for your futures orders.

HTTP Request

GET /v2/futures/trades

Query String Parameters
import requests

params = {
           "symbol":"BTCUSDFP"
         }
response = requests.get('https://api.aax.com/v2/futures/trades', params=params, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/trades'
data="?symbol=BTCUSDFP"
verb='GET'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}${data}"`
echo "result: $output"
Name Required Data Type Description
pageNum No Integer Pagination page number, default '1'
pageSize No Integer Pagination page size, default '10'
orderID No String AAX order ID
symbol No String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
base No String Base Currency code, for example, 'BTC'
quote No String Quote Currency code, for example, 'BTC'
startDate No String Search starts date, format to use: yyyy-mm-dd
endDate No String Search ends date, format to use: 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, STOP, LIQ, MARKET-CLOSING, LIMIT-CLOSING'
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "list":[
         {
            "base":"BTC",
            "commission":"0.00000913",
            "createTime":"2019-11-12T07:05:52Z",
            "filledPrice":"8769",
            "filledQty":"-100",
            "id":"114380149774995456",
            "leavesQty":"0",
            "leverage":null,
            "liqType":1,
            "liquidationPrice":null,
            "orderID":"wJXURIFBT",
            "tradeID":"g04GsqjJT8vl",
            "orderStatus":3,
            "orderType":1,
            "quote":"USD",
            "realisedPnl":"-0.00000196",
            "side":2,
            "symbol":"BTCUSDFP",
            "taker":true,
            "transactTime":"2019-11-12T07:05:52Z",
            "updateTime":null,
            "timeInForce":1,
            "userID":"216214"
         },
         {
            "base":"BTC",
            "commission":"0.00000913",
            "createTime":"2019-11-12T07:05:52Z",
            "filledPrice":"8770.5",
            "filledQty":"100",
            "id":"114380147677843457",
            "leavesQty":"0",
            "leverage":null,
            "liqType":0,
            "liquidationPrice":null,
            "orderID":"wJXUHKvFn",
            "tradeID":"E03GseMJLjfn",
            "orderStatus":3,
            "orderType":1,
            "quote":"USD",
            "realisedPnl":"0",
            "side":1,
            "symbol":"BTCUSDFP",
            "taker":true,
            "transactTime":"2019-11-12T07:05:52Z",
            "updateTime":null,
            "timeInForce":1,
            "userID":"216214"
         },
         ...
      ],
      "pageNum":1,
      "pageSize":10,
      "total":15
   },
   "message":"success",
   "ts":1573545435652
}
Variable Data Type Description
base String Base Currency code, for example, 'BTC'
commission String Total commission paid/received since opening the position.Positive sign means received
filledPrice String Fill price for the trade
filledQty String Filled quantity for the trade
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
leavesQty String Outstanding quantity of the order that remains to be filled
leverage String Position leverage
liqType Integer Liquidation type for futures,'0:General,1:USER-CLOSE-LIQ, 2:LIQ, 3:TAKE-PROFIT-LIQ, 4:STOP-LOSS-LIQ'. More details on liqType.
liquidationPrice String The liquidation price after the trade was processed
orderID String AAX order ID
tradeID String Trade ID
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
quote String Base Currency code, for example, 'BTC'
realisedPnl String Realised profit and loss since opening this position
side Integer 'Long' or 'Short' the contract. e.g. 'BUY, SELL'
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
transactTime String Last execution time
updateTime String Last update time of the order
userID String User id
pageNum Integer Pagination page number
pageSize Integer Pagination page size
total Integer Total number of records returned from the search

Retrieve Futures Open Orders

Description

This endpoint is used to retrieve futures open orders.

HTTP Request

GET /v2/futures/openOrders

Query String Parameters
import requests

params = {
           "symbol":"BTCUSDFP"
         }
response = requests.get('https:/api.aax.com/v2/futures/openOrders', params=params, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/openOrders'
data="?symbol=BTCUSDFP"
verb='GET'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}${data}"`
echo "result: $output"
Name Required Data Type Description
pageNum No Integer Pagination page number, default '1'
pageSize No Integer Pagination page size, default '10'
symbol No String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
orderID No String AAX order ID
side No String Filter on the direction of the trade, 'BUY or SELL, Long:BUY, Short:SELL'
clOrdID No String Client order ID
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "list":[
         {
            "avgPrice":"0",
            "base":"BTC",
            "clOrdID":"aax_futures",
            "code":"FP",
            "commission":"0",
            "createTime":"2019-11-12T10:22:03Z",
            "cumQty":"0",
            "id":"114429520856076288",
            "isTriggered":false,
            "lastPrice":"0",
            "lastQty":null,
            "leavesQty":"100",
            "leverage":"1",
            "liqType":0,
            "marketPrice":"8759.25",
            "orderID":"wKQf3hpV7",
            "orderQty":"100",
            "orderStatus":1,
            "orderType":2,
            "price":"8000",
            "quote":"USD",
            "rejectCode":0,
            "rejectReason":null,
            "settleType":"INVERSE",
            "side":1,
            "stopPrice":"0",
            "symbol":"BTCUSDFP",
            "transactTime":null,
            "updateTime":"2019-11-12T10:22:03Z",
            "timeInForce":1,
            "execInst": "",
            "userID":"216214"
         }
      ],
      "pageNum":1,
      "pageSize":1,
      "total":1
   },
   "message":"success",
   "ts":1573554124003
}
Variable Data Type Description
avgPrice String Average execution price
base String Base Currency code, for example, 'BTC'
clOrdID String Client order ID
code String Applicable for futures only. 'FP' for futures, null for spot
commission String Total commission paid/received for this order.
createTime String Time at which the order was submitted
cumQty String Cumulative filled quantity of the order
lastPrice String Price of the last fill
lastQty String Quantity of the last fill
leavesQty String Outstanding quantity of the order that remains to be filled
leverage String Position leverage
liqType Integer Liquidation type for futures,'0:General,1:USER-CLOSE-LIQ, 2:LIQ, 3:TAKE-PROFIT-LIQ, 4:STOP-LOSS-LIQ'. More details on liqType.
marketPrice String Market price. (best bid + best ask)/2
orderID String AAX order ID
orderQty String Order quantity
rejectCode String Order rejection code
rejectReason String Reason why the order was rejected
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
price String Limit price in limit and stop-limit order
quote String Base Currency code, for example, 'BTC'
settleType String Settlement type (INVERSE, VANILLA or QUANTO) More details on Settlement types.
side Integer 'Long' or 'Short' the contract. e.g. 'BUY, SELL'
stopPrice String Trigger price for stop-limit order or stop order
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
transactTime String Last execution time
updateTime String Last update time of the order
timeInForce String '1: GTC, 3: IOC, 4: FOK'
execInst String Post-Only or ''
userID String User id
pageNum Integer Pagination page number
pageSize Integer Pagination page size
total Integer Total number of records returned from the search

Retrieve Futures Historical Order(s)

Description

This endpoint is used to retrieve historical orders.

HTTP Request

GET /v2/futures/orders

Query String Parameters
import requests

params = {
           "symbol":"BTCUSDFP",
           "orderType":"LIMIT"
         }
response = requests.get('https:/api.aax.com/v2/futures/orders', params=params, auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/orders'
data="?symbol=BTCUSDFP&orderType=LIMIT"
verb='GET'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}${data}"`
echo "result: $output"
Name Required Data Type Description
pageNum No Integer Pagination page number, default '1'
pageSize No Integer Pagination page size, default '10'
symbol No String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
orderID No String AAX order ID
base No String Base Currency code, for example, 'BTC'
quote No String Quote Currency code, for example, 'BTC'
orderStatus No Integer Status of orders to include in the search, '1:new, 2:filled, 3:cancel'
startDate No String Search starts date, format to use: yyyy-mm-dd
endDate No String Search ends date, format to use: yyyy-mm-dd
side No String Filter on the direction of the trade, 'BUY or SELL, Long:BUY, Short:SELL'
orderType No String Types of order to include in the search, 'MARKET, LIMIT, STOP, STOP-LIMIT'
clOrdID No String Client order ID
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "list":[
         {
            "avgPrice":"8768.99999999484997",
            "base":"BTC",
            "clOrdID":null,
            "code":"FP",
            "commission":"0.00000913",
            "createTime":"2019-11-12T07:05:52Z",
            "cumQty":"100",
            "id":"114380149603028993",
            "isTriggered":false,
            "lastPrice":"8769",
            "lastQty":"100",
            "leavesQty":"0",
            "leverage":"1",
            "liqType":1,
            "marketPrice":"8769.75",
            "orderID":"wJXURIFBT",
            "orderQty":"100",
            "orderStatus":3,
            "orderType":1,
            "price":"8769.75",
            "quote":"USD",
            "rejectCode":0,
            "rejectReason":null,
            "settleType":"INVERSE",
            "side":2,
            "stopPrice":"0",
            "symbol":"BTCUSDFP",
            "transactTime":"2019-11-12T07:05:52Z",
            "updateTime":"2019-11-12T07:05:52Z",
            "timeInForce":1,
            "execInst": "",
            "userID":"216214"
         },
         ...
      ],
      "pageNum":1,
      "pageSize":10,
      "total":21
   },
   "message":"success",
   "ts":1573546960172
}
Variable Data Type Description
avgPrice String Average execution price
base String Base Currency code, for example, 'BTC'
clOrdID String Client order ID
code String Applicable for futures only. 'FP' for futures, null for spot
commission String Total commission paid/received for this order.
createTime String Time at which the order was submitted
cumQty String Cumulative filled quantity of the order
lastPrice String Price of the last fill
lastQty String Quantity of the last fill
leavesQty String Outstanding quantity of the order that remains to be filled
leverage String leverage
liqType Integer Liquidation type for futures,'0:General,1:USER-CLOSE-LIQ, 2:LIQ, 3:TAKE-PROFIT-LIQ, 4:STOP-LOSS-LIQ'. More details on liqType.
marketPrice String Market price. (best bid + best ask)/2
orderID String AAX order ID
orderQty String Order quantity
rejectCode String Order rejection code
rejectReason String Reason why the order was rejected
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
price String Limit price in limit and stop-limit order
quote String Base Currency code, for example, 'BTC'
settleType String Settlement type (INVERSE, VANILLA or QUANTO) More details on Settlement types.
side Integer 'Long' or 'Short' the contract. e.g. 'BUY, SELL'
stopPrice String Trigger price for stop-limit order or stop order
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
transactTime String Last execution time
updateTime String Last update time of the order
timeInForce String '1: GTC, 3: IOC, 4: FOK'
execInst String Post-Only or ''
userID String User id
pageNum Integer Pagination page number
pageSize Integer Pagination page size
total Integer Total number of records returned from the search

Get Predicted Funding Fee

Description

This endpoint is used to get predicted funding fee

HTTP Request

GET /v2/futures/funding/predictedFundingFee/{symbol}

Path Parameters
import requests

response = requests.get('https://api.aax.com/v2/futures/funding/predictedFundingFee/BTCUSDFP', auth=auth).json()
print(response)
#!/usr/bin/env bash

domain="https://api.aax.com"
api_key=""
api_secret=""
path='/v2/futures/funding/predictedFundingFee/'
data="BTCUSDFP"
verb='GET'
expires=`date +%s000`
std_sign=`echo -n "${expires}:${verb}${path}${data}" | openssl dgst -sha256 -hmac ${api_secret}`
sign=`echo ${std_sign} | tr -s ' '|cut -d' ' -f2`
output=`curl -s -H "accept: application/json;charset=UTF-8" \
 -H 'Content-Type: application/json;charset=UTF-8' \
 -H "X-ACCESS-NONCE:${expires}" \
 -H "X-ACCESS-KEY:${api_key}" \
 -H "X-ACCESS-SIGN:${sign}" \
 -X ${verb} "${domain}${path}"`
echo "result: $output"
Name Required Data Type Description
symbol Yes String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
Output Variable

The above command returns JSON structured like this:

{
   "code":1,
   "data":{
      "predictedFundingRate": "0.001",
      "predictedFundingFee": "0.000234",
      "nextFundingTime":  "2020-02-12T08:00:00Z"
   },
   "message":"success",
   "ts":1573542445411
}
Variable Data Type Description
predictedFundingRate String Predicted funding rate. When the funding rate is positive, longs pay shorts. When it is negative, shorts pay longs.
predictedFundingFee String Predicted funding fee
nextFundingTime String Next funding time with UTC time

Websocket

Overview

Websocket

WebSocket channels provides real-time market data streaming and notifications which work using a publish-subscribe communication model.

Message Encoding

Messages sent and received via the AAX websocket channels are encoded in JSON format.

Rate Limits

Websocket

One IP should not exceed 600 connection requests per minute. If this limit is reached, you will receive a HTTP 429 error.

Market Data

Websocket

General

Websocket URL

Market data websockets provide real-time data and do not require API key authentication.

base url: wss://realtime.aax.com/marketdata/v2

Public Streams

All websocket data can be accessed via wss://realtime.aax.com/marketdata/v2/{streamName1}/{streamName2}

Each connection can subscribe to one or multiple streams. There are different streams for different market data and each has specific update intervals. Below is a list of streams available:

Subscriptions

You can subscribe to multiple streams like this:

import websocket
import json


STREAM_HOST = 'wss://realtime.aax.com/marketdata/v2/'
def on_open(ws):
    ws.send(json.dumps({"e": "subscribe", "stream": "BTCUSDT@book_50"}))
    ws.send(json.dumps({"e": "subscribe", "stream": "tickers"}))
    ws.send(json.dumps({"e": "subscribe", "stream": "BTCUSDT@1m_candles"}))


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(STREAM_HOST,
                                on_open=on_open,
                                on_message=on_message,
                                on_error=on_error,
                                on_close=on_close)
    ws.run_forever(ping_interval=1)

Instead of specifying stream names in the URL, you can also subscribe to and unsubscribe from any streams on-demand, by sending:

Example

{"e":"subscribe”,”stream”:”BTCUSDT@book_50“}

or

{“e”:”unsubscribe”,”stream”:”BTCUSDT@book_50"}

Example of response:

{“e”:”reply”,”status”:”ok”}

or

{“e”:”reply”,”status”:”error”}

Empty Event

Server may publish empty events if there is nothing to send right after a new connection is established.

Example

{"e":"empty"}

System Event

Server may publish system events to indicate a system status change. Possible status are:

Example

{"e":"system","status":"active"}

Orderbook

import websocket

ws = websocket.WebSocket()
ws.connect("wss://realtime.aax.com/marketdata/v2/")
ws.send('{"e": "subscribe", "stream": "BTCUSDT@book_50"}')
while True:
    print("Received '%s'" % ws.recv())

Snapshot of the top N bids and asks, updated every 300 milliseconds. Only pushes when there are changes in the orderbook.

Parameters
Parameter Required Data Type Description
symbol Yes String The trading symbol to trade. For spot, convention is 'Base Currency + Quote Currency', i.e. BTCUSDT; for futures, convention is 'Base Currency + Quote Currency +FP', i.e. BTCUSDTP
level Yes Integer depth.Support 20, 50
Message Variable

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
}
Variable Data Type Description
e String Event name
t Integer Event time (unit: milliseconds)
asks Array List of bids currently in orderbook
bids Array List of asks currently in orderbook

Trades

import websocket

ws = websocket.WebSocket()
ws.connect("wss://realtime.aax.com/marketdata/v2/")
ws.send('{"e": "subscribe", "stream": "BTCUSDT@trade"}')
while True:
    print("Received '%s'" % ws.recv())

For each new connection, our server returns the last 50 trades.

Parameters
Parameter Required Data Type Description
symbol Yes String The trading symbol to trade. For spot, convention is 'Base Currency + Quote Currency', i.e. BTCUSDT; for futures, convention is 'Base Currency + Quote Currency +FP', i.e. BTCUSDTP
Message Variable

The above command returns JSON structured like this:

{
   "e":"BTCUSDT@trade",
   "p":"10924.30000000",
   "q":"0.002000",
   "t":1561445393223
}
Variable Data Type Description
e String Event name
t Integer Event time (unit: milliseconds)
p String Price (Positive for Buy, Negative for Sell, e.g. -6573.2 for Sell)
q String Quantity

Tickers

import websocket

ws = websocket.WebSocket()
ws.connect("wss://realtime.aax.com/marketdata/v2/")
ws.send('{"e": "subscribe", "stream": "tickers"}')
while True:
    print("Received '%s'" % ws.recv())

The response contains the open, high, low, close and volume for the last 24 hours. The server initially sends the data for all the tickers immediately after connection, and then only sends the tickers that have changed since the last update every N seconds.

Message Variable

The above command returns JSON structured like this:


{
"e":"tickers",
"t":1561543614756,
"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"}
             ]
}
Variable Data Type Description
e String Event name
t Integer Event time (unit: milliseconds)
s String Symbol
o String Open price
h String High price
l String Low price
c String Close price
v String Quote volume

Candlesticks

import websocket

ws = websocket.WebSocket()
ws.connect("wss://realtime.aax.com/marketdata/v2/")
ws.send('{"e": "subscribe", "stream": "BTCUSDT@1m_candles"}')
while True:
    print("Received '%s'" % ws.recv())

The last candlestick is being added to the Candlestick time series every second.

Parameters
Parameter Required Data Type Description
symbol Yes String The trading symbol to trade. For spot, convention is 'Base Currency + Quote Currency', i.e. BTCUSDT; for futures, convention is 'Base Currency + Quote Currency +FP', i.e. BTCUSDTP
timeframe Yes Integer Candlestick interval
Message Variable

The above command returns JSON 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"
}
Variable Data Type Description
e String Event name
t Integer Event time (unit: milliseconds)
h String High price
l String Low price
o String Open price
s Integer Start time of the candlestick(seconds)
v String Trade volume
c String Close price

Mark Price

import websocket

ws = websocket.WebSocket()
ws.connect("wss://realtime.aax.com/marketdata/v2/")
ws.send('{"e": "subscribe", "stream": "BTCUSDFP@mark"}')
while True:
    print("Received '%s'" % ws.recv())
Parameters
Parameter Required Data Type Description
symbol Yes String The trading symbol to trade. For spot, convention is 'Base Currency + Quote Currency', i.e. BTCUSDT; for futures, convention is 'Base Currency + Quote Currency +FP', i.e. BTCUSDTP
Message Variable

The above command returns JSON structured like this:

{
  "e":"BTCUSDFP@mark",
  "p":"9000.12000000",
  "t":1572858173963
}
Variable Data Type Description
e String Event name
p String Mark price
t Integer Event time (unit: milliseconds)

User Notification

General

AAX uses the SocketCluster protocol to implement WebSocket services that subscribe to user data.For more information about SocketCluster, please refer to SocketCluster Protocol and SocketCluster client driver

Event format

Basic event sending format:

{"event": "eventName", "data": "eventData",cid:"eventID"}

Note

cid: Each emitted event can have call ID (if specified, it needs to be unique for the life of the client session)

You can use UUID strings, but for efficiency, we recommend using a number starting a 1 and incrementing it with each event sent.

Websocket URL

The notification channel provides real-time alerts for changes in your orders, positions and balance. It requires API key for authentication:

Base URL: wss://stream.aax.com/notification/v2/

WebSocket Authentication

Similarly to RESTful API, you need to authenticate your connection using your API Key in order to subscribe to the private channels. If you wish to subscribe to user-locked streams, you must authenticate first.

Send command format:

{"event": "login", "data": {"apiKey":${KEY},"nonce":${NONCE},"signature":${SIGNATURE}}}

Example of authentication message:

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

Subscriptions

AAX allows subscribing to real-time data. This access is not rate-limited once connected and is the best way to get the most up-to-date data to your programs.

To subscribe user private information:

{"event":"#subscribe","data":{"channel":"user/' + ${USER_ID} + '"},"cid":2}

Event response

Response data format:

{ "event": “event name”, "data":responseData,"ts": responseTime}

Handshake

Before you can send custom events to the SocketCluster server, you first need to establish a WebSocket connection to a SocketCluster server and then perform a handshake to initiate the socket.

As soon as the WebSocket connection is opened, your client should emit a special #handshake event to the server.

the #handshake event message should look like this:

{

  event: '#handshake',

    // this as an empty object.

  data: {},

    // This can be any number/string, just make sure that it is unique for the life of the client session.

  cid: 1 }

As soon as it receives the event, your server should send back a handshake response event message in this format:

{

  // The rid will match the cid from the #handshake event.

  "rid": 1,

  "data": {

    // This is the ID for the SC connection assigned by the server.

  "id": "Y7Uw-jHCJP-gld4QAAAA",

    // Because we did not send any auth token, this will be false.

  "isAuthenticated": false,

    // SC uses a ping/pong mechanism for checking if a connection is alive.

    // This value is the number of milliseconds of inactivity after which the SC server

    // will mark this connections as dead.

  "pingTimeout": 10000

       }

}

Heartbeat

As mentioned above, SocketCluster has a ping/pong mechanism for checking whether or not a connection is still alive.The ping interval is 20s

Ping message

#1

Pong message

#2

Notification

from websocket import create_connection
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'

ws = create_connection("wss://stream.aax.com/notification/v2/")

nonce = str(int(1000 * time.time()))
message = nonce + ':' + API_KEY
signature = hmac.new(API_SECRET.encode(), message.encode(), hashlib.sha256).hexdigest()

req = '{"event":"#handshake","cid":1}'
print(req)
ws.send(req)
print("Received '%s'" % ws.recv())

req = '{"event":"login","data":{"apiKey":"' + API_KEY + '","nonce":' + nonce + ',"signature":"' + signature + '"}}'
print(req)
ws.send(req)
print("Received '%s'" % ws.recv())

req = '{"event":"#subscribe","data":{"channel":"user/' + USER_ID + '"},"cid":2}'
print(req)
ws.send(req)
print("Received '%s'" % ws.recv())

while True:
  message = ws.recv()
  print("Received '%s'" % message)
  if message == '#1':
    ws.send("#2")  # Pong.

The notification channel sends user private information including updates to:

user balance spot order futures orders futures position futures leverage

Channel & Event
Type Channel Event Description
Private user/{USER ID} USER_BALANCE Broadcast user's balance change information
Private user/{USER ID} SPOT Broadcast spot order status
Private user/{USER ID} FUTURES Broadcast futures order, leverage, position information

Event: USER_BALANCE

When the balance of any of your accounts changes, a notification will be sent.

{
   "data":{
      "userID":"213409",
      "purseType":"coin",
      "currency":"BTC",
      "available":"0.12127194",
      "unavailable":"0.01458122"
   },
   "event":"USER_BALANCE"
}

When the balance of any of your accounts changes, a notification will be sent.

Message Variable
Variable Data Type Description
location String (Not yet supported)
userID String User id
currency String Currency code (e.g. BTC)
purseType String Account type
available String Available balance
unavailable String Locked balance

Event: SPOT

The event returns JSON structured like this

{ 
   "data":{ 
      "avgPrice":"0",
      "base":"BTC",
      "clOrdID":"aax",
      "commission":"0",
      "createTime":"2019-11-13T06:35:53Z",
      "cumQty":"0",
      "id":"114734989961183232",
      "isTriggered":false,
      "lastPrice":"0",
      "lastQty":"0",
      "leavesQty":"0",
      "orderID":"wQgmCG7zr",
      "orderQty":"0.05",
      "orderStatus":1,
      "orderType":2,
      "price":"8000",
      "quote":"USDT",
      "rejectCode":0,
      "rejectReason":null,
      "side":1,
      "stopPrice":"0",
      "symbol":"BTCUSDT",
      "transactTime":"2019-11-13T06:33:34Z",
      "updateTime":"2019-11-13T06:35:53Z",
      "timeInForce":1,
      "userID":"213409"
   },
   "event":"SPOT"
}

When your balance changes, you will receive notifications.

Message Variable
Variable Data Type Description
avgPrice String Average execution price
base String Base Currency code, for example, 'BTC'
clOrdID String Your customized Order ID. The clOrdID type should only use letters. Both uppercase and lowercase letters are supported and a maximum of 20 characters are allowed.
commission String Total commission paid/received for this order.
createTime String Time at which the order was submitted
lastPrice String Price of the last fill
lastQty String Quantity of the last fill
cumQty String Cumulative filled quantity of the order
updateTime String Last update time of the order
isTriggered Boolean Used by STOP_LIMIT and STOP, True or False
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
price String Limit price in limit and stop-limit order
quote String Quote Currency code, for example, 'BTC'
rejectCode String Order rejection code
rejectReason String Reason why the order was rejected
leavesQty String Outstanding quantity of the order that remains to be filled
orderID String AAX order ID
side Integer Buy or Sell the Base Currency, '1:Buy, 2:Sell'
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
stopPrice String Trigger price for stop-limit order or stop order
symbol String The trading symbol to trade. Convention is 'Base Currency + Quote Currency'
orderQty String Order quantity
transactTime String Last execution time
timeInForce String '1: GTC, 3: IOC, 4: FOK'
userID String User id

Event: FUTURES

The event returns JSON structured like this

{ 
   "data":{ 
      "closed":{ 
         "base":"BTC",
         "commission":"0.00002711",
         "createTime":null,
         "filledPrice":"8560.5",
         "filledQty":"-290",
         "id":"114744152334385153",
         "leavesQty":"0",
         "leverage":"1",
         "liqType":1,
         "liquidationPrice":"4392.5",
         "orderID":"wQqrE7ly9",
         "orderStatus":3,
         "orderType":1,
         "quote":"USD",
         "realisedPnl":"-0.00101840",
         "side":2,
         "symbol":"BTCUSDFP",
         "taker":true,
         "transactTime":"2019-11-13T07:12:17Z",
         "updateTime":null,
         "userID":"213409"
      },
      "opens":{ 
         "buy":0,
         "sell":0,
         "symbol":"BTCUSDFP"
      },
      "order":{ 
         "avgPrice":"8566.60442994073443",
         "base":"BTC",
         "clOrdID":null,
         "code":"FP",
         "commission":"0.00002803",
         "createTime":"2019-11-13T07:12:17Z",
         "cumQty":"300",
         "id":"114744151591993346",
         "isTriggered":false,
         "lastPrice":"8560.5",
         "lastQty":"290",
         "leavesQty":"0",
         "leverage":"1",
         "liqType":1,
         "marketPrice":"8854.25",
         "orderID":"wQqrE7ly9",
         "orderQty":"300",
         "orderStatus":3,
         "orderType":1,
         "price":"8854.25",
         "quote":"USD",
         "rejectCode":0,
         "rejectReason":null,
         "settleType":"INVERSE",
         "side":2,
         "stopPrice":"0",
         "symbol":"BTCUSDFP",
         "transactTime":"2019-11-13T07:12:17Z",
         "updateTime":"2019-11-13T07:12:17Z",
         "timeInForce":1,
         "execInst": "",
         "userID":"213409"
      },
      "position":{ 
         "avgEntryPrice":"0",
         "bankruptPrice":"0",
         "base":"BTC",
         "code":"FP",
         "commission":"0",
         "currentQty":"0",
         "funding":"0",
         "fundingStatus":0,
         "id":"114743189926166528",
         "leverage":"1",
         "liquidationPrice":"0",
         "marketPrice":null,
         "openTime":null,
         "stopLossPrice":"8200",
         "stopLossSource":1,
         "takeProfitPrice":"8780",
         "takeProfitSource":1,
         "posLeverage":"0.00",
         "posMargin":"0",
         "quote":"USD",
         "realisedPnl":"0",
         "unrealisedPnl": "0",
         "riskLimit":"1000000",
         "riskyPrice":"0",
         "settleType":"INVERSE",
         "symbol":"BTCUSDFP",
         "userID":"213409"
      }
   },
   "event":"FUTURES"
}

You will receive notifications in the below cases:

Message Variable
Variable Data Type Description
closed Object Close position information
base String Base Currency in a trading pair
commission String Total commission paid/received since opening the position.Positive sign means received
filledPrice String Fill price for the trade
filledQty String Filled quantity for the trade
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
leavesQty String Outstanding quantity of the order that remains to be filled
leverage String leverage
liqType Integer Liquidation type for futures,'0:General,1:USER-CLOSE-LIQ, 2:LIQ, 3:TAKE-PROFIT-LIQ, 4:STOP-LOSS-LIQ'. More details on liqType.
liquidationPrice String The liquidation price after the trade was processed
margin String The amount of margin locked by each position
orderID String AAX order ID
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
quote String Quote Currency in a trading pair
realisedPnl String Realised profit and loss since opening this position
unrealisedPnl String Unrealised profit and loss
side Integer Filter on the direction of the trade, 'BUY or SELL, Long:BUY, Short:SELL'
taker Boolean True: taker, False: maker
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
transactTime String Last execution time
userID String user id
opens Object Open order amount information
buy Integer The total buy amount in open orders
sell Integer The total buy amount in open orders
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
order Object order information
avgPrice String Average execution price
base String Base Currency code, for example, 'BTC'
clOrdID String Client order ID
code String Applicable for futures only. 'FP' for futures, null for spot
commission String Total commission paid/received for this order.
createTime String Time at which the order was submitted
cumQty String Cumulative filled quantity of the order
lastPrice String Price of the last fill
leavesQty String Outstanding quantity of the order that remains to be filled
leverage String leverage
liqType Integer Liquidation type for futures,'0:General,1:USER-CLOSE-LIQ, 2:LIQ, 3:TAKE-PROFIT-LIQ, 4:STOP-LOSS-LIQ'. More details on liqType.
marketPrice String Market price. (best bid + best ask)/2
orderID String AAX order ID
orderQty String Order quantity
rejectCode String Order rejection code
rejectReason String Reason why the order was rejected
orderStatus Integer Order status,'0:Pending-New, 1:New, 2:Partially-Filled, 3:Filled, 4:Cancel-Reject, 5:Canceled, 6:Rejected, 10:Expired, 11:Business-Reject'
orderType Integer Order type, '1:Market Order,2:Limit Order,3:Stop Order,4:Stop-Limit Order,7:Stop Loss,8:Take Profit'
price String Limit price in limit and stop-limit order
quote String Base Currency code, for example, 'BTC'
settleType String Settlement type (INVERSE, VANILLA or QUANTO) More details on Settlement types.
side Integer 'Long' or 'Short' the contract. e.g. 'BUY, SELL'
stopPrice String Trigger price for stop-limit order or stop order
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
transactTime String Last execution time
updateTime String Last update time of the order
timeInForce String '1: GTC, 3: IOC, 4: FOK'
execInst String Post-Only or ''
userID String User id
position Object position information
avgEntryPrice String Average executed buy/sell price for your current long/short position
bankruptPrice String Bankruptcy price
base String Base Currency code, for example, 'BTC'
code String Applicable for futures only. 'FP' for futures, null for spot
commission String Total commission paid/received since opening the position.Positive sign means received
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 received, negative means paid
fundingStatus Integer Funding status, 0:settling, 1:settled
posMargin String Position margin
leverage String Position leverage
liquidationPrice String The liquidation price after the trade was processed
marketPrice String Market price. (best bid + best ask)/2
openTime String Position creation timestamp in UTC
stopLossPrice String Stop loss price
stopLossSource Integer Trigger price type.'1: Last Price'
takeProfitPrice String Take profit price
takeProfitSource Integer Trigger price type.'1: Last Price'
quote String Base Currency code, for example, 'BTC'
realisedPnl String Realised profit and loss since opening this position
riskyPrice String Risky price, this is for internal processing only
settleType String Settlement type (INVERSE, VANILLA or QUANTO) More details on Settlement types.
symbol String Trading symbol. Convention is 'Base Currency + Quote Currency + FP'
userID String User id
event String Event name

Errors

Error Code Meaning
1 Success
10003 Parameter validation error
10006 Session expired, please relogin
10007 Invalid authentication key or token
11007 Invalid key format
20001 Insufficient balance. Please deposit to trade.
20009 Order amount must be positive
30001 The order is being submitted, please try again later
30004 Minimum quantity is {0}
30005 Quantity maximum precision is {0} decimal places
30006 Price maximum precision is {0} decimal places
30007 Minimum price is {0}
30008 Stop price maximum precision is {0} decimal places
30009 Stop Price cannot be less than {0}
30010 Market price cannot be empty
30011 The order is being cancelled, please wait.
30012 Unknown currency
30013 Unknown symbol
30014 Futures order cannot be found
30015 This is not an open order and cannot modified
30016 No position found
30017 The current close position is 0. It is recommended that you cancel the current order closing order.
30018 Order price cannot be greater than {0}
30019 Order quantity cannot be greater than {0}
30020 Order price must be a multiple of {0}
30021 Margin adjustement must be greater than 0
30022 New quantity must be greater than filled quantity
30023 Order failed, please try again
30024 TimeInForce error, only GTC or IOC are allowed
30025 TimeInForce error, only GTC is allowed
30026 Quantity is not a multiple of {0}
30027 Close position failed, it is recommended that you cancel the current order and then close the position.
30028 Symbol cannot be traded at this time
30029 Modified quantity or price cannot be empty
30030 Price cannot be specified for market orders
30031 Liquidation orders cannot be modified
30032 Leverage cannot be greater than {0}
30033 Leverage cannot be smaller than {0}
30034 The max number of open orders is {0}. To place a new order, please cancel a previous one
30035 The max number of {0} open orders is {1}. To place a new order, please cancel a previous one
30036 Liquidation is in progress, please try again later
30037 Once stop limit order triggered, stop price cannot be amended
30038 The total value of your orders has exceeded the current risk limit. Please adjust the risk limit
30039 Your risk limit has now been changed to {0}, your maximum leverage less than 1, please readjust accordingly
30040 Order status has changed, please try again later
30041 Liquidation orders cannot be cancelled
30042 Order cannot be placed as you will be breaching you max limit value of {1} BTC for {0}
30043 The risk limit cannot be less than 0
30044 Timeout cannot be greater than 60 minutes
30045 Side is not valid, it should be BUY or SELL
30046 Order type is not valid, it should be MARKET or LIMIT or STOP-LIMIT or STOP
30047 The order is closed. Can't cancel
30048 Market orders cannot be modified
30049 The order is being modified, please wait
30050 Maximum 10 orders
40004 Requested ressource doesn't exist
40009 Too many requests
41001 Incorrect HTTP request
41002 Unsupported HTTP request method
42001 Duplicated data entry, please check and try again
50001 Server side exception, please try again later
50002 Server is busy, please try again later