import pandas_datareader.data as web
df = web.DataReader('^GSPC', 'yahoo', start='1950-01-03', end='2017-09-14')
如果我访问Yahoo Finance网站,我可以手动从1950年下载数据,那么为什么我不能使用pandas datareader呢?我的意思是我已经获得了数据,只是好奇它为什么不起作用。
编辑:我收到此错误:
Traceback (most recent call last):
File "C:/Users/x/PycharmProjects/Programming for Finance/getsp.py", line 7, in <module>
df = web.DataReader('^GSPC', 'yahoo', start='1950-01-03', end='2017-09-14')
File "C:\Users\x\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas_datareader\data.py", line 121, in DataReader
session=session).read()
File "C:\Users\x\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas_datareader\yahoo\daily.py", line 115, in read
df = super(YahooDailyReader, self).read()
File "C:\Users\x\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas_datareader\base.py", line 181, in read
params=self._get_params(self.symbols))
File "C:\Users\x\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas_datareader\yahoo\daily.py", line 99, in _get_params
unix_start = int(time.mktime(self.start.timetuple()))
OverflowError: mktime argument out of range