[英]OHLC data for bitcoin using bitfinex's API - issue with API
Using this API call I want to get a complete BTCUSD data set for 5 minute OHLC data. 使用此 API调用,我想获取5分钟OHLC数据的完整BTCUSD数据集。
I tried the following code in python but the API isn't returning the right data: 我在python中尝试了以下代码,但API未返回正确的数据:
import requests
import pandas as pd
r = requests.post('https://api.bitfinex.com/v2/candles/trade:5m:tBTCUSD/hist', data={'start': 1434764470000, 'end': 1497922870000})
data = r.json()
Can anyone offer any help ? 有人可以提供任何帮助吗?
David! 大卫!
That Bitfinex v2 endpoint is actually meant to be accessed via HTTP GET, not POST. 该Bitfinex v2端点实际上是要通过HTTP GET而不是POST访问的。
The params should be appended to the URL query like so: 应将参数附加到URL查询中,如下所示:
https://api.bitfinex.com/v2/candles/trade:5m:tBTCUSD/hist?start=1434764470000&end=1497922870000 https://api.bitfinex.com/v2/candles/trade:5m:tBTCUSD/hist?start=1434764470000&end=1497922870000
Also, you should be more specific on what you mean by the right data . 另外,您应该更具体地说明正确数据的含义。 If you don't get the answer at all - it may be due to a malformed request.
如果您根本找不到答案-可能是由于请求格式错误。 If the prices are not corresponding to what you expect for requested period of history - you may want to ensure your timestamps are UTC time.
如果价格与请求的历史记录期的价格不符-您可能需要确保时间戳记为UTC时间。
If you don't pass start and end filters in the HTTP GET URL querystring, you always get last 100 candles, as if there was no start/end filtering at all. 如果未在HTTP GET URL查询字符串中传递开始和结束过滤器,则始终会获得最后100根蜡烛,就好像根本没有开始/结束过滤一样。
import requests
url = 'https://api.bitfinex.com/v2/candles/trade:5m:tBTCUSD/hist'
params = { 'start': 1434764470000, 'end': 1497922870000 }
r = requests.get(url, params = params)
data = r.json()
print(data)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.