首页 > 解决方案 > Alpha vantage API "invalid api call" - 日内和货币数字货币汇率

问题描述

当我尝试获取加密货币的日内数据时,它会返回invalid api call

当我将其更改为每天时,请求工作正常。ForeignExchange 和 TimeSeries 也运行良好,只有加密货币和盘中的汇率。

这是我的代码:

from alpha_vantage.cryptocurrencies import CryptoCurrencies

ts = CryptoCurrencies(key="my_key", output_format="pandas")
data= ts.get_digital_currency_exchange_rate(symbol='BTC',market='USD')

这是我得到的错误:

ValueError: Invalid API call. Please retry or visit the documentation (https://www.alphavantage.co/documentation/) for CURRENCY_EXCHANGE_RATE.

标签: pythonapialpha-vantage

解决方案


有两个问题:

  1. Alpha Vantage 平台不提供对加密货币的日内支持。如果您查看文档,您会看到它有每日、每周和每月,但没有日内。
  2. 要获得 in 的价格,BTCUSD必须使用ForeignExchange. 这是您调整后的正常工作代码:
from alpha_vantage.foreignexchange import ForeignExchange

ts = ForeignExchange(key="my_key", output_format="pandas")
data= ts.get_currency_exchange_rate(from_currency='BTC',to_currency='USD')
print(data)

推荐阅读