Alpha vantage API“无效API调用”日内和货币数字货币汇率

2024-10-06 21:21:36 发布

您现在位置:Python中文网/ 问答频道 /正文

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

当我将其更改为“每日”时,请求工作正常。外汇和时间序列也运行良好,只有加密货币和日内的汇率

这是我的密码:

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.

Tags: 数据keyfromapi密码汇率documentation时间
1条回答
网友
1楼 · 发布于 2024-10-06 21:21:36

有两个问题:

  1. Alpha Vantage平台上不提供加密货币的日内支持。如果你去documentation你会看到它有每日、每周和每月,但不是日内
  2. 要获得USDBTC的价格,必须使用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)

相关问题 更多 >