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

An YQL that returns no results causes a YQLResponseMalformedError even with a valid response #90

Open
gvenkatas opened this issue Nov 22, 2016 · 21 comments

Comments

@gvenkatas
Copy link

gvenkatas commented Nov 22, 2016

Query:
select * from yahoo.finance.historicaldata where symbol = "BNDX" and startDate="2012-06-03" and endDate="2013-06-03"

Response:
{'query': {'count': 0, 'lang': 'en-US', 'results': None, 'created': '2016-11-22T01:30:18Z'}}

It looks like this change caused it:
db06364

Removing the AttributeError in the except clause makes this issue go away but is obviously not the right fix since that commit actually added AttributeError to the except clause

@IvanThinking
Copy link

I am experiencing this issue as well... any plan to fix?

@TarangKhanna
Copy link

Same, when the start and end dates are close for the historical data method I get:
raise YQLResponseMalformedError()
yahoo_finance.YQLResponseMalformedError: Response malformed.
Problem starts from a gap of 3 days.

@nlejeune
Copy link

Same issue here...

@vl3
Copy link

vl3 commented May 17, 2017

Same issue here. I've tried several gaps and i'm always getting YQLResponseMalformedError

@a-heintz
Copy link

I have the same issue. It worked about a week ago, but it no longer works now.

@vl3
Copy link

vl3 commented May 17, 2017

I think that the issue is yahoo API not the client.

@yatresh
Copy link

yatresh commented May 18, 2017

I am also facing the issue when i ran the command , Request Help.
pprint(yahoo.get_historical('2017-05-11', '2017-05-12'))

Error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/yahoo_finance/init.py", line 120, in _request
_, results = response['query']['results'].popitem()
AttributeError: 'NoneType' object has no attribute 'popitem'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/yahoo_finance/init.py", line 123, in _request
raise YQLQueryError(response['error']['description'])
KeyError: 'error'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/yagrawal/Python/Historical_data.py", line 13, in
pprint(yahoo.get_historical('2017-05-11', '2017-05-12'))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/yahoo_finance/init.py", line 342, in get_historical
result = self._request(query)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/yahoo_finance/init.py", line 125, in _request
raise YQLResponseMalformedError()
yahoo_finance.YQLResponseMalformedError: Response malformed.

Process finished with exit code 1

@joeyjoeyjoeey
Copy link

joeyjoeyjoeey commented May 18, 2017

I am getting this issue when querying for historical data. All of the other methods which return current data seem to be working (get_price, get_change, get_book_value...).

Also using the python pandas DataReader method isn't working either.

For me these issues started 5/16/2017.

@iakovace
Copy link

Same problem here, getting YQLResponseMalformedError(). Tried multiple combinations of dates and stocks. Is it something from yahoo that should be fixed in the following days?

@KentChun33333
Copy link

+1, same problem :
According to following blog
It seems ..... '

@ilovefood2
Copy link

same problem here

@sameeksha16gupta
Copy link

When will this be fixed?

@kylestahl
Copy link

Same problem

@Yevgnen
Copy link

Yevgnen commented Jul 7, 2017

Any news?

@diyuexiao
Copy link

Same issue here. Hope it can be fixed.

@DennyWeinberg
Copy link

+1

@knair99
Copy link

knair99 commented Oct 29, 2017

Here's a workaround (grab the data directly from the history pages):

import urllib2
from BeautifulSoup import BeautifulSoup as bs

def get_historical_data(name, number_of_days):
	data = []
	url = "https://finance.yahoo.com/quote/" + name + "/history/"
	rows = bs(urllib2.urlopen(url).read()).findAll('table')[0].tbody.findAll('tr')

	for each_row in rows:
		divs = each_row.findAll('td')
		if divs[1].span.text  != 'Dividend': #Ignore this row in the table
			#I'm only interested in 'Open' price; For other values, play with divs[1 - 5]
			data.append({'Date': divs[0].span.text, 'Open': float(divs[1].span.text.replace(',',''))})

	return data[:number_of_days]

#Test
print get_historical_data('amzn', 15)

@libnine
Copy link

libnine commented Nov 2, 2017

Having an issue as well:

`Traceback (most recent call last):
File "newsletter.py", line 54, in
crude = Share('CL=F')
File "/home/qorka/.local/lib/python2.7/site-packages/yahoo_finance/init.py", line 178, in init
self.refresh()
File "/home/qorka/.local/lib/python2.7/site-packages/yahoo_finance/init.py", line 142, in refresh
self.data_set = self._fetch()
File "/home/qorka/.local/lib/python2.7/site-packages/yahoo_finance/init.py", line 181, in _fetch
data = super(Share, self)._fetch()
File "/home/qorka/.local/lib/python2.7/site-packages/yahoo_finance/init.py", line 134, in _fetch
data = self._request(query)
File "/home/qorka/.local/lib/python2.7/site-packages/yahoo_finance/init.py", line 125, in _request
raise YQLResponseMalformedError()
yahoo_finance.YQLResponseMalformedError: Response malformed.

`

@3rico
Copy link

3rico commented Nov 2, 2017

Same with me i have just started experiencing this today :-( what is happening?

@wtkao
Copy link

wtkao commented Nov 8, 2017

2017/11/8 The following code works! (for Python3)

import urllib
from bs4 import BeautifulSoup as bs

def get_historical_data(name, number_of_days):
data = []
url = "https://finance.yahoo.com/quote/" + name + "/history/"
rows = bs(urllib.request.urlopen(url).read()).findAll('table')[0].tbody.findAll('tr')

for each_row in rows:
    divs = each_row.findAll('td')
    if divs[1].span.text  != 'Dividend': #Ignore this row in the table
        #I'm only interested in 'Open' price; For other values, play with divs[1 - 5]
        data.append({'Date': divs[0].span.text, 'Open': float(divs[1].span.text.replace(',',''))})

return data[:number_of_days]

#Test
for i in get_historical_data('AAPL', 5):
print (i)

@knair99
Copy link

knair99 commented Nov 8, 2017

@wtkao Good to know it still works; I wrote that months ago and they change the HTML sometimes. As a caution, you might want to use urllib2 instead.

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

No branches or pull requests