-
Notifications
You must be signed in to change notification settings - Fork 29
GOAi API 接口文档
GOAi edited this page Mar 1, 2019
·
7 revisions
- 接口名称:GOAi开放接口
- 版本:V0.1.0
- 接口用途:量化策略通过调用GOAI接口,访问各个不同交易所
- 是否申请白名单:否
- 协议:HTTP/websocket
- 支持接入语言:JAVA
- 编码:UTF-8
- 特殊说明:时间戳单位,除了Kline类的time是秒单位,其余为毫秒单位。
- Ticker getTicker();
- Ticker getTicker(boolean latest);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| latest | boolean | true->获取最新的ticker,有访问过频问题 false->允许不是最新的,3秒 |
| 字段类型 | 说明 |
|---|---|
| Ticker | 市场心跳 |
- Klines getKlines(); (默认1分钟k线)
- Klines getKlines(Period period);
- Klines getKlines(boolean latest);
- Klines getKlines(Period period, boolean latest);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| period | Period | 周期 |
| latest | boolean | true->获取最新的Klines,有访问过频问题 false->允许不是最新的 |
| 字段类型 | 说明 |
|---|---|
| Klines | k线类 |
- Depth getDepth();
- Depth getDepth(boolean latest);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| latest | boolean | true->获取最新的Depth,有访问过频问题 false->允许不是最新的 |
| 字段类型 | 说明 |
|---|---|
| Depth | 深度 |
- Trades getTrades();
- Trades getTrades(boolean latest);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| latest | boolean | true->获取最新的Trades,有访问过频问题 false->允许不是最新的 |
| 字段类型 | 说明 |
|---|---|
| Trades | 成交记录列表 |
- Balances getBalances();
无
| 字段类型 | 说明 |
|---|---|
| Balances | 账户下所有币余额信息 |
- Account getAccount();
- Account getAccount(boolean latest);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| latest | boolean | true->获取最新的getAccount,有访问过频问题 false->允许不是最新的 |
| 字段类型 | 说明 |
|---|---|
| Account | 某个币对账户信息类 |
- Precisions getPrecisions();
无
| 字段类型 | 说明 |
|---|---|
| getPrecisions | 币对账户信息列表 |
- Precision getPrecision();
无
| 字段类型 | 说明 |
|---|---|
| Precision | 币对账户信息类 |
- String buyLimit(BigDecimal price, BigDecimal amount);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| price | BigDecimal | 订单价格 |
| amount | BigDecimal | 订单数量 |
| 字段类型 | 说明 |
|---|---|
| String | 订单id |
- String sellLimit(BigDecimal price, BigDecimal amount);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| price | BigDecimal | 订单价格 |
| amount | BigDecimal | 订单数量 |
| 字段类型 | 说明 |
|---|---|
| String | 订单id |
- List multiBuy(List bids);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| bids | List | 批量下单row |
| 字段类型 | 说明 |
|---|---|
| List | 批量订单id |
- List multiSell(List asks);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| asks | List | 批量下单row |
| 字段类型 | 说明 |
|---|---|
| List | 批量订单id |
- String buyMarket(BigDecimal quote);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| quote | BigDecimal | 订单总价 |
| 字段类型 | 说明 |
|---|---|
| String | 订单id |
- String sellMarket(BigDecimal base);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| base | BigDecimal | 订单数量 |
| 字段类型 | 说明 |
|---|---|
| String | 订单id |
- boolean cancelOrder(String id);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| id | BigDecimal | 订单id |
| 字段类型 | 说明 |
|---|---|
| boolean | 取消是否成功 |
- List cancelOrders(List ids);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| ids | List | 订单id列表 |
| 字段类型 | 说明 |
|---|---|
| List | 成功取消的订单id列表 |
- Orders getOrders();
无
| 字段类型 | 说明 |
|---|---|
| Orders | 活跃订单列表 |
- Orders getHistoryOrders();
无
| 字段类型 | 说明 |
|---|---|
| Orders | 历史订单 |
- Order getOrder(String id);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| id | BigDecimal | 订单id |
| 字段类型 | 说明 |
|---|---|
| Orders | 订单 |
- OrderDetails getOrderDetails(String id);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| id | BigDecimal | 订单id |
| 字段类型 | 说明 |
|---|---|
| OrderDetails | 多个订单成交明细记录 |
- protected void onTicker(Ticker ticker);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| ticker | Ticker | 市场心跳 |
@Override
protected void onTicker(Ticker ticker) {
log.info("{} onTicker --> ticker last: {}", id, exist(ticker) ? ticker.getLast() : null);
}
- protected void onKlines(Klines Klines);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| Klines | Klines | k线 |
- protected void onDepth(Depth depth);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| depth | Depth | 深度 |
- protected void onTrades(Trades trades);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| trades | Trades | 成交订单列表 |
- protected void onAccount(Account account);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| account | Account | 币对余额 |
- protected void onOrders(Orders orders);
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| orders | Orders | 订单列表 |
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| data | String | 交易所返回的原始数据, 防止有些用户需要一些特殊的数据 |
| time | Long | 时间戳 |
| open | BigDecimal | 开盘价 |
| high | BigDecimal | 最高价 |
| low | BigDecimal | 最低价 |
| last | BigDecimal | 收盘价 |
| volume | BigDecimal | 交易量 |
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| data | String | 交易所返回的原始数据, 防止有些用户需要一些特殊的数据 |
| time | Long | 时间戳(秒) |
| open | BigDecimal | 开盘价 |
| high | BigDecimal | 最高价 |
| low | BigDecimal | 最低价 |
| close | BigDecimal | 收盘价 |
| volume | BigDecimal | 交易量 |
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| data | String | 交易所返回的原始数据, 防止有些用户需要一些特殊的数据 |
| time | Long | 时间戳 |
| asks | Rows | 卖盘数据,由低到高 |
| bids | Rows | 买盘数据,由高到低 |
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| data | String | 交易所返回的原始数据, 防止有些用户需要一些特殊的数据 |
| time | Long | 时间戳 |
| id | String | 交易id |
| side | Side | 方向 |
| price | BigDecimal | 价格 |
| amount | BigDecimal | 数量 |
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| data | String | 交易所返回的原始数据, 防止有些用户需要一些特殊的数据 |
| Currency | String | 币的名称:BTC、USD等 |
| free | BigDecimal | 可用数量 |
| used | BigDecimal | 冻结数量 |
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| time | Long | 时间戳 |
| base | Balance | 目标货币 BTC_USD 中的 BTC余额 |
| quote | Balance | 目标货币 BTC_USD 中的 USD余额 |
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| data | String | 交易所返回的原始数据, 防止有些用户需要一些特殊的数据 |
| time | Long | 时间戳 |
| base | BigDecimal | 交易时币精度,amount |
| quote | BigDecimal | 计价货币精度 |
| baseStep | BigDecimal | 最小币步长 |
| quoteStep | BigDecimal | 最小价格步长 |
| minBase | BigDecimal | 最小买卖数量 |
| minquote | BigDecimal | 最小买价格 |
| maxBase | BigDecimal | 最大买卖数量 |
| maxquote | BigDecimal | 最大买价格 |
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| data | String | 交易所返回的原始数据, 防止有些用户需要一些特殊的数据 |
| time | Long | 时间戳 |
| id | String | 订单id |
| side | Side | 买卖方向 |
| type | Type | 订单类型 |
| state | State | 订单状态 |
| price | BigDecimal | 下单价格 |
| amount | BigDecimal | 下单数量 |
| deal | BigDecimal | 成交数量 |
| average | BigDecimal | 成交均价 |
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| data | String | 交易所返回的原始数据, 防止有些用户需要一些特殊的数据 |
| time | Long | 时间戳 |
| orderId | String | 订单id |
| detailId | String | 成交明细id |
| price | BigDecimal | 成交价格 |
| amount | BigDecimal | 成交数量 |
| fee | BigDecimal | 手续费 |
| feeCurrency | String | 手续费货币 |
| side | Side | 买卖方向 |
| 字段名 | 字段类型 | 说明 |
|---|---|---|
| data | String | 交易所返回的原始数据, 防止有些用户需要一些特殊的数据 |
| price | BigDecimal | 成交价格 |
| amount | BigDecimal | 成交数量 |
public enum Period {
// 1分钟
MIN1 (60),
// 3分钟
MIN3 (60 * 3),
// 5分钟
MIN5 (60 * 5),
// 15分钟
MIN15 (60 * 15),
// 30分钟
MIN30 (60 * 30),
// 1小时
HOUR1 (60 * 60),
// 2小时
HOUR2 (60 * 60 * 2),
// 3小时
HOUR3 (60 * 60 * 3),
// 4小时
HOUR4 (60 * 60 * 4),
// 6小时
HOUR6 (60 * 60 * 6),
// 12小时
HOUR12 (60 * 60 * 12),
// 1天
DAY1 (60 * 60 * 24),
// 3天
DAY3 (60 * 60 * 24 * 3),
// 1周
WEEK1 (60 * 60 * 24 * 7),
// 2周
WEEK2 (60 * 60 * 24 * 14),
// 1月
MONTH1 (60 * 60 * 24 * 30);
}
public enum Side {
// 买
BUY,
// 卖
SELL,
}
public enum Type {
// 限价单
LIMIT,
// 市价单
MARKET,
// FOK
FILL_OR_KILL,
// IOC
IMMEDIATE_OR_CANCEL,
}
public enum State {
// 已提交
SUBMIT,
// 已成交
FILLED,
// 已取消
CANCEL,
// 部分成交
PARTIAL,
// 部分成交后取消
UNDONE,
}
- getTicker:获取市场心跳
- getKlines :获取k线
- getDepth:获取深度
- getTrades:获取成交记录
- getBalances:获取账户所有余额
- getAccount:获取某个币对账户信息
- getPrecisions:获取所有币对精度信息
- getPrecision:获取币对精度信息
- buyLimit:限价买
- sellLimit:限价卖
- multiBuy:批量买
- multiSell:批量卖
- buyMarket:市价买
- sellMarket:市价卖
- cancelOrder:取消指定订单
- cancelOrders:取消多个订单
- getOrders:获取活跃订单
- getHistoryOrders:获取历史订单
- getOrder:获取指定订单
- getOrderDetails:获取订单成交明细