【问题标题】:Pandas Google Datareader only returning 1 year of stock dataPandas Google Datareader 仅返回 1 年的股票数据
【发布时间】:2017-09-16 20:48:46
【问题描述】:

它曾经能够提取 15 年的数据,而不是只返回 1 年的数据,而不管您的“开始”日期如何。其他人有这个问题吗?

【问题讨论】:

  • 也许是“Google”方面的问题?
  • 可能是。我曾经使用雅虎,他们一起禁用了他们的 API
  • 是的,我前段时间试过了,但我也做不到。您可以使用investing,但较小的时间范围是 1D

标签: python pandas stock


【解决方案1】:

我使用 spyder 作为 IDE。我做了以下工作,现在对我有用:

  1. 右键单击“wb.DataReader(symbol, 'google', start, end)”中的 DataReader 并选择“转到定义”
  2. 在打开的页面顶部,右键单击“pandas_datareader.google.daily import GoogleDailyReader”中的 GoogleDailyReader,然后选择“转到定义”
  3. 在打开的文件中将“http://www.google.com/finance/historical”更改为“http://finance.google.com/finance/historical”
  4. 关闭 spyder 并再次打开它。它应该工作!

【讨论】:

  • 感谢您的想法。我试试看
  • 成功了,谢谢!!你是怎么想到这样的事情的?
【解决方案2】:

另一种解决方案是为 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()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-06
    • 2011-01-17
    • 2021-03-23
    • 1970-01-01
    • 2019-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多