Python 2.7 Yahoo Finance No Definition Found
<p>Hope you are well. I'm Using Python 2.7 and new at it. I'm trying to use yahoo finance API to get information from stocks, here is my code:</p>

<pre><code>from yahoo_finance import Share
yahoo = Share('YHOO')
print yahoo.get_historical('2014-04-25', '2014-04-29') 
</code></pre>

<p>This code thoug works once out of 4 attempts, the other 3 times gives me this errors:</p>

<pre><code>YQL Query error: Query failed with error: No Definition found for Table yahoo.finance.quote 
</code></pre>

<p>Is there anyway to fix this error so to have the code working 100% of the time?
Thanks.
Warmest regards </p>

<p>This is a <em>server-side error</em>. The <code>query.yahooapis.com</code> service appears to be handled by a cluster of machines, and some of those machines appear to be misconfigured. This could be a temporary problem.</p>

<p>I see the same error when accessing the API directly using curl:</p>

<pre><code>$ curl "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quote%20where%20symbol%20%3D%20%22YHOO%22&amp;format=json&amp;env=store%3a//datatables.org/alltableswithkeys"
{"error":{"lang":"en-US","description":"No definition found for Table yahoo.finance.quote"}}
</code></pre>

<p>Other than retrying in a loop, there is no way to fix this on the Python side:</p>

<pre><code>data = None
for i in range(10):  # retry 10 times
    try:
        yahoo = Share('YHOO')
        data = yahoo.get_historical('2014-04-25', '2014-04-29')
        break
    except yahoo_finance.YQLQueryError:
        continue
if data is None:
    print 'Failed to retrieve data from the Yahoo service, try again later'
</code></pre>

python yql yahoo-api yahoo-finance