Search code examples
pythonpandas-datareader

Problems with Pandas DataReader and Yahoo


I was trying to get stock information as follows:

from pandas.io.data import DataReader
import datetime
data = DataReader("F", "yahoo", datetime.datetime(1990, 1, 1),datetime.datetime(2002, 1, 1))

which fails with

IOError: after 3 tries, Yahoo! did not return a 200 for url 'http://ichart.finance.yahoo.com/table.csv?s=C001.F&a=0&b=1&c=2014&d=11&e=1&f=2017&g=d&ignore=.csv'

Up to now, I could not find a fix for this issue or a suitable work-around. Do you guys have any suggestions?


Solution

  • It seems 'yahoo'is no longer supported. Try "morningstar" or "google".

    The simple yahoo financial link,that worked for years, is no longer supported.

    I've heard of a work around that involves browser spoofing (wget from command line) requires browser aliasing to obtain time sensitive cookies that are then required for each request -- but I've never tried it myself since "morningstar" currently still works (but I miss yahoo's adjusted close).

    #(Pascal 3.6)
    import pandas as pd
    import pandas_datareader.data as web
    ...
    df = web.DataReader('MSFT','morningstar')
    
    for idx, row in df.iterrows():
        print(idx[1],row[0],row[1],row[2],row[3],row[4])