接口:coinbar
描述:获取数字货币行情数据,目前支持币币交易和期货合约交易。如果是币币交易,exchange参数请输入huobi,okex,binance,bitfinex等。如果是期货,exchange参数请输入future_xxx,比如future_okex,future_bitmex。
注:因访问量激增,造成服务器压力增大,我们需要采购更多的机器来存储和提供数据服务,需要赞助1000元或同等币值获得数据权限。支持微信、支付宝赞助,也支持数字货币赞助
输入参数
名称 | 类型 | 必选 | 描述 |
---|---|---|---|
exchange | str | Y | 交易所名称 |
symbol | str | Y | 数字货币交易对 |
start_date | datetime | N | 开始时间 |
end_date | datetime | N | 结束时间 |
freq | str | Y | 行情频率 |
contract_type | str | N | 合约类型(只在exchange='future_xxx'情况下有用) |
输出参数
名称 | 类型 | 描述 |
---|---|---|
symbol | str | 数字货币交易对 |
date | datetime | 行情时间 |
open | float | 开盘价 |
high | float | 最高价 |
low | float | 最低价 |
close | float | 收盘价 |
count | int | 成交笔数(默认不展示,有些交易所没有此项数据,若需要请在fields里添加) |
contract_type | str | 合约类型 (只在取期货数据才有数据) |
vol | float | 成交量 |
amount | float | 成交额 (默认不展示,需在fields里添加上,有些交易所没有此项数据) |
freq说明
freq | 说明 |
---|---|
1min | 1分钟 |
5min | 5分钟 |
15min | 15分钟 |
30min | 30分钟 |
60min | 60分钟 |
daily | 日线 |
week | 周线 |
关于期货合约类型
future_okex的contract_type有三种: this_week / next_week / quarter
future_bitmex的contract_type有五种: perpetual / biquarterly / quarterly / monthly / weekly
接口用法
pro = ts.pro_api()
df = pro.coinbar(exchange='huobi', symbol='btcusdt', freq='15min', start_date='20180801', end_date='20180802')
或者
df = pro.query('coinbar', exchange='huobi', symbol='btcusdt', freq='15min', start_date='20180801', end_date='20180802')
数据样例
symbol date open high low close \
0 btcusdt 2018-08-01 00:00:00 7757.99 7761.44 7748.95 7748.96
1 btcusdt 2018-08-01 00:01:00 7748.96 7748.96 7735.00 7741.99
2 btcusdt 2018-08-01 00:02:00 7738.19 7741.03 7728.69 7729.02
3 btcusdt 2018-08-01 00:03:00 7729.02 7738.34 7715.10 7729.26
4 btcusdt 2018-08-01 00:04:00 7729.26 7734.10 7719.95 7730.00
5 btcusdt 2018-08-01 00:05:00 7730.00 7730.00 7720.00 7721.27
6 btcusdt 2018-08-01 00:06:00 7719.96 7725.93 7719.41 7722.92
7 btcusdt 2018-08-01 00:07:00 7722.92 7724.76 7719.17 7722.30
8 btcusdt 2018-08-01 00:08:00 7722.30 7722.30 7715.89 7719.67
9 btcusdt 2018-08-01 00:09:00 7718.12 7722.00 7709.88 7716.67
10 btcusdt 2018-08-01 00:10:00 7717.36 7721.20 7713.62 7721.18
11 btcusdt 2018-08-01 00:11:00 7721.18 7728.88 7721.17 7728.87
12 btcusdt 2018-08-01 00:12:00 7728.87 7729.80 7725.63 7729.15
13 btcusdt 2018-08-01 00:13:00 7729.15 7737.99 7728.39 7737.98
14 btcusdt 2018-08-01 00:14:00 7738.01 7744.80 7737.98 7743.30
15 btcusdt 2018-08-01 00:15:00 7743.30 7755.00 7743.12 7744.03
16 btcusdt 2018-08-01 00:16:00 7746.33 7755.00 7745.39 7746.06
17 btcusdt 2018-08-01 00:17:00 7746.06 7756.00 7746.05 7755.68