Bitfinex数据API [英] Bitfinex data api

查看:271
本文介绍了Bitfinex数据API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用bitfinex REST api获取历史记录的OHLC数据,此处的文档:

I am trying to get historic OHLC data using the bitfinex REST api, docs here: https://bitfinex.readme.io/v2/reference#rest-public-candles

我有以下代码:

try: 
     url = 'https://api.bitfinex.com/v2/candles/trade:1m:tBTCUSD/hist'
     params = { 'start': 1506816000, 'end': 1509674567 }
     r = requests.get(url, params = params)
     data = r.json()
     print(json.dumps(data, indent=2))

 except Exception, e:
     print e

运行代码时,我得到一个列表,其中仅包含100个元素,并且在给定期间内没有所有柱线,我尝试更改'limit'参数,但该参数最大值为1000,少于一天的时间为1分钟酒吧.

When I run the code I get a list with only 100 elements and not all bars within the given period, I have tried changing the 'limit' parameter but it maxes out at 1000, which is less then a day for 1 minute bars.

我还尝试通过以下网址使用cryptowatch的市场数据API: https ://api.cryptowat.ch/markets/gdax/btcusd/ohlc 但是无论我为开始和结束时间传递什么参数,它都只会返回最后的500条. (但是,与大多数其他API一样,我希望能够指定时间范围并获取多个月的数据)

I also tried to use the market data API from cryptowatch using the following url: https://api.cryptowat.ch/markets/gdax/btcusd/ohlc but no matter what parameters I pass for the start and end time it just gives back the last 500 bars. (However I want to be able to specify the time frame and get multiple months of data, as with most other API's)

有什么方法可以从Bitfinex获取历史数据吗?在大多数情况下,它们的API都有据可查的文档,因此让我感到惊讶的是,仅获取历史数据是如此困难.

Is there any way to get historic data from Bitfinex? For the most part their API is well documented so I am surprised that just getting historic data is so hard.

推荐答案

Bitfinex API花费Unix时间* 1000,表示:

Bitfinex API takes unix time * 1000, meaning:

 params = { 'start': 1506816000000, 'end': 1509674567000 }

您还可以添加"sort ="参数以按升序或降序对响应进行排序,还可以使您仅提供开始"参数或结束"参数 例如:

you can also add a "sort=" parameter to sort the response by ascending or descending order, also enabling you to provide only a 'start' param or 'end' param example:

https://api.bitfinex.com/v2/trades/tBTCUSD/hist?end=1509674567000&limit=1000&sort=-1

将返回一个响应,其中第一行是最接近于'1509674567000'时间戳(在常规unix时间中为'1509674567')发生的交易,而最后一行仅是'1509674567000'之前的999交易(应为'1509673162000') ).

will return a response where the first row is the closest trade occured to '1509674567000' timestamp ('1509674567' in regular unix time) and the last row would just be 999 trade before '1509674567000' (should be at '1509673162000').

这篇关于Bitfinex数据API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆