1

尝试使用get_currency_exchange_daily黄金现货价格提取历史黄金价格时出现错误。

这是引发错误的python代码示例ValueError: Invalid API call. Please retry or visit the documentation (https://www.alphavantage.co/documentation/) for FX_DAILY.

from alpha_vantage.foreignexchange import ForeignExchange
# Your key here
key = 'XXX'
ts = ForeignExchange(key)
price, meta = ts.get_currency_exchange_daily(from_symbol='XAU', to_symbol='USD')

虽然这个 python 代码执行得很好

from alpha_vantage.foreignexchange import ForeignExchange
# Your key here
key = 'XXX'
ts = ForeignExchange(key)
price, meta = ts.get_currency_exchange_rate(from_currency='XAU', to_currency='USD')

我正在使用 Anaconda 环境中的 Python 3.8.2 运行它,尽管它不应该有所作为。非常感谢帮助。

4

1 回答 1

1

我相信使用日内数据并找到特定的 API 为我解决了这个问题:

from alpha_vantage.timeseries import TimeSeries
ts = TimeSeries(key='xxx',output_format='pandas')
data, meta_data = ts.get_intraday(symbol='RGLDOU.SWI',interval='1min', outputsize='full')
于 2020-06-27T09:08:42.210 回答