Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to fetch Google finance data #394

Closed
nasirali1 opened this issue Sep 15, 2017 · 13 comments
Closed

Unable to fetch Google finance data #394

nasirali1 opened this issue Sep 15, 2017 · 13 comments

Comments

@nasirali1
Copy link

Google has changed their URL from "http://www.google.com/finance/info" to "https://finance.google.com/finance"

@rsvp
Copy link

rsvp commented Sep 16, 2017

OK, please tell us if and where this breaks the API.

What are the error messages with respect to pandas-datareader?

@nasirali1
Copy link
Author

nasirali1 commented Sep 16, 2017

Hi rsvp,
Thanks for a prompt reply. Please find below the python code and error trace:

CODE:
def finance_date():
"""
Stock indicies for
.INX = S&P 500
.DJI = Dow Jones
.IXIC = NASDAQ
"""
nds = web.get_quote_google(['.IXIC', '.DJI', '.INX'])

ERROR TRACE:
Traceback (most recent call last):
File "/home/ali/IdeaProjects/Environmental-Data-Collection/core/finance/nds_stock.py", line 55, in
finance_date()
File "/home/ali/IdeaProjects/Environmental-Data-Collection/core/finance/nds_stock.py", line 40, in finance_date
nds = web.get_quote_google(['.IXIC', '.DJI', '.INX'])
File "/home/ali/IdeaProjects/Environmental-Data-Collection/venv/lib/python3.5/site-packages/pandas_datareader/data.py", line 56, in get_quote_google
return GoogleQuotesReader(*args, **kwargs).read()
File "/home/ali/IdeaProjects/Environmental-Data-Collection/venv/lib/python3.5/site-packages/pandas_datareader/base.py", line 72, in read
return self._read_one_data(self.url, self.params)
File "/home/ali/IdeaProjects/Environmental-Data-Collection/venv/lib/python3.5/site-packages/pandas_datareader/base.py", line 79, in _read_one_data
out = self._read_url_as_StringIO(url, params=params)
File "/home/ali/IdeaProjects/Environmental-Data-Collection/venv/lib/python3.5/site-packages/pandas_datareader/base.py", line 90, in _read_url_as_StringIO
response = self._get_response(url, params=params)
File "/home/ali/IdeaProjects/Environmental-Data-Collection/venv/lib/python3.5/site-packages/pandas_datareader/base.py", line 139, in _get_response
raise RemoteDataError('Unable to read URL: {0}'.format(url))
pandas_datareader._utils.RemoteDataError: Unable to read URL: http://www.google.com/finance/info?q=.IXIC%2C.DJI%2C.INX

@paintdog
Copy link

Maybe it makes sense to contact Google to ask for a correction, but I do not think that the issue affects only a few.

@nasirali1
Copy link
Author

paindog, Google has changed/restructured their finance urls. It's not a mistake that we can ask Google to fix.

@paintdog
Copy link

They reduced the available data to the period of about one year. That's a problem they could fix...

@nasirali1
Copy link
Author

paintdog, I think, this is a simple URL update in pandas-datareader API. Current URL used in api is "http://www.google.com/finance/info". This URL should be updated to new Google finance URL: "https://finance.google.com/finance".

API code snippet (data.py)
class GoogleQuotesReader(_BaseReader):

"""Get current google quote"""

@property
def url(self):
    return 'http://www.google.com/finance/info'

@minimalgeek
Copy link

Temporary and very ugly solution for testing purposes:

from pandas_datareader.google.daily import GoogleDailyReader

@property
def url(self):
    return 'http://finance.google.com/finance/historical'

GoogleDailyReader.url = url

# get data

import pandas_datareader as pdr
from datetime import datetime

start = datetime(2010,1,1)
end = datetime(2014,1,1)
ret = pdr.get_data_google(['AAPL'], start, end)

@sof
Copy link

sof commented Sep 19, 2017

Changing the URL works, but the 302 redirect that www.google.com/finance/historical returns will currently strip the startdate= and enddate= params, which is why people are seeing only the past year's data being returned.

Unintentional bug in the www.google.com redirect rule at play?

soon added a commit to soon/pandas-datareader that referenced this issue Sep 21, 2017
@TyrelCB
Copy link

TyrelCB commented Sep 26, 2017

the commit added by soon fixed the historical collection, however the delayed quote is still not functional, I've tried http://finance.google.com/finance with no success

@rsvp
Copy link

rsvp commented Sep 27, 2017

@TyrelCB The latest PR by @soon has failed Travis build: #402

@rsvp
Copy link

rsvp commented Sep 27, 2017

Google Finance under renovation, portfolios to be deprecated mid-November 2017 : rsvp/fecon235#7 (comment)

@coulanuk
Copy link

coulanuk commented Dec 6, 2017

This fix may be a waste of effort. It looks like there are big holes in the underlying datasets on Google Finance, eg Bank of America (BAC) or JP Morgan (JPM) have nothing or garbage prices (as of the date I am posting).

@davidastephens
Copy link
Member

Fixed in #404.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants