使用panda datareader从谷歌财务下载股票数据的问题

时间:2017-09-19 18:37:55

标签: python finance google-finance

过去几天前工作的事情很棒。现在,当我运行以下内容时:

from pandas_datareader import data
symbol = 'AMZN'
data_source='google'
start_date = '2010-01-01'
end_date = '2016-01-01'

df = data.DataReader(symbol, data_source, start_date, end_date)

我只得到下面显示的一年的最新数据,好像start_data和end_data似乎并不重要。将它们更改为不同的日期会产生相同的结果。有谁知道为什么?

结果:

df.head()
              Open    High     Low   Close    Volume
Date                                                
2016-09-21  129.13  130.00  128.39  129.94  14068336
2016-09-22  130.50  130.73  129.56  130.08  15538307
2016-09-23  127.56  128.60  127.30  127.96  28326266
2016-09-26  127.37  128.16  126.80  127.31  15064940
2016-09-27  127.61  129.01  127.43  128.69  15637111

3 个答案:

答案 0 :(得分:4)

使用fix-yahoo-finance,然后使用yahoo而不是Google作为您的来源。看起来谷歌最近一直在锁定大量数据。

首先,您需要安装fix-yahoo-finance。只需使用pip install fix-yahoo-finance

然后使用get_data_yahoo

from pandas_datareader import data
import fix_yahoo_finance as yf
yf.pdr_override() 

symbol = 'AMZN'
data_source='google'
start_date = '2010-01-01'
end_date = '2016-01-01'
df = data.get_data_yahoo(symbol, start_date, end_date)

df.head()
                 Open       High        Low      Close  Adj Close    Volume
Date                                                                       
2010-01-04  136.25000  136.61000  133.14000  133.89999  133.89999   7599900
2010-01-05  133.42999  135.48000  131.81000  134.69000  134.69000   8851900
2010-01-06  134.60001  134.73000  131.64999  132.25000  132.25000   7178800
2010-01-07  132.01000  132.32001  128.80000  130.00000  130.00000  11030200
2010-01-08  130.56000  133.67999  129.03000  133.52000  133.52000   9830500

答案 1 :(得分:2)

只需用雅虎取代谷歌。谷歌源码现在有问题。 enter image description here

a.show(); // the service loader finds the service provider of this service using inheritence
x.show(); // same class 
w.show(); // using super

答案 2 :(得分:1)

雅虎从2020年1月1日开始工作:

import pandas_datareader.data as web
import datetime
start = datetime.datetime(2015, 1, 1)
end = datetime.datetime(2018, 2, 8)
df = web.DataReader('TSLA', 'yahoo', start, end)
print(df.head())
相关问题