简介
欢迎查看AAX API文档,我们提供功能丰富的 API 接口以满足您在AAX的算法交易需求。
RESTFul API接口为您提供安全的访问权限,以便管理您的订单和仓位等信息。也可以使用低延迟 WebSocket 通道来订阅市场数据、订单状态等更多信息。
我们提供了基于Shell和Python开发语言的代码示例及帮助文档,可供您参考。
更新日志
2020.12.04
新增
- 在预测资金费率API中新增indexPrice字段
- GET /v2/futures/funding/predictedFunding/{symbol}
优化
- 更新API响应信息中的datetime格式为'yyyy-MM-ddTHH:mm:ss.SSSZ'
2020.10.16
新增
- 新增多账户余额查询API
- GET /v2/account/balances
- 新增资产划转API
- POST /v2/account/transfer
- 查询币币和合约交易详情API响应结果中新增tradeID字段
- GET /v2/spot/trades
- GET /v2/futures/trades
优化
- 调整WebSocket notification信息流中USER_BALANCE事件的发送信息
- 淘汰旧版查询账户余额API
- GET /v2/user/balances
2020.09.01
新增
- 在市场行情类接口中添加 查询未平仓合约数 API
- GET /v2/futures/position/openInterest
- 在 Instruments API中新增结算类型及币种字段
- settleType and settleCurrency
2020.08.15
新增
- 在合约交易中新增仓位止盈止损API
- POST /v2/futures/position/sltp
- 在合约订单类API中新增两种liqType类型: TAKE-PROFIT-LIQ和STOP-LOSS-LIQ
- 在合约订单类API中新增两种orderType类型: Stop Loss和Take Profit
- 在仓位类API中新增止盈止损相关字段:stopLossPrice、stopLossSource、takeProfitPrice、takeProfitSource
- 在合约交易中新增查询上个周期的资金费率API
- GET /v2/futures/funding/prevFundingRate/{symbol}
- 在市场行情中新增获取标记价格API
- GET /v2/market/markPrice
- 在市场行情中新增获取当前指数K线数据API
- GET /v2/market/candles/index
2020.07.20
新增
- 新增错误码30000判断订单存在状态
优化
- 优化调整保证金时锁币的流程
- 优化错误码30047对应的错误信息
- 优化Notification的Websocket 心跳间隔为20s
2020.07.08
新增
- 在合约交易中新增调整保证金接口:
- GET /v2/futures/position/margin
- 在行情数据中新增深度信息接口:
- GET /v2/markets/orderbook
- 在行情数据中新增最近24小时行情数据接口:
- GET /v2/market/tickers
- 在行情数据中新增获取当前K线数据接口:
- GET /v2/market/candles
- 在行情数据中新增近期市场成交记录接口:
- GET /v2/market/trades
- 在查询Spot历史订单API中增加因为余额不足被拒历史订单的记录
- 在查询Futures历史订单API中增加因为余额不足被拒历史订单的记录
优化
- 优化撤单失败时的错误信息描述
- 优化部分参数输入异常时的错误信息描述
- 优化订单状态变化时修改订单失败的错误信息描述
2020.06.12
优化
- 统一userID字段的类型为string
- 优化市场行情的Websocket API的参数描述
- 删除弃用的订单状态(7,8,9)
- 限制clOrdID字段的最大长度为20个字符
2020.04.30
新增
- 添加RESTful API的错误码及错误详情
- 支持合约的限价平仓功能
2020.04.28
新增
- 发布中文版API文档
2020.03.23
新增
- 在以下接口中新增execInst字段:
- POST /v2/futures/orders:用于支持合约的Post Only订单类型
- 新增合约交易类接口
- POST /v2/futures/orders/cancelAllOnTimeout:超时后撤消所有合约订单
- GET /v2/futures/funding/predictedFunding/{symbol}: 获取预测资金费率
- GET /v2/futures/funding/predictedFundingFee/{symbol} : 获取预测资金费用
- 新增现货交易接口:
- POST /v2/spot/orders/cancelAllOnTimeout: 超时后撤消所有现货订单
2020.02.24
新增
- 添加RESTful API的shell示例代码
- 添加AAX API Telegram群组
优化
- 更新Websockets API文档结构
- 优化现货和合约的撤消订单API的接口描述
- 优化WebSocket API 的市场行情及用户信息示例代码
2019.12.11
新增
- 新增标记价格的WebSocket频道
- 定义在HMAC构造中使用JSON编码进行API身份验证
优化
- 更新API身份验证示例代码
- 改进了API文档的结构
- 优化API请求和响应的字段描述
- 在合约交易下添加了有关timeInForce和liqType的解释
- 支持订阅多个的Websocket 频道
API 密钥
鉴权类接口需要使用 API 公钥 和 私钥。您可以根据需要,在此页面生成任意数量的 API 密钥。下表显示了可为每个 API 密钥设置的不同权限。
权限 | 读 | 写 |
---|---|---|
账号信息 | 默认 | -- |
现货交易 | 默认 | 可选 |
期货交易 | 默认 | 可选 |
默认情况下,API 密钥对用户数据(例如仓位、保证金、订单和交易)具有只读访问权限。若要操作订单,请将“现货交易”和/或“期货交易”设置为“可写”状态 。
REST
概览
接口
基本网址: https://api.aax.com
公共接口
公共接口可用于检索工具详细信息、资金费率等数据,并且无需进行身份验证。
私有接口
私有接口可用于管理订单和检索帐号详细信息(例如仓位)。要使用私有接口,您必须使用API密钥进行身份验证。
身份验证
可以参照以下示例使用API 密钥进行授权:
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 提供用于身份验证的 SecretAPIKey。请保护好您的私钥,切勿与他人共用。如果您已登录,请按照链接中的说明来管理您的有效密钥。
身份验证会通过发送以下 HTTP 标头完成:
X-ACCESS-KEY: 您的API公钥。
X-ACCESS-NONCE: UNIX 时间戳(以毫秒为单位),超过该时间后,请求将不再有效。这是为了防范重放攻击。
- UNIX 时间戳以毫秒为单位。例如,2019-11-06T09:30:30.423Z 将转换为 1573032630423。
- 此时间戳在到达交易引擎前会与我们的系统时间进行比较。 它不能作为队列中待处理的委托提交的取消机制。
X-ACCESS-SIGN: 您的当前请求的签名。其计算方式为:HEX(HMAC_SHA256(apiSecret, str(nonce) + ’:’ + verb + path + data))。HMAC结构的数据应与您要发送到服务器的原始信息正文相同。
可以参照以下示例检查签名计算方式是否正确:
# 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 请求
每个 HTTP 请求必须包含标头 Accept: application/json。
HTTP 响应
所有响应都将以 JSON 格式返回。
HTTP 成功
成功的 HTTP 响应的状态代码为 200。本文档提供了每个接口的返回响应示例。
HTTP 错误
响应状态代码不等于 200 的 HTTP 请求将会视为失败。如果您的请求失败,您可能会在响应正文中看到下列错误代码:
错误代码 | 含义 |
---|---|
400 | 错误的请求 - 您的请求有问题 |
401 | 未授权 - 您的 API 密钥错误 |
403 | 禁止 - 您的 API 密钥没有足够的权限来访问此资源 |
429 | 请求过多 - 您超出了 API 密钥速率限制 |
500 | 内部服务器 - 内部服务器错误 |
503 | 服务不可用 - 因维护而停止服务 |
504 | 网关超时 - 请求超时过期 |
550 | 无数据 - 您请求的数据目前不可用 |
速率限制
每个接口的请求速率限制如下:
API | 次/每秒 | 次/每分钟 | 次/每小时 |
---|---|---|---|
撤销现货订单 | 20 | 200 | 6000 |
撤销期货订单 | 20 | 200 | 6000 |
撤销所有现货订单 | 2 | 30 | 600 |
撤销所有期货订单 | 2 | 30 | 600 |
期货平仓 | 2 | 30 | 600 |
调整开仓杠杆 | 15 | 200 | |
其他需要鉴权的接口 | 10 | 150 | 5000 |
行情数据
方法 | 路径 | 描述 |
---|---|---|
GET | /v2/announcement/maintenance | 系统维护通知 |
GET | /v2/instruments | 查看所有交易对信息 |
GET | /v2/market/orderbook | 深度信息 |
GET | /v2/futures/position/openInterest | 查询未平仓合约数 |
GET | /v2/market/tickers | 最近24小时行情数据 |
GET | /v2/market/candles | 获取当前K线数据 |
GET | /v2/market/trades | 近期市场成交记录 |
GET | /v2/market/markPrice | 查看当前标记价格 |
GET | /v2/futures/funding/predictedFunding/{symbol} | 获取预测资金费率 |
GET | /v2/futures/funding/prevFundingRate/{symbol} | 查询上个周期的资金费率 |
GET | /v2/market/candles/index | 获取当前指数K线数据 |
系统维护通知
描述
此接口返回发布中的系统维护信息。
HTTP 请求
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
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
startTime | String | 系统维护预计开始时间 |
endTime | String | 系统维护预计结束时间 |
description | String | 系统维护信息 |
获取所有交易对信息
描述
此接口用于查看AAX所有交易对的信息
HTTP 请求
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
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
tickSize | String | 此交易对的最低价格变动幅度 |
lotSize | String | 交易数量可以增加/减少的幅度 |
base | String | 交易对中的基础币种 |
quote | String | 交易对中的计价币种 |
settleType | String | 结算类型(INVERSE、VANILLA 或 QUANTO)(逆向、单纯或双币种结算) 关于 结算类型的更多详细信息。 |
settleCurrency | String | 结算币种 |
minQuantity | String | 以基础货币币种进行买卖的最小下单量 |
maxQuantity | String | 以基础货币币种进行买卖的最大下单量 |
minPrice | String | 允许的最低限价或者止损价价格 |
maxPrice | String | 允许的最高限价或者止损价价格 |
status | String | 交易对的状态(ENABLE,DISABLE, ONLYREADY) |
symbol | String | 交易对名称,现货命名格式为“基础币种 + 计价币种”,例如BTCUSDT,合约命名格式为“基础币种 + 计价币种 + FP”,例如BTCUSDFP |
code | String | 仅适用于合约。‘FP’代表永续合约, 空表示现货 |
takerFee | String | 挂单费 |
makerFee | String | 吃单费 |
multiplier | String | 乘数(适用于期货) |
mmRate | String | 维持保证金率(适用于合约) |
imRate | String | 初始保证金率(适用于合约) |
type | String | 交易对类型,即现货或期货 |
深度信息
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"
功能描述
此接口用于返回指定交易对的当前市场深度数据。
HTTP 请求
GET /v2/market/orderbook
参数
参数 | 是否必须 | 类型 | 默认 | 描述 |
---|---|---|---|---|
symbol | Yes | String | 交易对名称,现货命名格式为“基础币种 + 计价币种”,例如BTCUSDT,合约命名格式为“基础币种 + 计价币种 + FP”,例如BTCUSDFP | |
level | Yes | Integer | 深度信息。支持20, 50 |
返回参数
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
e | String | 事件名称 |
t | Integer | 事件时间(单位: 毫秒) |
asks | Array | 订单簿中当前的叫价列表[price, size] |
bids | Array | 订单簿中当前的出价列表[price, size] |
查询未平仓合约数
描述
此接口用于获取指定合约交易对的当前未平仓合约数。
HTTP 请求
GET /v2/futures/position/openInterest
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
响应数据
响应示例:
{
"code":1,
"data":{
"symbol":"BTCUSDFP",
"openInterest":"1034600",
"openInterestUSD":"1034600"
},
"message":"success",
"ts":1573542445411
}
变量 | 类型 | 描述 |
---|---|---|
openInterest | String | 当前未平仓合约数 |
openInterestUSD | String | 当前未平仓合约总价值 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
最近24小时行情数据
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"
功能描述
此接口用于获取所有交易对的最近24小时的交易聚合信息。
HTTP 请求
GET /v2/market/tickers
返回参数
响应示例:
{
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"
},
]
}
变量 | 类型 | 描述 |
---|---|---|
e | String | 事件名称 |
t | Integer | 事件时间(单位: 毫秒) |
s | String | 交易对名称,现货命名格式为“基础币种 + 计价币种”,例如BTCUSDT,合约命名格式为“基础币种 + 计价币种 + FP”,例如BTCUSDFP |
o | String | 开盘价 |
h | String | 最高价 |
l | String | 最低价 |
c | String | 收盘价 |
v | String | 以报价币种计量的交易量 |
a | String | 以USD计量的交易量(只支持Futures) |
获取当前K线数据
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"
功能描述
此接口用于获取指定交易对的当前K线数据
HTTP 请求
GET /v2/market/candles
参数
参数 | 是否必须 | 类型 | 默认 | 描述 |
---|---|---|---|---|
symbol | Yes | String | 交易对名称,现货命名格式为“基础币种 + 计价币种”,例如BTCUSDT,合约命名格式为“基础币种 + 计价币种 + FP”,例如BTCUSDFP | |
timeFrame | Yes | String | 蜡烛时间区间,如1m, 3m, 5m, 15m, 30m, 1h, 2h, 3h, 4h, 8h, 1d |
返回参数
响应示例:
{
c: "9308.34000000",
e: "BTCUSDT@1m_candles",
h: "9316.97000000",
l: "9304.82000000",
o: "9304.82000000",
s: 1592548440,
t: 1592548470,
v: "4806.98608000"
}
变量 | 类型 | 描述 |
---|---|---|
e | String | 事件名称 |
t | Integer | 事件时间(单位: 毫秒) |
h | String | 最高价 |
l | String | 最低价 |
o | String | 开盘价 |
s | Integer | K 线图的开始时间(秒) |
v | String | 交易量 |
c | String | 收盘价 |
近期市场成交记录
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"
功能描述
此接口用于返回指定交易对的近期交易记录(最大2000条)。
HTTP 请求
GET /v2/market/trades
参数
参数 | 是否必须 | 类型 | 默认 | 描述 |
---|---|---|---|---|
symbol | Yes | String | 交易对名称,现货命名格式为“基础币种 + 计价币种”,例如BTCUSDT,合约命名格式为“基础币种 + 计价币种 + FP”,例如BTCUSDFP | |
limit | Yes | Integer | 交易记录数量,最大值2000 |
返回参数
响应示例:
{
"e":"BTCUSDFP@trades",
"trades":
[ { "p":"9395.50000000",
"q":"50.000000",
"t":1592563996718
},
{ "p":"9395.50000000",
"q":"50.000000",
"t":1592563993577
}]
}
变量 | 类型 | 描述 |
---|---|---|
e | String | 事件名称 |
t | Integer | 事件时间(单位: 毫秒) |
p | String | 成交价格(正为买入,负为卖出,例如 -6573.2 表示卖出) |
q | String | 成交数量 |
查看当前标记价格
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"
描述
此接口用于返回指定合约交易对的当前标记价格信息。
HTTP 请求
GET /v2/market/markPrice
参数
参数 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
{
"e":"BTCUSDFP@mark", // event name
"p":"9000.12000000", // price
"t":1572858173963 // Event time (milliseconds)
}
变量 | 类型 | 描述 |
---|---|---|
e | String | 事件名称 |
p | String | 标记价格 |
t | Integer | 事件时间(单位: 毫秒) |
获取预测资金费率
描述
此接口用于获取预测资金费率信息
HTTP 请求
GET /v2/futures/funding/predictedFunding/{symbol}
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
响应数据
响应示例:
{
"code":1,
"data":{
"predictedFundingRate": "0.001",
"nextFundingTime": "2020-02-12T08:00:00Z"
"indexPrice": "13000.94"
},
"message":"success",
"ts":1573542445411
}
变量 | 类型 | 描述 |
---|---|---|
predictedFundingRate | String | 预测资金费率。当资金费率为正时,多头支付空头。如果为负,则空头支付多头。 |
nextFundingTime | String | 下一次收取资金费率的UTC时间 |
indexPrice | String | 指数价格 |
查询上个周期的资金费率
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"
描述
此接口用于查询上个周期的资金费率。UTC时间每天0点、8点、16点产生一个资金费率。
HTTP 请求
GET /v2/futures/funding/prevFundingRate/{symbol}
参数
参数 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对。常用形式为“基础货币”+“报价货币”+“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
}
变量 | 类型 | 描述 |
---|---|---|
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
markPrice | String | 标记价格 |
fundingRate | String | 资金费率。当资金费率为正时,多头支付空头。如果为负,则空头支付多头。 |
fundingTime | String | 资金费率结算的UTC时间 |
nextFundingTime | String | 下次资金费率结算的UTC时间 |
获取当前指数K线数据
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"
描述
此接口用于获取指定交易对的当前k线指数数据。支持交易对: BTCUSD、BTCUSDT、ETHUSD
HTTP 请求
GET /v2/market/candles/index
参数
参数 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对,常用形式为‘基础币种+计价币种’ |
timeFrame | Yes | String | 蜡烛时间区间,如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"
}
变量 | 类型 | 描述 |
---|---|---|
e | String | 事件名称 |
t | Integer | 事件时间(单位: 毫秒) |
h | String | 最高价 |
l | String | 最低价 |
o | String | 开盘价 |
s | Integer | K 线图的开始时间(秒) |
v | String | 交易量 |
c | String | 收盘价 |
需要鉴权的接口
可用接口
变量 | 路径 | 描述 |
---|---|---|
GET | /v2/user/info | 账户信息 |
GET | /v2/account/balances | 获取余额 |
POST | /v2/account/transfer | 资产划转 |
POST | /v2/spot/orders | 现货下单 |
PUT | /v2/spot/orders | 修改现货未成交订单 |
DELETE | /v2/spot/orders/cancel | 撤销现货订单 |
DELETE | /v2/spot/orders/cancel/all | 批量撤销现货订单 |
POST | /v2/spot/orders/cancelAllOnTimeout | 超时后撤消所有现货订单 |
GET | /v2/spot/trades | 查看现货订单成交详情 |
GET | /v2/spot/openOrders | 查看现货当前挂单 |
GET | /v2/spot/orders | 查询现货所有订单 |
POST | /v2/futures/orders | 合约下单 |
PUT | /v2/futures/orders | 修改合约未成交订单 |
DELETE | /v2/futures/orders/cancel | 撤销合约订单 |
DELETE | /v2/futures/orders/cancel/all | 批量撤销合约订单 |
POST | /v2/futures/orders/cancelAllOnTimeout | 超时后撤消所有合约订单 |
GET | /v2/futures/position | 查看合约的仓位 |
POST | /v2/futures/position/close | 合约平仓 |
GET | /v2/futures/position/closed | 查询平仓记录 |
POST | /v2/futures/position/leverage | 调整开仓杠杆 |
POST | /v2/futures/position/margin | 调整逐仓保证金 |
GET | /v2/futures/trades | 查看合约订单成交详情 |
GET | /v2/futures/openOrders | 查看合约当前挂单 |
GET | /v2/futures/Orders | 查询合约所有订单 |
GET | /v2/futures/funding/predictedFundingFee/{symbol} | 获取预测资金费用 |
账户相关
账户信息
描述
此接口用于查看用户 ID。
HTTP 请求
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
响应数据
响应示例:
{
"code":1,
"data":{
"userID":"216214"
},
"message":"success",
"ts":1573530400495
}
变量 | 类型 | 描述 |
---|---|---|
userID | String | userID |
获取余额
描述
此接口用于查询用户账户的资产信息
账户类型
- SPTP: 币币账户
- FUTP: 合约账户
- F2CP: OTC账户
- VLTP: 理财账户
- RWDP: 奖励账户
HTTP 请求
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
请求参数
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
purseType | No | String | 账户类型,包括SPTP、FUTP、F2CP、VLTP、RWDP |
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
unavailable | String | 冻结资产 |
available | String | 可用资产 |
currency | String | 币种,如BTC |
purseType | String | 账户类型 |
资产划转
描述
此接口用于各账户资产的划转。支持从币币账户(SPTP)划转到其他账户(合约、OTC和理财账户),或者从其他账户划转到币币账户(SPTP).
HTTP 请求
POST /v2/account/transfer
请求参数
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¤cy=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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
fromPurse | Yes | String | 转出账户,如SPTP, FUTP, F2CP, VLTP |
toPurse | Yes | String | 转入账户,如SPTP, FUTP, F2CP, VLTP |
currency | Yes | String | 币种,如BTC |
quantity | Yes | Decimal | 划转数量 |
响应数据
响应示例:
{
"code":1,
"data":{
"transferID": "177",
"transferTime": "2020-09-06 12:00:00.000Z"
}
"message":"success",
"ts":1573530401020
}
变量 | 类型 | 描述 |
---|---|---|
transferID | Integer | 划转单号 |
transferTime | String | 划转时间 |
现货交易
现货下单
描述
此接口用于现货下单,有关该接口用法的更多详情,请参见以下各字段。
类型
- LIMIT: 限价单类型。指定数量和价格。
- MARKET: 传统市价单。
- STOP: 请指定止损价。
- STOP-LIMIT: 限价止损单。请指定交易数量、止损价和限价价格。
HTTP 请求
POST /v2/spot/orders
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
orderType | Yes | String | 订单类型。可接受的值:MARKET(市价单)、LIMIT(限价单)、STOP(止损单)、STOP-LIMIT(限价止损单) |
symbol | Yes | String | 交易对,常用形式为‘基础币种+计价币种’ |
price | No | String | 委托价格。如果是下限价单,该参数为必填。 |
orderQty | Yes | String | 买卖数量 |
side | Yes | String | ‘BUY’(买入)或‘SELL’(卖出) |
stopPrice | No | String | 限价止损单或止损单的触发价格 |
clOrdID | No | String | 您的自定义订单 ID。clOrdID 类型应由字母 + 字符串组成,或仅包含 1 - 20 个字符的字母,并且支持大写和小写字母 |
timeInForce | No | String | GTC/IOC/FOK,默认是 GTC |
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
avgPrice | String | 平均成交价格 |
base | String | 基础货币币种 |
clOrdID | String | 您的自定义订单 ID。clOrdID 类型应由字母 + 字符串组成,或仅包含 1 - 20 个字符的字母,并且支持大写和小写字母 |
commission | String | 已成交的手续费 |
createTime | String | 订单创建时间 |
lastPrice | String | 成交价格 |
lastQty | String | 成交数量 |
cumQty | String | 订单的累计成交数量 |
updateTime | String | 订单的最后更新时间 |
isTriggered | Boolean | 由 STOP_LIMIT(限价止损单)和 STOP(止损单)使用,True 或False |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
price | String | 委托价格。如果是下限价单,该参数为必填。 |
quote | String | 计价货币币种 |
rejectCode | String | 订单拒绝代码 |
rejectReason | String | 订单被拒绝的原因 |
leavesQty | String | 还未成交的订单数量 |
orderID | String | AAX 订单编号 |
side | Integer | 买卖基础货币,“1:买入,2:卖出” |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
stopPrice | String | 限价止损单或止损单的触发价格 |
symbol | String | 交易对,常用形式为‘基础币种+计价币种’ |
orderQty | String | 订单数量 |
transactTime | String | 最后成交时间 |
timeInForce | String | '1: GTC, 3: IOC, 4: FOK' |
userID | String | 用户ID |
修改现货订单
描述
此接口用于修改当前未成交订单的数量或价格。
HTTP 请求
PUT /v2/spot/orders
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
orderID | Yes | String | 修改现货订单 |
orderQty | No | String | 订单数量 |
price | No | String | 委托价格。如果是下限价单,该参数为必填。 |
stopPrice | No | String | 限价止损单或止损单的触发价格 |
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
avgPrice | String | 平均成交价格 |
base | String | 基础货币币种 |
orderID | String | AAX 订单编号 |
clOrdID | String | 您的自定义订单 ID。clOrdID 类型应由字母 + 字符串组成,或仅包含 1 - 20 个字符的字母,并且支持大写和小写字母 |
commission | String | 已成交的手续费 |
createTime | String | 订单创建时间 |
lastPrice | String | 成交价格 |
lastQty | String | 成交数量 |
cumQty | String | 订单的累计成交数量 |
updateTime | String | 订单的最后更新时间 |
isTriggered | Boolean | 由 STOP_LIMIT(限价止损单)和 STOP(止损单)使用,True 或False |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
price | String | 委托价格。如果是下限价单,该参数为必填。 |
quote | String | 计价货币币种 |
rejectCode | String | 订单拒绝代码 |
rejectReason | String | 订单被拒绝的原因 |
leavesQty | String | 还未成交的订单数量 |
side | Integer | 买卖基础货币,“1:买入,2:卖出” |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
stopPrice | String | 限价止损单或止损单的触发价格 |
symbol | String | 交易对,常用形式为‘基础币种+计价币种’ |
orderQty | String | 订单数量 |
transactTime | String | 最后成交时间 |
timeInForce | String | '1: GTC, 3: IOC, 4: FOK' |
userID | String | 用户ID |
撤消现货订单
描述
此接口用于撤消现货未成交的(当前委托)订单。
HTTP 请求
DELETE /v2/spot/orders/cancel/{orderID}
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
orderID | Yes | String | 撤销订单号 |
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
avgPrice | String | 平均成交价格 |
base | String | 基础货币币种 |
orderID | String | AAX 订单编号 |
clOrdID | String | 您的自定义订单 ID。clOrdID 类型应由字母 + 字符串组成,或仅包含 1 - 20 个字符的字母,并且支持大写和小写字母 |
commission | String | 已成交的手续费 |
createTime | String | 订单创建时间 |
lastPrice | String | 成交价格 |
lastQty | String | 成交数量 |
cumQty | String | 订单的累计成交数量 |
updateTime | String | 订单的最后更新时间 |
isTriggered | Boolean | 由 STOP_LIMIT(限价止损单)和 STOP(止损单)使用,True 或False |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
price | String | 委托价格。如果是下限价单,该参数为必填。 |
quote | String | 计价货币币种 |
rejectCode | String | 订单拒绝代码 |
rejectReason | String | 订单被拒绝的原因 |
leavesQty | String | 还未成交的订单数量 |
side | Integer | 买卖基础货币,“1:买入,2:卖出” |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
stopPrice | String | 限价止损单或止损单的触发价格 |
symbol | String | 交易对,常用形式为‘基础币种+计价币种’ |
orderQty | String | 订单数量 |
transactTime | String | 最后成交时间 |
timeInForce | String | '1: GTC, 3: IOC, 4: FOK' |
userID | String | 用户ID |
批量撤消现货订单
描述
此接口用于批量撤消您的现货订单。默认情况下,将撤消指定交易对所对应的所有现货未成交订单。您可以通过提供 orderID 列表或 clOrdID 列表来选择仅撤消特定未成交订单列表。
HTTP 请求
DELETE /v2/spot/orders/cancel/all
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对,常用形式为‘基础币种+计价币种’ |
orderID | No | String | 要撤消的订单 ID 列表。使用英文逗号“,”进行分隔 |
clOrdID | No | String | 您的自定义订单 ID。使用英文逗号“,”进行分隔 |
响应数据
响应示例:
{
"code":1,
"data":[
"vBC9rXsEE",
"vBCc46OI0"
],
"message":"success",
"ts":1572597435470
}
变量 | 类型 | 描述 |
---|---|---|
data | Array | 将被撤消的 orderID 列表 |
超时后撤消所有现货订单
描述
此接口用作防止意外事件(例如,数据中心连接丢失或其他网络问题)的保护措施,以免您无法控制订单。可以调用此接口来设置计时器(以毫秒为单位)。在超时之前,必须再次调用此接口以“重置计时器”。如果超时,则所有交易对的所有现货订单将被取消。
为了取消计时器并保持订单有效,您可以将“timeout”设置为“0”。
我们建议不要将超时设置为少于5秒,以免在短暂的网络故障或拥塞情况下取消订单。
HTTP 请求
POST /v2/spot/orders/cancelAllOnTimeout
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
timeout | Yes | Integer | Timeout以毫秒为单位。设置为0将取消定时器,最大timeout为1小时 |
响应数据
响应示例:
{
"code":1,
"data":{
"endTime": "2020-03-13T08:26:55Z",
"startTime": "2020-03-13T08:26:25Z",
}
"message":"success",
"ts":158408795346
}
变量 | 类型 | 描述 |
---|---|---|
startTime | String | Unix时间 |
endTime | String | Unix时间 |
查看现货订单成交详情
描述
此接口用于查看您的现货成交详情记录。
HTTP 请求
GET /v2/spot/trades
请求参数
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"e=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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
pageNum | No | Integer | 分页页码,默认为“1” |
pageSize | No | Integer | 分页页面大小,默认为“10” |
orderID | No | String | 如果要检索与特定订单相关的交易详细信息,请指定订单 ID |
base | No | String | 基础货币币种 |
quote | No | String | 计价货币币种 |
startDate | No | String | 搜索开始日期,使用 yyyy-mm-dd 格式 |
endDate | No | String | 搜索结束日期,使用 yyyy-mm-dd 格式 |
side | No | String | 按交易方向进行筛选,BUY(买入)或 SELL(卖出) |
orderType | No | String | “MARKET(市价单)、LIMIT(限价单)、STOP(市价止损单)、STOP-LIMIT(限价止损单)” |
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
avgPrice | String | 平均成交价格 |
base | String | 基础货币币种 |
orderID | String | AAX 订单编号 |
tradeID | String | 订单成交记录ID |
commission | String | 已成交的手续费 |
createTime | String | 订单创建时间 |
filledPrice | String | 成交价格 |
cumQty | String | 订单的累计成交数量 |
updateTime | String | 订单的最后更新时间 |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
price | String | 委托价格。如果是下限价单,该参数为必填。 |
quote | String | 计价货币币种 |
rejectCode | String | 订单拒绝代码 |
rejectReason | String | 订单被拒绝的原因 |
leavesQty | String | 还未成交的订单数量 |
side | Integer | 买卖基础货币,“1:买入,2:卖出” |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
stopPrice | String | 限价止损单或止损单的触发价格 |
symbol | String | 交易对,常用形式为‘基础币种+计价币种’ |
orderQty | String | 订单数量 |
transactTime | String | 最后成交时间 |
filledQty | String | 成交数量 |
taker | Boolean | True:挂单,False:吃单 |
userID | String | 用户ID |
pageNum | Integer | 分页页码 |
pageSize | Integer | 分页页面大小 |
total | Integer | 搜索返回的记录总数 |
查看现货当前挂单
描述
此接口用于查看现货未成交订单
HTTP 请求
GET /v2/spot/openOrders
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
pageNum | No | Integer | 分页页码,默认为“1” |
pageSize | No | Integer | 分页页面大小,默认为“10” |
symbol | No | String | 交易对,常用形式为‘基础币种+计价币种’ |
orderID | No | String | AAX 订单编号 |
side | No | String | 按交易方向进行筛选,BUY(买入)或 SELL(卖出) |
clOrdID | No | String | 您的自定义订单 ID。clOrdID 类型应由字母 + 字符串组成,或仅包含 1 - 20 个字符的字母,并且支持大写和小写字母 |
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
avgPrice | String | 平均成交价格 |
base | String | 基础货币币种 |
orderID | String | AAX 订单编号 |
clOrdID | String | 您的自定义订单 ID。clOrdID 类型应由字母 + 字符串组成,或仅包含 1 - 20 个字符的字母,并且支持大写和小写字母 |
commission | String | 已成交的手续费 |
createTime | String | 订单创建时间 |
lastPrice | String | 成交价格 |
lastQty | String | 成交数量 |
cumQty | String | 订单的累计成交数量 |
updateTime | String | 订单的最后更新时间 |
isTriggered | Boolean | 由 STOP_LIMIT(限价止损单)和 STOP(止损单)使用,True 或False |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
price | String | 委托价格。如果是下限价单,该参数为必填。 |
quote | String | 计价货币币种 |
rejectCode | String | 订单拒绝代码 |
rejectReason | String | 订单被拒绝的原因 |
leavesQty | String | 还未成交的订单数量 |
side | Integer | 买卖基础货币,“1:买入,2:卖出” |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
stopPrice | String | 限价止损单或止损单的触发价格 |
symbol | String | 交易对,常用形式为‘基础币种+计价币种’ |
orderQty | String | 订单数量 |
transactTime | String | 最后成交时间 |
timeInForce | String | '1: GTC, 3: IOC, 4: FOK' |
userID | String | 用户ID |
pageNum | Integer | 分页页码 |
pageSize | Integer | 分页页面大小 |
total | Integer | 搜索返回的记录总数 |
查询现货所有订单
描述
此接口用于查询现货的所有订单。
HTTP 请求
GET /v2/spot/orders
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
pageNum | No | Integer | 分页页码,默认为“1” |
pageSize | No | Integer | 分页页面大小,默认为“10” |
symbol | No | String | 交易对,常用形式为‘基础币种+计价币种’ |
orderID | No | String | AAX 订单编号 |
base | No | String | 基础货币币种 |
quote | No | String | 计价货币币种 |
orderStatus | No | Integer | 要纳入搜索范围的订单状态:“ 1:新订单,2:已成交订单,3:已取消订单” |
startDate | No | String | 搜索开始日期,使用 yyyy-mm-dd 格式 |
endDate | No | String | 搜索结束日期,使用 yyyy-mm-dd 格式 |
orderType | No | String | “MARKET(市价单)、LIMIT(限价单)、STOP(市价止损单)、STOP-LIMIT(限价止损单)” |
side | No | String | 按交易方向进行筛选,BUY(买入)或 SELL(卖出) |
clOrdID | No | String | 您的自定义订单 ID。clOrdID 类型应由字母 + 字符串组成,或仅包含 1 - 20 个字符的字母,并且支持大写和小写字母 |
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
avgPrice | String | 平均成交价格 |
base | String | 基础货币币种 |
orderID | String | AAX 订单编号 |
clOrdID | String | 您的自定义订单 ID。clOrdID 类型应由字母 + 字符串组成,或仅包含 1 - 20 个字符的字母,并且支持大写和小写字母 |
commission | String | 已成交的手续费 |
createTime | String | 订单创建时间 |
lastPrice | String | 成交价格 |
lastQty | String | 成交数量 |
cumQty | String | 订单的累计成交数量 |
updateTime | String | 订单的最后更新时间 |
isTriggered | Boolean | 由 STOP_LIMIT(限价止损单)和 STOP(止损单)使用,True 或False |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
price | String | 委托价格。如果是下限价单,该参数为必填。 |
quote | String | 计价货币币种 |
rejectCode | String | 订单拒绝代码 |
rejectReason | String | 订单被拒绝的原因 |
leavesQty | String | 还未成交的订单数量 |
side | Integer | 买卖基础货币,“1:买入,2:卖出” |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
stopPrice | String | 限价止损单或止损单的触发价格 |
symbol | String | 交易对,常用形式为‘基础币种+计价币种’ |
orderQty | String | 订单数量 |
transactTime | String | 最后成交时间 |
timeInForce | String | '1: GTC, 3: IOC, 4: FOK' |
userID | String | 用户ID |
pageNum | Integer | 分页页码 |
pageSize | Integer | 分页页面大小 |
total | Integer | 搜索返回的记录总数 |
合约交易
合约下单
描述
此接口用于合约下单,有关此接口用法的更多详细信息,请参见以下各字段。
类型
- LIMIT: 限价单类型。指定数量和价格。
- MARKET: 传统市价单。
- STOP: 请指定止损价。
- STOP-LIMIT: 限价止损单。请指定交易数量、止损价和限价价格。
有效时间
timeInForce 是下订单时使用的不同执行策略,用于指示订单在成交或过期前保持有效状态的期限。
- 一直有效直至取消(GTC):订单将持续有效直到完全执行或被交易者手动取消。
- 立即成交或取消(IOC): 订单必须立即以限价或更优的价格成交,如果订单无法立即完全成交,未成交的部分将被取消。
- 完全成交或取消(FOK): 订单必须立即以限价或更优的价格全部成交,否则将被完全取消,不允许部分成交。
liqType
- General:不属于清算的命令
- USER-CLOSE-LIQ: 用户发起的平仓
- LIQ: 由于保证金不足而被强平
- TAKE-PROFT-LIQ: 止盈设置触发的平仓
- STOP-LOSS-LIQ: 止损设置触发的平仓
结算类型
名称 | 结算币种 | 示例 | 描述 |
---|---|---|---|
逆向结算 | (基础货币结算) | BTCUSDFP | 期货合约的结算使用基础货币 BTC 计算 |
双币种结算 | (跨货币结算) | ETHUSDFP | 期货合约的结算使用 BTC 计算,但 BTC 既不是基础货币也不是计价货币 |
单纯结算 | (计价货币结算) | EOSBTCFP | 期货合约的结算使用计价货币 BTC 计算 |
HTTP 请求
POST /v2/futures/orders
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
orderType | Yes | String | 订单类型。可接受的值:MARKET(市价单)、LIMIT(限价单)、STOP(止损单)、STOP-LIMIT(限价止损单) |
symbol | Yes | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
price | No | String | 委托价格。如果是下限价单,该参数为必填。 |
orderQty | Yes | String | 委托数量(张) |
side | Yes | String | “Long”(做多)或“Short”(做空)合约,e.g.“BUY,SELL” |
stopPrice | No | String | 限价止损单或止损单的触发价格 |
clOrdID | No | String | 用户自定义订单ID |
execInst | No | String | 可选执行说明。有效选项:Post-Only。Post-Only订单,如果此订单在下达订单会被执行,则此订单将会被取消。 |
timeInForce | No | String | GTC/IOC/FOK,默认是 GTC |
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
avgPrice | String | 平均成交价格 |
base | String | 基础货币币种 |
clOrdID | String | 用户自定义订单ID |
code | String | 仅适用于期货合约。“FP”代表永续合约,null 代表现货 |
commission | String | 已成交的手续费 |
createTime | String | 订单创建时间 |
cumQty | String | 订单的累计成交数量 |
lastPrice | String | 成交价格 |
leavesQty | String | 还未成交的订单数量 |
leverage | String | 杠杆 |
liqType | Integer | 期货的清算类型,“0:General,1:USER-CLOSE-LIQ,2:STOP-LIQ,3:TAKE-PROFIT-LIQ,4:STOP-LOSS-LIQ”。有关 liqType 的 更多详细信息。 |
marketPrice | String | 市场价。(最高出价 + 最低叫价)/2 |
orderID | String | AAX 订单编号 |
orderQty | String | 订单数量 |
rejectCode | String | 订单拒绝代码 |
rejectReason | String | 订单被拒绝的原因 |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
price | String | 委托价格。如果是下限价单,该参数为必填。 |
quote | String | 基础货币币种 |
settleType | String | 结算类型(INVERSE、VANILLA 或 QUANTO)(逆向、单纯或双币种结算) 关于 结算类型的更多详细信息。 |
side | Integer | “Long”(做多)或“Short”(做空)合约,e.g.“BUY,SELL” |
stopPrice | String | 限价止损单或止损单的触发价格 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
transactTime | String | 最后成交时间 |
updateTime | String | 订单的最后更新时间 |
execInst | String | Post-Only or '' |
timeInForce | String | '1: GTC, 3: IOC, 4: FOK' |
userID | String | 用户ID |
修改合约未成交订单
描述
此接口用于修改合约未成交订单的数量或价格。
HTTP 请求
PUT /v2/futures/orders
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
orderID | Yes | String | 要修改的订单ID |
orderQty | No | String | 订单数量 |
price | No | String | 委托价格。如果是下限价单,该参数为必填。 |
stopPrice | No | String | 限价止损单或止损单的触发价格 |
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
avgPrice | String | 平均成交价格 |
base | String | 基础货币币种 |
clOrdID | String | 用户自定义订单ID |
code | String | 仅适用于期货合约。“FP”代表永续合约,null 代表现货 |
commission | String | 已成交的手续费 |
createTime | String | 订单创建时间 |
cumQty | String | 订单的累计成交数量 |
lastPrice | String | 成交价格 |
leavesQty | String | 还未成交的订单数量 |
leverage | String | 杠杆 |
liqType | Integer | 期货的清算类型,“0:General,1:USER-CLOSE-LIQ,2:STOP-LIQ,3:TAKE-PROFIT-LIQ,4:STOP-LOSS-LIQ”。有关 liqType 的 更多详细信息。 |
marketPrice | String | 市场价。(最高出价 + 最低叫价)/2 |
orderID | String | AAX 订单编号 |
orderQty | String | 订单数量 |
rejectCode | String | 订单拒绝代码 |
rejectReason | String | 订单被拒绝的原因 |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
price | String | 委托价格。如果是下限价单,该参数为必填。 |
quote | String | 基础货币币种 |
settleType | String | 结算类型(INVERSE、VANILLA 或 QUANTO)(逆向、单纯或双币种结算) 关于 结算类型的更多详细信息。 |
side | Integer | “Long”(做多)或“Short”(做空)合约,e.g.“BUY,SELL” |
stopPrice | String | 限价止损单或止损单的触发价格 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
transactTime | String | 最后成交时间 |
updateTime | String | 订单的最后更新时间 |
timeInForce | String | '1: GTC, 3: IOC, 4: FOK' |
userID | String | 用户ID |
撤消合约订单
描述
此接口用于撤消合约未成交的订单。
HTTP 请求
DELETE /v2/futures/orders/cancel/{orderID}
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
orderID | Yes | String | 要撤消的订单的订单 ID |
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
avgPrice | String | 平均成交价格 |
base | String | 基础货币币种 |
clOrdID | String | 用户自定义订单ID |
code | String | 仅适用于期货合约。“FP”代表永续合约,null 代表现货 |
commission | String | 已成交的手续费 |
createTime | String | 订单创建时间 |
cumQty | String | 订单的累计成交数量 |
lastPrice | String | 成交价格 |
leavesQty | String | 还未成交的订单数量 |
leverage | String | 杠杆 |
liqType | Integer | 期货的清算类型,“0:General,1:USER-CLOSE-LIQ,2:STOP-LIQ,3:TAKE-PROFIT-LIQ,4:STOP-LOSS-LIQ”。有关 liqType 的 更多详细信息。 |
marketPrice | String | 市场价。(最高出价 + 最低叫价)/2 |
orderID | String | AAX 订单编号 |
orderQty | String | 订单数量 |
rejectCode | String | 订单拒绝代码 |
rejectReason | String | 订单被拒绝的原因 |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
price | String | 委托价格。如果是下限价单,该参数为必填。 |
quote | String | 基础货币币种 |
settleType | String | 结算类型(INVERSE、VANILLA 或 QUANTO)(逆向、单纯或双币种结算) 关于 结算类型的更多详细信息。 |
side | Integer | “Long”(做多)或“Short”(做空)合约,e.g.“BUY,SELL” |
stopPrice | String | 限价止损单或止损单的触发价格 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
transactTime | String | 最后成交时间 |
updateTime | String | 订单的最后更新时间 |
execInst | String | Post-Only or '' |
timeInForce | String | '1: GTC, 3: IOC, 4: FOK' |
userID | String | 用户ID |
批量撤消合约订单
描述
此接口用于批量撤消合约的未成交订单。默认情况下,将撤消指定交易对所对应的所有现货未成交订单。您可以通过提供 orderID 列表或 clOrdID 列表来选择仅撤消特定未成交订单列表。
HTTP 请求
DELETE /v2/futures/orders/cancel/all
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
orderID | No | String | 要撤消的订单 ID 列表。使用英文逗号“,”进行分隔 |
clOrdID | No | String | 您的自定义订单 ID。使用英文逗号“,”进行分隔 |
响应数据
响应示例:
{
"code":1,
"data":[
"wKQf3hpV7"
],
"message":"success",
"ts":1573556374435
}
变量 | 类型 | 描述 |
---|---|---|
data | Array | 将被撤消的 orderID 列表 |
超时后撤销所有合约订单
描述
此接口用作防止意外事件(例如,数据中心连接丢失或其他网络问题)的保护措施,以免您无法控制订单。可以调用此接口来设置计时器(以毫秒为单位)。在超时之前,必须再次调用此接口以“重置计时器”。如果超时,则所有交易对的所有现货订单将被取消。
为了取消计时器并保持订单有效,您可以将“timeout”设置为“0”。
我们建议不要将超时设置为少于5秒,以免在短暂的网络故障或拥塞情况下取消订单。
HTTP 请求
POST /v2/futures/orders/cancelAllOnTimeout
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
timeout | Yes | Integer | Timeout以毫秒为单位。设置为0将取消定时器,最大timeout为1小时 |
响应数据
响应示例:
{
"code":1,
"data":{
"endTime": "2020-03-13T08:26:55Z",
"startTime": "2020-03-13T08:26:25Z",
}
"message":"success",
"ts":158408795346
}
变量 | 类型 | 描述 |
---|---|---|
startTime | String | Unix时间 |
endTime | String | Unix时间 |
查看合约的仓位
描述
此接口用于查看合约的仓位。
HTTP 请求
GET /v2/futures/position
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | No | String | 如果您只想查看某期货的仓位,请指定该期货合约符号。常用形式为“基础货币”+“报价货币”+“FP” |
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
avgEntryPrice | String | 当前多头/空头仓位的平均买卖成交价格 |
bankruptPrice | String | 破产价格 |
base | String | 基础货币币种 |
code | String | 仅适用于期货合约。“FP”代表永续合约,null 代表现货 |
commission | String | 已成交的手续费 |
currentQty | String | 您当前交易对持有的仓位。如果为正,则为多头;如果为负,则为空头 |
funding | String | 自建仓以来以 BTC 收取/支付的资金金额。正号表示收取,负号表示支付 |
fundingStatus | Integer | 资金状态,0:结算中,1:已结算 |
posMargin | String | 持仓保证金 |
leverage | String | 仓位杠杆 |
liquidationPrice | String | 强平价格 |
marketPrice | String | 市场价。(最高出价 + 最低叫价)/2 |
openTime | String | 建仓时间戳(采用 UTC 时间) |
quote | String | 基础货币币种 |
stopLossPrice | String | 止损价格 |
stopLossSource | Integer | 触发价格类型。 “1:最新市价” |
takeProfitPrice | String | 止盈价格 |
takeProfitSource | Integer | 触发价格类型。 “1:最新市价” |
realisedPnl | String | 自建仓以来已实现的损益 |
unrealisedPnl | String | 未实现盈亏 |
riskyPrice | String | 风险价格,仅用于内部处理 |
settleType | String | 结算类型(INVERSE、VANILLA 或 QUANTO)(逆向、单纯或双币种结算) 关于 结算类型的更多详细信息。 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
userID | String | 用户ID |
设置仓位止盈止损
描述
该接口用于实现仓位止盈止损功能。可以用于新建、修改、撤销止盈止损设置(开仓后才可以设置)。
HTTP 请求
POST /v2/futures/position/sltp
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
side | Yes | String | “Long”(做多)或“Short”(做空)合约,e.g.“BUY,SELL” |
stopLossPrice | No | String | 止损价格 |
stopLossStatus | No | Integer | 启用止损设置。“0: 否, 1: 是” |
takeProfitPrice | No | String | 止盈价格 |
takeProfitStatus | No | Integer | 启用止盈设置。“0: 否, 1: 是” |
备注
- symbol+stopLossPrice+stopLossStatus: 新建或者修改仓位止损设置
- symbol+stopLossStatus: 撤销止损设置
- symbol+takeProfitPrice+takeProfitStatus: 新建或者修改仓位止盈设置
- symbol+takeProfitStatus: 撤销止盈设置
响应数据
响应示例:
{
"code":1,
"data":{
"side":"1",
"stopLossExpiration":"2020-08-02T11:36:13.000Z,
"stopLossOrderId":"WnzsF613y",
"stopLossPrice":"9211",
"stopLossSource":1,
"stopLossStatus":1,
"symbol":"BTCUSDTFP",
"takeProfitExpiration":"2020-08-02T11:36:13.000Z,
"takeProfitOrderId":"WnzsF8drO",
"takeProfitPrice":"9400",
"takeProfitSource":1,
"takeProfitStatus":1
},
"message":"success",
"timestamp":"2020-07-16 10:55:44"
}
变量 | 类型 | 描述 |
---|---|---|
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
side | Integer | 止盈止损方向。“1: 做多, 2: 做空” |
stopLossPrice | String | 止损价格 |
stopLossSource | Integer | 触发价格类型。 “1:最新市价” |
stopLossStatus | Integer | 启用止损设置。“0: 否, 1: 是” |
stopLossOrderID | String | 止损订单ID |
stopLossExpiration | String | 止损有效期 |
takeProfitPrice | String | 止盈价格 |
takeProfitSource | Integer | 触发价格类型。 “1:最新市价,2: 标记价格, 3: 指数价格,4:中间价格” |
takeProfitStatus | Integer | 启用止盈设置。“0: 否, 1: 是” |
takeProfitOrderID | String | 止盈订单ID |
takeProfitExpiration | String | 止盈有效期 |
合约平仓
描述
此接口用于合约平仓
HTTP 请求
POST /v2/futures/position/close
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
price | No | String | 限价平仓价格 |
备注
- 只传symbol,则市价平仓该品种合约
- 传symbol和price,则限价平仓该品种合约
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
avgPrice | String | 平均成交价格 |
base | String | 基础货币币种 |
clOrdID | String | 用户自定义订单ID |
code | String | 仅适用于期货合约。“FP”代表永续合约,null 代表现货 |
commission | String | 已成交的手续费 |
createTime | String | 订单创建时间 |
cumQty | String | 订单的累计成交数量 |
lastPrice | String | 成交价格 |
leavesQty | String | 还未成交的订单数量 |
leverage | String | 仓位杠杆 |
liqType | Integer | 期货的清算类型,“0:General,1:USER-CLOSE-LIQ,2:STOP-LIQ,3:TAKE-PROFIT-LIQ,4:STOP-LOSS-LIQ”。有关 liqType 的 更多详细信息。 |
marketPrice | String | 市场价。(最高出价 + 最低叫价)/2 |
orderID | String | AAX 订单编号 |
orderQty | String | 订单数量 |
rejectCode | String | 订单拒绝代码 |
rejectReason | String | 订单被拒绝的原因 |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
price | String | 委托价格。如果是下限价单,该参数为必填。 |
stopLossPrice | String | 止损价格 |
stopLossSource | Integer | 触发价格类型。 “1:最新市价” |
takeProfitPrice | String | 止盈价格 |
takeProfitSource | Integer | 触发价格类型。 “1:最新市价” |
quote | String | 基础货币币种 |
settleType | String | 结算类型(INVERSE、VANILLA 或 QUANTO)(逆向、单纯或双币种结算) 关于 结算类型的更多详细信息。 |
side | Integer | “Long”(做多)或“Short”(做空)合约,e.g.“BUY,SELL” |
stopPrice | String | 限价止损单或止损单的触发价格 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
transactTime | String | 最后成交时间 |
updateTime | String | 订单的最后更新时间 |
userID | String | 用户ID |
查询平仓记录
描述
此接口用于查询平仓历史记录。
HTTP 请求
GET /v2/futures/position/closed
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
pageNum | No | Integer | 分页页码,默认为“1” |
pageSize | No | Integer | 分页页面大小,默认为“10” |
symbol | No | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
startDate | No | String | 搜索开始日期,使用 yyyy-mm-dd 格式 |
endDate | No | String | 搜索结束日期,使用 yyyy-mm-dd 格式 |
pnlType | No | String | pnl 类型,“porfit”或“loss” |
beforeHours | No | Integer | 搜索 n(如“8”)小时之前的订单 |
响应数据
响应示例:
{
"code":1,
"data":{
"list":[
{
"base":"BTC",
"closeTime":"2019-11-07T07:23:56.000Z,
"code":"FP",
"commission":"0.00000625",
"funding":"0",
"id":"112572754530816000",
"openTime":"2019-11-07T07:23:35.000Z,
"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:37.000Z,
"code":"FP",
"commission":"0.00000957",
"funding":"-0.00000128",
"id":"112235202187776000",
"openTime":"2019-11-06T08:50:48.000Z,
"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
}
变量 | 类型 | 描述 |
---|---|---|
base | String | 基础货币币种 |
closeTime | String | 平仓时间 |
code | String | 仅适用于期货合约。“FP”代表永续合约,null 代表现货 |
commission | String | 已成交的手续费 |
funding | String | 自建仓以来以 BTC 收取/支付的资金金额。正号表示收取,负号表示支付 |
openTime | String | 建仓时间戳(采用 UTC 时间) |
pnl | String | 盈亏 |
quote | String | 基础货币币种 |
stopLossPrice | String | 止损价格 |
stopLossSource | Integer | 触发价格类型。 “1:最新市价” |
takeProfitPrice | String | 止盈价格 |
takeProfitSource | Integer | 触发价格类型。 “1:最新市价” |
realisedPnl | String | 自建仓以来已实现的损益 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
userID | String | 用户ID |
pageNum | Integer | 分页页码 |
pageSize | Integer | 分页页面大小 |
total | Integer | 搜索返回的记录总数 |
调整开仓杠杆
描述
此接口用于调整合约开仓杠杆。
HTTP 请求
POST /v2/futures/position/leverage
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
leverage | Yes | Integer | 1-100 倍杠杆,例如 10 倍 |
响应数据
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
avgEntryPrice | String | 当前多头/空头仓位的平均买卖成交价格 |
bankruptPrice | String | 破产价格 |
base | String | 基础货币币种 |
code | String | 仅适用于期货合约。“FP”代表永续合约,null 代表现货 |
commission | String | 已成交的手续费 |
currentQty | String | 您当前交易对持有的仓位。如果为正,则为多头;如果为负,则为空头 |
funding | String | 自建仓以来以 BTC 收取/支付的资金金额。正号表示收取,负号表示支付 |
fundingStatus | Integer | 资金状态,0:结算中,1:已结算 |
posMargin | String | 持仓保证金 |
leverage | String | 仓位杠杆 |
liquidationPrice | String | 强平价格 |
marketPrice | String | 市场价。(最高出价 + 最低叫价)/2 |
openTime | String | 建仓时间戳(采用 UTC 时间) |
quote | String | 基础货币币种 |
realisedPnl | String | 自建仓以来已实现的损益 |
unrealisedPnl | String | 未实现盈亏 |
riskyPrice | String | 风险价格,仅用于内部处理 |
settleType | String | 结算类型(INVERSE、VANILLA 或 QUANTO)(逆向、单纯或双币种结算) 关于 结算类型的更多详细信息。 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
userID | String | 用户ID |
调整逐仓保证金
描述
此接口用于调整逐仓保证金。
HTTP 请求
POST /v2/futures/position/margin
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
margin | Yes | Integer | 保证金资金 |
响应数据
响应示例:
{"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}
变量 | 类型 | 描述 |
---|---|---|
avgEntryPrice | String | 当前多头/空头仓位的平均买卖成交价格 |
bankruptPrice | String | 破产价格 |
base | String | 基础货币币种 |
code | String | 仅适用于期货合约。“FP”代表永续合约,null 代表现货 |
commission | String | 已成交的手续费 |
currentQty | String | 您当前交易对持有的仓位。如果为正,则为多头;如果为负,则为空头 |
funding | String | 自建仓以来以 BTC 收取/支付的资金金额。正号表示收取,负号表示支付 |
fundingStatus | Integer | 资金状态,0:结算中,1:已结算 |
posMargin | String | 持仓保证金 |
leverage | String | 仓位杠杆 |
liquidationPrice | String | 强平价格 |
marketPrice | String | 市场价。(最高出价 + 最低叫价)/2 |
openTime | String | 建仓时间戳(采用 UTC 时间) |
quote | String | 基础货币币种 |
realisedPnl | String | 自建仓以来已实现的损益 |
unrealisedPnl | String | 未实现盈亏 |
riskyPrice | String | 风险价格,仅用于内部处理 |
settleType | String | 结算类型(INVERSE、VANILLA 或 QUANTO)(逆向、单纯或双币种结算) 关于 结算类型的更多详细信息。 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
userID | String | 用户ID |
查看合约订单成交详情
描述
此接口用于查看合约订单的成交详细信息。
HTTP 请求
GET /v2/futures/trades
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
pageNum | No | Integer | 分页页码,默认为“1” |
pageSize | No | Integer | 分页页面大小,默认为“10” |
orderID | No | String | AAX 订单编号 |
symbol | No | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
base | No | String | 基础货币币种 |
quote | No | String | 计价货币币种 |
startDate | No | String | 搜索开始日期,使用 yyyy-mm-dd 格式 |
endDate | No | String | 搜索结束日期,使用 yyyy-mm-dd 格式 |
side | No | String | 按交易方向进行筛选,“BUY” 或者 “SELL” |
orderType | No | String | 要纳入搜索范围的订单类型:“MARKET、LIMIT、STOP-LIMIT、 STOP、LIQ、MARKET-CLOSING、LIMIT-CLOSING” |
响应数据
响应示例:
{
"code":1,
"data":{
"list":[
{
"base":"BTC",
"commission":"0.00000913",
"createTime":"2019-11-12T07:05:52.000Z,
"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:52.000Z,
"updateTime":null,
"timeInForce":1,
"userID":"216214"
},
{
"base":"BTC",
"commission":"0.00000913",
"createTime":"2019-11-12T07:05:52.000Z,
"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:52.000Z,
"updateTime":null,
"timeInForce":1,
"userID":"216214"
},
...
],
"pageNum":1,
"pageSize":10,
"total":15
},
"message":"success",
"ts":1573545435652
}
变量 | 类型 | 描述 |
---|---|---|
base | String | 基础货币币种 |
commission | String | 已成交的手续费 |
filledPrice | String | 成交价格 |
filledQty | String | 成交数量 |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
leavesQty | String | 还未成交的订单数量 |
leverage | String | 仓位杠杆 |
liqType | Integer | 期货的清算类型,“0:General,1:USER-CLOSE-LIQ,2:STOP-LIQ,3:TAKE-PROFIT-LIQ,4:STOP-LOSS-LIQ”。有关 liqType 的 更多详细信息。 |
liquidationPrice | String | 强平价格 |
orderID | String | AAX 订单编号 |
tradeID | String | 订单成交记录ID |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
quote | String | 基础货币币种 |
realisedPnl | String | 自建仓以来已实现的损益 |
side | Integer | “Long”(做多)或“Short”(做空)合约,e.g.“BUY,SELL” |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
transactTime | String | 最后成交时间 |
updateTime | String | 订单的最后更新时间 |
userID | String | 用户ID |
pageNum | Integer | 分页页码 |
pageSize | Integer | 分页页面大小 |
total | Integer | 搜索返回的记录总数 |
查看合约当前挂单
描述
此接口用于查看合约当前未成交订单。
HTTP 请求
GET /v2/futures/openOrders
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
pageNum | No | Integer | 分页页码,默认为“1” |
pageSize | No | Integer | 分页页面大小,默认为“10” |
symbol | No | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
orderID | No | String | AAX 订单编号 |
side | No | String | 按交易方向进行筛选,“BUY” 或者 “SELL” |
clOrdID | No | String | 用户自定义订单ID |
响应数据
响应示例:
{
"code":1,
"data":{
"list":[
{
"avgPrice":"0",
"base":"BTC",
"clOrdID":"aax_futures",
"code":"FP",
"commission":"0",
"createTime":"2019-11-12T10:22:03.000Z,
"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:03.000Z,
"timeInForce":1,
"execInst": "",
"userID":"216214"
}
],
"pageNum":1,
"pageSize":1,
"total":1
},
"message":"success",
"ts":1573554124003
}
变量 | 类型 | 描述 |
---|---|---|
avgPrice | String | 平均成交价格 |
base | String | 基础货币币种 |
clOrdID | String | 用户自定义订单ID |
code | String | 仅适用于期货合约。“FP”代表永续合约,null 代表现货 |
commission | String | 已成交的手续费 |
createTime | String | 订单创建时间 |
cumQty | String | 订单的累计成交数量 |
lastPrice | String | 成交价格 |
lastQty | String | 成交数量 |
leavesQty | String | 还未成交的订单数量 |
leverage | String | 仓位杠杆 |
liqType | Integer | 期货的清算类型,“0:General,1:USER-CLOSE-LIQ,2:STOP-LIQ,3:TAKE-PROFIT-LIQ,4:STOP-LOSS-LIQ”。有关 liqType 的 更多详细信息。 |
marketPrice | String | 市场价。(最高出价 + 最低叫价)/2 |
orderID | String | AAX 订单编号 |
orderQty | String | 订单数量 |
rejectCode | String | 订单拒绝代码 |
rejectReason | String | 订单被拒绝的原因 |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
price | String | 委托价格。如果是下限价单,该参数为必填。 |
quote | String | 基础货币币种 |
settleType | String | 结算类型(INVERSE、VANILLA 或 QUANTO)(逆向、单纯或双币种结算) 关于 结算类型的更多详细信息。 |
side | Integer | “Long”(做多)或“Short”(做空)合约,e.g.“BUY,SELL” |
stopPrice | String | 限价止损单或止损单的触发价格 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
transactTime | String | 最后成交时间 |
updateTime | String | 订单的最后更新时间 |
timeInForce | String | '1: GTC, 3: IOC, 4: FOK' |
execInst | String | Post-Only or '' |
userID | String | 用户ID |
pageNum | Integer | 分页页码 |
pageSize | Integer | 分页页面大小 |
total | Integer | 搜索返回的记录总数 |
查询合约所有订单
描述
此接口用于查询合约的所有订单。
HTTP 请求
GET /v2/futures/orders
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
pageNum | No | Integer | 分页页码,默认为“1” |
pageSize | No | Integer | 分页页面大小,默认为“10” |
symbol | No | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
orderID | No | String | AAX 订单编号 |
base | No | String | 基础货币币种 |
quote | No | String | 计价货币币种 |
orderStatus | No | Integer | 要纳入搜索范围的订单状态:“ 1:新订单,2:已成交订单,3:已取消订单” |
startDate | No | String | 搜索开始日期,使用 yyyy-mm-dd 格式 |
endDate | No | String | 搜索结束日期,使用 yyyy-mm-dd 格式 |
side | No | String | 按交易方向进行筛选,“BUY” 或者 “SELL” |
orderType | No | String | “MARKET(市价单)、LIMIT(限价单)、STOP(市价止损单)、STOP-LIMIT(限价止损单)” |
clOrdID | No | String | 用户自定义订单ID |
响应数据
响应示例:
{
"code":1,
"data":{
"list":[
{
"avgPrice":"8768.99999999484997",
"base":"BTC",
"clOrdID":null,
"code":"FP",
"commission":"0.00000913",
"createTime":"2019-11-12T07:05:52.000Z,
"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:52.000Z,
"updateTime":"2019-11-12T07:05:52.000Z,
"timeInForce":1,
"execInst": "",
"userID":"216214"
},
...
],
"pageNum":1,
"pageSize":10,
"total":21
},
"message":"success",
"ts":1573546960172
}
变量 | 类型 | 描述 |
---|---|---|
avgPrice | String | 平均成交价格 |
base | String | 基础货币币种 |
clOrdID | String | 用户自定义订单ID |
code | String | 仅适用于期货合约。“FP”代表永续合约,null 代表现货 |
commission | String | 已成交的手续费 |
createTime | String | 订单创建时间 |
cumQty | String | 订单的累计成交数量 |
lastPrice | String | 成交价格 |
lastQty | String | 成交数量 |
leavesQty | String | 还未成交的订单数量 |
leverage | String | 杠杆 |
liqType | Integer | 期货的清算类型,“0:General,1:USER-CLOSE-LIQ,2:STOP-LIQ,3:TAKE-PROFIT-LIQ,4:STOP-LOSS-LIQ”。有关 liqType 的 更多详细信息。 |
marketPrice | String | 市场价。(最高出价 + 最低叫价)/2 |
orderID | String | AAX 订单编号 |
orderQty | String | 订单数量 |
rejectCode | String | 订单拒绝代码 |
rejectReason | String | 订单被拒绝的原因 |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
price | String | 委托价格。如果是下限价单,该参数为必填。 |
quote | String | 基础货币币种 |
settleType | String | 结算类型(INVERSE、VANILLA 或 QUANTO)(逆向、单纯或双币种结算) 关于 结算类型的更多详细信息。 |
side | Integer | “Long”(做多)或“Short”(做空)合约,e.g.“BUY,SELL” |
stopPrice | String | 限价止损或市价止损的触发价格 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
transactTime | String | 最后成交时间 |
updateTime | String | 订单的最后更新时间 |
timeInForce | String | '1: GTC, 3: IOC, 4: FOK' |
execInst | String | Post-Only or '' |
userID | String | 用户ID |
pageNum | Integer | 分页页码 |
pageSize | Integer | 分页页面大小 |
total | Integer | 搜索返回的记录总数 |
获取预测资金费用
描述
此接口用于获取预测资金费用信息
HTTP 请求
GET /v2/futures/funding/predictedFundingFee/{symbol}
请求参数
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"
名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
响应数据
响应示例:
{
"code":1,
"data":{
"predictedFundingRate": "0.001",
"predictedFundingFee": "0.000234",
"nextFundingTime": "2020-02-12T08:00:00.000Z
},
"message":"success",
"ts":1573542445411
}
变量 | 类型 | 描述 |
---|---|---|
predictedFundingRate | String | 预测资金费率。当资金费率为正时,多头支付空头。如果为负,则空头支付多头。 |
predictedFundingFee | String | 预测资金费用 |
nextFundingTime | String | 下一次收取资金费率的UTC时间 |
Websocket
概览
Streaming API,提供实时的市场行情和账户挂单数据。
消息编码
通过 AAX Websocket 通道发送和接收的消息均以 JSON 格式编码。
速率限制
每个 IP 每分钟所发出的连接请求数量不得超过 600 个。如果达到此限制,您将收到 HTTP 429 错误。
公有市场行情
概览
Websocket URL
市场行情API提供公共的实时数据。
Base URL: wss://realtime.aax.com/marketdata/v2
公有数据
可以通过 wss://realtime.aax.com/marketdata/v2/{streamName1}/{streamName2} 访问所有 Websocket 数据
每个连接可以预订一个或多个信息流。不同的市场数据有不同的信息流,每个信息流都有特定的更新间隔。以下是可用信息流的列表:
- Orderbook: 订单簿 Feed
- Trades: 交易 Feed
- Tickers: 股票行情资讯 Feed
- Candlesticks: K 线图 Feed
- Mark Price: 标记价格 Feed
订阅
您可以订阅多个此类信息流:
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)
除了在 URL 中指定信息流名称之外,还可以通过发送以下命令按需订阅和取消订阅任何信息流:
示例
{"e":"subscribe”,”stream”:”BTCUSDT@book_50“}
或者
{“e”:”unsubscribe”,”stream”:”BTCUSDT@book_50"}
响应示例:
{“e”:”reply”,”status”:”ok”}
或者
{“e”:”reply”,”status”:”error”}
空事件
新建连接后,如果服务器没有能立即发送的内容,则可能会向客户端发送空事件。
示例
{"e":"empty"}
系统事件
服务器可以向客户端发送系统事件,以指示系统状态变更。可能的状态是:
- active(系统处于活跃且正常状态)
- inactive(无法获得市场数据)
示例
{"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())
每300毫秒推送有限档订单薄信息(存在变化时推送)。level表示买卖档数信息, 可选 20,50档
- 信息流名称:
{symbol}@book_{level}
- 支持的级别 (N):): 20, 50
- 更新间隔 (X):: 300 ms
- 示例: BTCUSDT@book_50
- URL示例:
wss://realtime.aax.com/marketdata/v2/BTCUSDT@book_50
参数
参数 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对名称,现货命名格式为“基础币种 + 计价币种”,例如BTCUSDT,合约命名格式为“基础币种 + 计价币种 + FP”,例如BTCUSDFP |
level | Yes | Integer | 深度信息。支持20, 50 |
返回参数
响应示例:
{
"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
}
变量 | 类型 | 描述 |
---|---|---|
e | String | 事件名称 |
t | Integer | 事件时间(单位: 毫秒) |
asks | Array | 订单簿中当前的出价列表 |
bids | Array | 订单簿中当前的叫价列表 |
订阅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())
对于每个新连接,我们的服务器返回最近的 50 条交易。
- 信息流名称: {symbol}@trade
- 示例: BTCUSDT@trade
- URL示例: wss://realtime.aax.com/marketdata/v2/BTCUSDT@trade
参数
参数 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对名称,现货命名格式为“基础币种 + 计价币种”,例如BTCUSDT,合约命名格式为“基础币种 + 计价币种 + FP”,例如BTCUSDFP |
返回参数
响应示例:
{
"e":"BTCUSDT@trade",
"p":"10924.30000000",
"q":"0.002000",
"t":1561445393223
}
变量 | 类型 | 描述 |
---|---|---|
e | String | 事件名称 |
t | Integer | 事件时间(单位: 毫秒) |
p | String | 成交价格(正为买入,负为卖出,例如 -6573.2 表示卖出) |
q | String | 成交数量 |
订阅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())
结果包含最近 24 小时的开盘价、最高价、最低价、收盘价和成交量。建立连接后,服务器最初会立即将所有Tickers数据发送到客户端,随后仅发送自上次更新(每隔 N 秒)以来有变化的Tickers数据。
- 信息流名称: tickers
- 更新间隔 (N): 2 seconds
- URL示例: wss://realtime.aax.com/marketdata/v2/tickers
返回参数
响应示例:
{
"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"}
]
}
变量 | 类型 | 描述 |
---|---|---|
e | String | 事件名称 |
t | Integer | 事件时间(单位: 毫秒) |
s | String | 交易对 |
o | String | 开盘价 |
h | String | 最高价 |
l | String | 最低价 |
c | String | 收盘价 |
v | String | 24小时成交量 |
订阅Kline数据
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())
Candlesticks stream逐秒推送所请求的candlesticks种类(最新一根K线)的更新
- 信息流名称: {symbol}@{timeframe}_candles
- 支持的时间范围:: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 3h, 4h, 8h, 1d
- 更新间隔:: 1 second
- 示例: BTCUSDT@1m_candles
- URL示例: wss://realtime.aax.com/marketdata/v2/BTCUSDT@1m_candles
参数
参数 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对名称,现货命名格式为“基础币种 + 计价币种”,例如BTCUSDT,合约命名格式为“基础币种 + 计价币种 + FP”,例如BTCUSDFP |
timeframe | Yes | Integer | K线周期 |
返回参数
响应示例:
{
"c":"10821.30000000",
"e":"BTCUSDT@1m_candles",
"h":"10821.30000000",
"l":"10821.30000000",
"o":"10821.30000000",
"s":1561543560,
"t":1561543560,
"v":"0.00000000"
}
变量 | 类型 | 描述 |
---|---|---|
e | String | 事件名称 |
t | Integer | 事件时间(单位: 毫秒) |
h | String | 最高价 |
l | String | 最低价 |
o | String | 开盘价 |
s | Integer | K 线图的开始时间(秒) |
v | String | 交易量 |
c | String | 收盘价 |
订阅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())
- 信息流名称: {symbol}@mark
- 示例: BTCUSDFP@mark
- URL示例: wss://realtime.aax.com/marketdata/v2/BTCUSDFP@mark
参数
参数 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol | Yes | String | 交易对名称,现货命名格式为“基础币种 + 计价币种”,例如BTCUSDT,合约命名格式为“基础币种 + 计价币种 + FP”,例如BTCUSDFP |
返回参数
响应示例:
{
"e":"BTCUSDFP@mark",
"p":"9000.12000000",
"t":1572858173963
}
变量 | 类型 | 描述 |
---|---|---|
e | String | 事件名称 |
p | String | 标记价格 |
t | Integer | 事件时间(单位: 毫秒) |
订单与用户数据接口
概览
AAX采用SocketCluster协议实现订阅用户数据的WebSocket服务。有关SocketCluster的详细信息,请参考 SocketCluster Protocol 及 SocketCluster client driver
事件格式
基本事件的发送格式︰
{"event": "eventName", "data": "eventData",cid:"eventID"}
备注
cid:每个发出的事件都可以具有呼叫ID(如果已指定,则在客户端会话的生命周期中必须是唯一的)
您可以使用UUID字符串,但是为了提高效率,我们建议使用以1开头的数字,并在发送的每个事件中对其进行递增。
Websocket URL
此接口提供实时的订单、仓位、账户变化信息。需要通过API Key授权。
Base URL: wss://stream.aax.com/notification/v2/
Websocket 身份验证
类似于 RESTful API,您需要使用 API 密钥对连接进行身份验证,才能获得私有通道的访问权限。如果您希望订阅用户锁定的信息流,则必须先进行身份验证。
发送命令格式:
{"event": "login", "data": {"apiKey":${KEY},"nonce":${NONCE},"signature":${SIGNATURE}}}
示例消息,例如:
{"event":"login","data":{"apiKey":"e04019b***","nonce":1557386524650,"signature":"114422***"}}
- nonce 是 UNIX 时间戳(以毫秒为单位)。
- signature 是 HEX(HMAC_SHA256(apiSecret, nonce + ':' + apiKey))。
订阅
AAX允许订阅实时数据。 一旦连接成功,该访问方式没有频率限制,它是获取最新数据的最好的方法。
订阅用户私有信息的发送命令格式:
{"event":"#subscribe","data":{"channel":"user/' + ${USER_ID} + '"},"cid":2}
事件响应
响应数据格式:
{ "event": “event name”, "data":responseData,"ts": responseTime}
握手
在将自定义事件发送到SocketCluster服务器之前,首先需要建立与SocketCluster服务器的WebSocket连接,然后执行握手以启动套接字。
一旦打开WebSocket连接,您的客户端应向服务器发出特殊的 #handshake事件。
#handshake 事件消息应如下所示:
{
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
}
收到事件后,服务器应以以下格式发送回握手响应事件消息:
{
// 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
}
}
心跳
如上所述,SocketCluster具有用于检查连接是否仍处于活动状态的ping / pong机制。ping间隔为20s
Ping 信息
#1
Pong 信息
#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.
用户的以下私有信息发生变化时,将会触发Notification 频道返回信息:
账户资产 现货订单 合约订单 合约仓位 合约杠杆
频道或事件
类型 | 频道 | 事件 | 描述 |
---|---|---|---|
Private | user/{USER ID} | USER_BALANCE |
广播用户的余额变更信息 |
Private | user/{USER ID} | SPOT |
广播现货订单状态 |
Private | user/{USER ID} | FUTURES |
广播合约订单、杠杆、仓位信息 |
事件:USER_BALANCE
当您的账户资产发生变化时,将会收到notification推送信息。
{
"data":{
"userID":"213409",
"purseType":"coin",
"currency":"BTC",
"available":"0.12127194",
"unavailable":"0.01458122"
},
"event":"USER_BALANCE"
}
当您的账户资产发生变化时,将会收到notification推送信息。
返回参数
变量 | 类型 | 描述 |
---|---|---|
location | String | 待使用 |
userID | String | 用户ID |
currency | String | 币种,如BTC |
purseType | String | 账户类型 |
available | String | 可用资产 |
unavailable | String | 冻结资产 |
事件:SPOT
事件返回的JSON格式数据如下
{
"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"
}
当您下单或者订单状态发生变化时,您将会收到提醒。
返回参数
变量 | 类型 | 描述 |
---|---|---|
avgPrice | String | 平均成交价格 |
base | String | 基础货币币种 |
clOrdID | String | 您的自定义订单 ID。clOrdID 类型应由字母 + 字符串组成,或仅包含 1 - 20 个字符的字母,并且支持大写和小写字母 |
commission | String | 已成交的手续费 |
createTime | String | 订单创建时间 |
lastPrice | String | 成交价格 |
lastQty | String | 成交数量 |
cumQty | String | 订单的累计成交数量 |
updateTime | String | 订单的最后更新时间 |
isTriggered | Boolean | 由 STOP_LIMIT(限价止损单)和 STOP(止损单)使用,True 或False |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
price | String | 委托价格。如果是下限价单,该参数为必填。 |
quote | String | 计价货币币种 |
rejectCode | String | 订单拒绝代码 |
rejectReason | String | 订单被拒绝的原因 |
leavesQty | String | 还未成交的订单数量 |
orderID | String | AAX 订单编号 |
side | Integer | 买卖基础货币,“1:买入,2:卖出” |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
stopPrice | String | 限价止损单或止损单的触发价格 |
symbol | String | 交易对,常用形式为‘基础币种+计价币种’ |
orderQty | String | 订单数量 |
transactTime | String | 最后成交时间 |
timeInForce | String | '1: GTC, 3: IOC, 4: FOK' |
userID | String | 用户ID |
事件:FUTURES
事件返回的JSON格式数据如下
{
"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:17.000Z,
"updateTime":"2019-11-13T07:12:17.000Z,
"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"
}
以下情况下你将会收到提醒:
- 下单
- 订单变化
- 平仓
- 强平
- 杠杆变化
返回参数
变量 | 类型 | 描述 |
---|---|---|
closed | Object | 平仓信息 |
base | String | 交易对中的基础币种 |
commission | String | 已成交的手续费 |
filledPrice | String | 成交价格 |
filledQty | String | 成交数量 |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
leavesQty | String | 还未成交的订单数量 |
leverage | String | 杠杆 |
liqType | Integer | 期货的清算类型,“0:General,1:USER-CLOSE-LIQ,2:STOP-LIQ,3:TAKE-PROFIT-LIQ,4:STOP-LOSS-LIQ”。有关 liqType 的 更多详细信息。 |
liquidationPrice | String | 强平价格 |
margin | String | 锁定保证金金额 |
orderID | String | AAX 订单编号 |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
quote | String | 交易对中的计价币种 |
realisedPnl | String | 自建仓以来已实现的损益 |
unrealisedPnl | String | 未实现盈亏 |
side | Integer | 按交易方向进行筛选,“BUY” 或者 “SELL” |
taker | Boolean | True:挂单,False:吃单 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
transactTime | String | 最后成交时间 |
userID | String | userID |
opens | Object | 未成交订单信息 |
buy | Integer | 未成交订单中做多的合约张数 |
sell | Integer | 未成交订单中做空的合约张数 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
order | Object | 订单信息 |
avgPrice | String | 平均成交价格 |
base | String | 基础货币币种 |
clOrdID | String | 用户自定义订单ID |
code | String | 仅适用于期货合约。“FP”代表永续合约,null 代表现货 |
commission | String | 已成交的手续费 |
createTime | String | 订单创建时间 |
cumQty | String | 订单的累计成交数量 |
lastPrice | String | 成交价格 |
leavesQty | String | 还未成交的订单数量 |
leverage | String | 杠杆 |
liqType | Integer | 期货的清算类型,“0:General,1:USER-CLOSE-LIQ,2:STOP-LIQ,3:TAKE-PROFIT-LIQ,4:STOP-LOSS-LIQ”。有关 liqType 的 更多详细信息。 |
marketPrice | String | 市场价。(最高出价 + 最低叫价)/2 |
orderID | String | AAX 订单编号 |
orderQty | String | 订单数量 |
rejectCode | String | 订单拒绝代码 |
rejectReason | String | 订单被拒绝的原因 |
orderStatus | Integer | 订单状态,“0:待处理的新订单,1:新订单,2:部分成交,3:已成交,4:取消已拒绝,5:已取消,6:已拒绝,10:已过期,11:业务已拒绝” |
orderType | Integer | 订单类型。“1:Market Order(市价单),2:Limit Order(限价单),3:Stop Order(止损单),4:Stop Limit Order(限价止损单),7:Stop Loss Order(止损单),8:Take Profit Order(止盈单)” |
price | String | 委托价格。如果是下限价单,该参数为必填。 |
quote | String | 基础货币币种 |
settleType | String | 结算类型(INVERSE、VANILLA 或 QUANTO)(逆向、单纯或双币种结算) 关于 结算类型的更多详细信息。 |
side | Integer | “Long”(做多)或“Short”(做空)合约,e.g.“BUY,SELL” |
stopPrice | String | 限价止损单或止损单的触发价格 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
transactTime | String | 最后成交时间 |
updateTime | String | 订单的最后更新时间 |
timeInForce | String | '1: GTC, 3: IOC, 4: FOK' |
execInst | String | Post-Only or '' |
userID | String | 用户ID |
position | Object | 仓位信息 |
avgEntryPrice | String | 当前多头/空头仓位的平均买卖成交价格 |
bankruptPrice | String | 破产价格 |
base | String | 基础货币币种 |
code | String | 仅适用于期货合约。“FP”代表永续合约,null 代表现货 |
commission | String | 已成交的手续费 |
currentQty | String | 您当前交易对持有的仓位。如果为正,则为多头;如果为负,则为空头 |
funding | String | 自建仓以来以 BTC 收取/支付的资金金额。正号表示收取,负号表示支付 |
fundingStatus | Integer | 资金状态,0:结算中,1:已结算 |
posMargin | String | 持仓保证金 |
leverage | String | 仓位杠杆 |
liquidationPrice | String | 强平价格 |
marketPrice | String | 市场价。(最高出价 + 最低叫价)/2 |
openTime | String | 建仓时间戳(采用 UTC 时间) |
stopLossPrice | String | 止损价格 |
stopLossSource | Integer | 触发价格类型。 “1:最新市价” |
takeProfitPrice | String | 止盈价格 |
takeProfitSource | Integer | 触发价格类型。 “1:最新市价” |
quote | String | 基础货币币种 |
realisedPnl | String | 自建仓以来已实现的损益 |
riskyPrice | String | 风险价格,仅用于内部处理 |
settleType | String | 结算类型(INVERSE、VANILLA 或 QUANTO)(逆向、单纯或双币种结算) 关于 结算类型的更多详细信息。 |
symbol | String | 交易对。常用形式为“基础货币”+“报价货币”+“FP” |
userID | String | 用户ID |
event | String | 事件名称 |
错误码
错误代码 | 含义 |
---|---|
1 | 成功 |
10003 | 参数校验错误 |
10006 | 登录状态已过期,请重新登录 |
10007 | Token 错误 |
11007 | Token 格式错误 |
20001 | 您的可用余币不足,建议您先充币 |
20009 | 锁币数量不可小于0 |
30001 | 订单提交中,请稍后再试 |
30004 | 订单的数量不能低于{0} |
30005 | 数量的精度不能大于{0} |
30006 | 价格的精度不能大于{0} |
30007 | 价格不能低于{0} |
30008 | 止损价格的精度不能大于{0} |
30009 | 订单的止损价格不能低于{0} |
30010 | 市场价格为空 |
30011 | 订单正在撤销中,请耐心等待 |
30012 | 交易币种不存在 |
30013 | Symbol错误 |
30014 | 期货订单不存在 |
30015 | 订单已不属于当前委托,不可修改 |
30016 | 仓位不存在 |
30017 | 当前可平仓数量为0,建议您先撤销当前委托的订单 |
30018 | 订单价格不能大于{0} |
30019 | 订单数量不能大于{0} |
30020 | 订单价格必须是{0}的倍数 |
30021 | 调整的保证金必须大于0 |
30022 | 修改数量必须大于已成交数量 |
30023 | 下单失败,请重试 |
30024 | TimeInForce格式错误,只能是GTC 或者 IOC |
30025 | TimeInForce格式错误,只能是GTC |
30026 | 数量必须是{0}的倍数 |
30027 | 平仓失败,建议您先撤销当前委托再平仓 |
30028 | 该币种暂不支持交易 |
30029 | 修改数量或价格不能为空 |
30030 | 市价单不可修改价格 |
30031 | 平仓单不可修改 |
30032 | 最大杠杆不能大于{0} |
30033 | 最小杠杆不能小于{0} |
30034 | 最大委托单数量为{0},如需继续下单请先撤销部分委托 |
30035 | {0}最大委托单数量为{1},如需继续下单请先撤销部分委托 |
30036 | 清算进行中,请稍后重试 |
30037 | 订单已经触发计划委托,不可再修改触发价格 |
30038 | 您的订单总值已超出当前风险限额,请调整风险限额 |
30039 | 风险等级调整到{0}后,您的最大杠杆小于1,请重新调整 |
30040 | 订单状态有变化,请稍后重试 |
30041 | 清算订单,不可撤销 |
30042 | {0}合约最大限额 {1} BTC,请先撤销部分委托后操作 |
30043 | 风险限额不可小于0 |
30044 | Timeout不可大于60分钟 |
30045 | Side参数错误,应该是BUY或者SELL |
30046 | 订单类型参数错误,应该是MARKET或LIMIT或STOP-LIMIT或STOP |
30047 | 订单已关闭,不能取消 |
30048 | 市价单不能修改 |
30049 | 订单正在修改中,请稍后 |
30050 | 最多可下10单 |
40004 | 请求的资源不存在 |
40009 | 请求冲突,数据重复 |
41001 | HTTP消息不可读 |
41002 | 不支持的HTTP请求方法 |
42001 | 数据录入重复, 请检查后重试 |
50001 | 服务器异常,请稍后重试 |
50002 | 系统繁忙, 请稍后再试 |