Coinbase API v2 获取多日历史价格

Coinbase API v2 Getting Historic Price for Multiple Days

我在 Coinbase.com API 请求历史数据时遇到了一些问题。

以前,我得到的天数是可变的,与终端屏幕上可用的 space 天数相匹配,请求 URL 看起来像这样:

https://api.coinbase.com/v2/prices/historic?currency=USD&days=76

这将提取前 76 天的价格历史记录。旧输出的示例如下: https://gist.github.com/KenDB3/f071a06ab3ef1a899d3cd8df8b40a049#file-coinbase-historic-days-example-2017-12-23-json

这几天前就停止工作了。我最接近这个的是这个请求URL(虽然我没有得到我想要的数据):

https://api.coinbase.com/v2/prices/BTC-USD/historic?days=76

可以在这里看到输出: https://gist.github.com/KenDB3/f071a06ab3ef1a899d3cd8df8b40a049#file-coinbase-historic-days-example-2018-07-19-json

在第二个示例中,它只是在当天的不同时间显示查询当天的价格。我真正想要的是第一个示例输出,它给出了每天的单一价格,可以追溯到请求的天数。

连接到的项目在这里: https://github.com/KenDB3/SyncBTC

无效的链接: https://api.coinbase.com/v2/prices/historic?currency=BTC-USD&days=76 (没有结果) https://api.coinbase.com/v2/prices/BTC-USD/historic?2018-07-15T00:00:00-04:00 (不从 7/15/2018 提取数据)

您不使用 coinbase pro 的原因是什么?

新的api非常易于使用。只需添加您想要的 get 命令,然后添加以问号分隔的参数。这是新的历史汇率 api 文档: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductcandles

与价格最相似的新 api 获取命令是“蜡烛”。它需要识别三个参数,iso 格式的开始和停止时间以及以秒为单位的粒度。这是一个例子:

https://api.pro.coinbase.com/products/BTC-USD/candles?start=2018-07-10T12:00:00&end=2018-07-15T12:00:00&granularity=900

编辑:另外,请注意时区不适合您的时区,我相信是格林威治标准时间。

这是 CoinBase API 的包装器,用于导出历史数据:https://pypi.org/project/Historic-Crypto/

它应该通过调用提供所需的结果:

pip install Historic-Crypto
from Historic_Crypto import HistoricalData
new = HistoricalData('ETH-USD',300,'2020-06-01-00-00').retrieve_data()

可用加密货币的完整列表:

pip install Historic-Crypto
from Historic_Crypto import Cryptocurrencies

data = Cryptocurrencies(extended_output=False).find_crypto_pairs()