Pandas Google Datareader 只返回 1 年的股票数据
Pandas Google Datareader only returning 1 year of stock data
它过去可以提取 15 年的数据,而不仅仅是 returns 1 年的数据,无论您的 "start" 日期如何。还有其他人遇到这个问题吗?
我将 spyder 用作 IDE。我做了以下操作,它现在对我有用:
- 右键单击 "wb.DataReader(symbol, 'google', start, end)" 和 select "Go to definition"
中的 DataReader
- 在打开的页面顶部,右键单击来自 "pandas_datareader.google.daily import GoogleDailyReader" 和 select "Go to definition"
的 GoogleDailyReader
- 在打开的文件中将 'http://www.google.com/finance/historical' 更改为 return 'http://finance.google.com/finance/historical'
- 关闭spyder,再打开。它应该工作!
另一种解决方案是为 GoogleDailyReader 创建包装器并更改此包装器中的 URL:
from pandas_datareader.google.daily import GoogleDailyReader
class FixedGoogleDailyReader(GoogleDailyReader):
@property
def url(self):
return 'http://finance.google.com/finance/historical'
start = datetime.datetime(2012, 1, 1)
end = datetime.datetime.now()
reader = FixedGoogleDailyReader(symbols=['AMZN', 'IBM'], start=start, end=end, chunksize=25, retry_count=3, pause=0.001, session=None)
reader.read()
它过去可以提取 15 年的数据,而不仅仅是 returns 1 年的数据,无论您的 "start" 日期如何。还有其他人遇到这个问题吗?
我将 spyder 用作 IDE。我做了以下操作,它现在对我有用:
- 右键单击 "wb.DataReader(symbol, 'google', start, end)" 和 select "Go to definition" 中的 DataReader
- 在打开的页面顶部,右键单击来自 "pandas_datareader.google.daily import GoogleDailyReader" 和 select "Go to definition" 的 GoogleDailyReader
- 在打开的文件中将 'http://www.google.com/finance/historical' 更改为 return 'http://finance.google.com/finance/historical'
- 关闭spyder,再打开。它应该工作!
另一种解决方案是为 GoogleDailyReader 创建包装器并更改此包装器中的 URL:
from pandas_datareader.google.daily import GoogleDailyReader
class FixedGoogleDailyReader(GoogleDailyReader):
@property
def url(self):
return 'http://finance.google.com/finance/historical'
start = datetime.datetime(2012, 1, 1)
end = datetime.datetime.now()
reader = FixedGoogleDailyReader(symbols=['AMZN', 'IBM'], start=start, end=end, chunksize=25, retry_count=3, pause=0.001, session=None)
reader.read()