雅虎财经API / URL无法工作:修复Pandas DataReader的Python方法

8 浏览
0 Comments

雅虎财经API / URL无法工作:修复Pandas DataReader的Python方法

自2017年5月16日起,使用Pandas DataReader的"yahoo"方法无法访问Yahoo Finance的URL。我尚未测试昨天发布的fix-yahoo-finance:https://pypi.python.org/pypi/fix-yahoo-finance,其中声明:"Yahoo! finance已停用其历史数据API"。

编辑于2017年8月2日:我已经按照https://pypi.python.org/pypi/fix-yahoo-finance中的步骤进行操作:$ pip3 install fix_yahoo_finance --upgrade --no-cache-dir,将pandas_datareader升级为与"fix-yahoo-finance 0.0.6"兼容,并修改了代码:

from pandas_datareader import data as pdr
import fix_yahoo_finance
data = pdr.get_data_yahoo('AAPL', start='2017-04-23', end='2017-05-24')

请注意,最后两列数据的顺序是'Adj Close'和'Volume',即不同于以前的格式。对于我的目的,它们只是被重置为原始格式:

cols = ['Date', 'Open', 'High', 'Low', 'Close', 'Volume', 'Adj Close']
data.reindex(columns=cols)

0