修复从Yahoo Finance下载股票数据的问题

时间:2017-10-20 09:17:20

标签: python pandas yahoo-finance yahoo-api

我正在尝试使用Python从Yahoo Finance下载DJIA数据。

from pandas_datareader import data as pdr
import fix_yahoo_finance as yf # Fix for downloading financial data from Yahoo, as the Pyhton Yahoo API has stopped working

yf.pdr_override()

djia = pdr.get_data_yahoo("^DJI", start="2017-10-20", end="2015-10-20")

但是我收到了这个错误

Auto-overriding of pandas_datareader's get_data_yahoo() is deprecated and no longer available.

我可以从雅虎下载DJIA数据吗?

1 个答案:

答案 0 :(得分:1)

import fix_yahoo_finance as yf
import datetime as dt
start = dt.datetime(2012,5,31)
end = dt.datetime(2018,5,31)
data = yf.download('DIA',start = start,end = end)

此代码将适用于从Yahoo Finance下载Dot。

您不需要使用pandas_datareader