-1

I've been looking around for a stable function to fetch stock data in my program. Yahoo_finance is broken completely now, even the current day data retrievers return a None type. Previously I've had success with a stock downloader written by Andrew Galeazzi, but just a couple days ago the downloader stopped working, and now I am met with:

Traceback (most recent call last):
  File "C:/Users/somename/PycharmProjects/StockGUI/test1.py", line 57, in module>
    print (get_crumble_and_cookie('KO'))
  File "C:/Users/somename/PycharmProjects/StockGUI/test1.py", line 26, in get_crumble_and_cookie
    cookie_str = match.group(1)
AttributeError: 'NoneType' object has no attribute 'group'

Are there any historical stock data retrievers out there that are currently working?

user8435778
  • 1
  • 1
  • 1
  • Have you tried [`googlefinance`](https://pypi.python.org/pypi/googlefinance)? Or are you strictly looking to fetch from Yahoo!? – Mangohero1 Aug 08 '17 at 18:15
  • [This](https://www.alphavantage.co) has api to fetch historical data – fen1x Aug 08 '17 at 18:22

1 Answers1

0

You can use the pandas-datareader package. Example code below.

import datetime as dt
from pandas_datareader import data, wb

start_date = dt.datetime(1980, 1, 1)
dat = data.DataReader('googl', 'yahoo', start_date, dt.datetime.today())
dat.to_csv('googl.csv', mode='w', header=True)

I used pandas-datareader==0.5.0 and Python 3.6.2. Incidentally, pandas-datareader docs seem to indicate that Yahoo recently changed the API. Also, pandas-datareader has options for pulling dividend/split data as well.

tdube
  • 2,453
  • 2
  • 16
  • 25