Bitfinex 数据接口

编程入门 行业动态 更新时间:2024-10-27 08:37:46
本文介绍了Bitfinex 数据接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试使用 bitfinex REST api 获取历史 OHLC 数据,文档在这里:https://bitfinex.readme.io/v2/reference#rest-public-candles

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/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 个元素的列表,而不是给定时间段内的所有柱,我尝试更改限制"参数,但它最大为 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 time * 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/v2/trades/tBTCUSD/hist?end=1509674567000&limit=1000&sort=-1

将返回一个响应,其中第一行是最接近 '1509674567000' 时间戳(常规 Unix 时间中的 '1509674567'),最后一行将是 '1509674567000' 之前的 999 交易(应该是 '150967073).

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 数据接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-18 06:38:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/932810.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:接口   数据   Bitfinex

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!