DataReader Google财务日期不起作用 [英] DataReader google finance date not working
问题描述
我只是使用pandas datareader来获取过去两周左右的库存数据,并且运行良好.从昨天开始,提供的日期突然失效了.它只是提供了过去一年的数据,我无法更改日期.曾经与被注释掉的那个一起工作,但是现在没有.我什至将其更改为使用datetime对象,但仍然无法正常工作.任何的想法?我更新了pandas和pandas_datareader仍然没有运气.用另一台电脑仍然没有工作.他们是最近才更改API的吗?
I was just using pandas datareader to get the stock data for the past two weeks or so and it was working fine. All of a sudden since yesterday the date provided wasnt working anymore. It just gives me the past year data and I cant change the date. Used to work with the one commented out, but now its not. I even changed it to use datetime object, but still not working. Any idea? I updated pandas and pandas_datareader still no luck. Used another computer still didnt work. Did they just recently change the API?
from pandas_datareader import data
import datetime
#start = '2010-01-01'
#end = '2017-7-31'
start = datetime.datetime(2010, 1, 1)
end = datetime.datetime(2017,7, 31)
f = data.DataReader('AAPL', 'google', start, end)
print(f.head())
输出:
Open High Low Close Volume
Date
2016-09-19 115.19 116.18 113.25 113.58 47023046
2016-09-20 113.05 114.12 112.51 113.57 34514269
2016-09-21 113.85 113.99 112.44 113.55 36003185
2016-09-22 114.35 114.94 114.00 114.62 31073984
2016-09-23 114.42 114.79 111.55 112.71 52481151
推荐答案
Google已将Google财经URL更改为Finance.google.com/finance/historical而不是www.google.com/finance/historical,该网址用作pandas_datareader中的URL.
Google has changed the Google Finance URL to finance.google.com/finance/historical rather than www.google.com/finance/historical, which is used as the URL in the pandas_datareader.
从旧URL提取数据并重定向到新URL时,服务器返回HTTP 302.但是,HTTP重定向期间缺少参数startdate/enddate.
Server returns HTTP 302 when fetching data from the old URL and redirect to the new URL. However, the parameters startdate/enddate are missing during the HTTP redirection.
URL是在源代码中设置的: https://github.com/pydata/pandas-datareader/blob/master/pandas_datareader/google/daily.py
The url is set in the source code: https://github.com/pydata/pandas-datareader/blob/master/pandas_datareader/google/daily.py
也许您可以修改URL并使用自己的pandas_datareader版本.
Maybe you can modify the URL and use your own version of pandas_datareader.
这篇关于DataReader Google财务日期不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!