DataReader google finance date not working

前端 未结 3 1066
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-06 15:24

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 worki

相关标签:
3条回答
  • 2021-01-06 16:13

    According to data reader docs, Yahoo!, Google Options, Google Quotes and EDGAR have been immediately deprecated due to large changes in their API and no stable replacement. Use 'iex' instead

    import pandas_datareader.data as web
    import datetime as dt    
    
    start = dt.datetime(2018,1,1)
    end = dt.datetime(2019,1,1)
    
    aapl = web.DataReader('AAPL', 'iex', start, end)
    
    aapl.shape
    (251, 5)
    
    aapl.head()
    
        open    high    low close   volume
    date                    
    2018-01-02  167.6431    169.7514    166.7564    169.7120    25555934
    2018-01-03  169.9780    171.9682    169.4165    169.6825    29517899
    2018-01-04  169.9879    170.9041    169.5347    170.4707    22434597
    2018-01-05  170.8746    172.7760    170.4904    172.4115    23660018
    2018-01-08  171.7711    173.0125    171.3573    171.7711    20567766
    
    0 讨论(0)
  • 2021-01-06 16:14

    The url has now been updated, so upgrading datareader will fix the problem:

    sudo pip install pandas_datareader --upgrade

    0 讨论(0)
  • 2021-01-06 16:21

    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.

    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.

    The url is set in the source code: https://github.com/pydata/pandas-datareader/blob/master/pandas_datareader/google/daily.py

    Maybe you can modify the URL and use your own version of pandas_datareader.

    0 讨论(0)
提交回复
热议问题