Yahoo finance API missing data for certain days
<p>I'm coding a script that fetches information from the Yahoo finance API and even though the API is pretty slow it works for what I'm going to use it for. During testing of the script I found out that I got an IndexOutOfBounds exception and up on investigation I see that Yahoo Finance is returning stock quote information for the stocks I have except that its missing one day for one of the stocks, and I suspect that when using a wider time period it will miss more days as I have got that exception before when using a wider time period, but I thought it was something in my code that I could just fix later.</p>

<p>That the Yahoo finance API is missing entire days of stock quote information makes the API useless for me. Has anyone else experienced this, and is there any solution to it ? I'm guessing I would need to use another way to get the data.</p>

<p>Right now I'm using this python module <a href="https://pypi.python.org/pypi/yahoo-finance" rel="nofollow">https://pypi.python.org/pypi/yahoo-finance</a>.</p>

<p>Yahoo finance is the only API I've currently found that contains the information I need and support the stock exchange I need to query data for. </p>

<p>Update:
Yes, I can re-produce the problem. Below is the code to re-produce:</p>

<pre><code>&gt;&gt;&gt; import datetime as dt
&gt;&gt;&gt; import yahoo_finance as yf
&gt;&gt;&gt;
&gt;&gt;&gt; quote = yf.Share('GJF.OL')
&gt;&gt;&gt; date_from = str(dt.date.today() - dt.timedelta(days=5))
&gt;&gt;&gt; date_to = str(dt.date.today())
&gt;&gt;&gt; quote_his = quote.get_historical(date_from, date_to)
&gt;&gt;&gt; import pprint
&gt;&gt;&gt; pprint.pprint(quote_his)
[{'Adj_Close': '156.50',
  'Close': '156.50',
  'Date': '2016-10-14',
  'High': '156.50',
  'Low': '153.10',
  'Open': '153.50',
  'Symbol': 'GJF.OL',
  'Volume': '487600'},
 {'Adj_Close': '153.60',
  'Close': '153.60',
  'Date': '2016-10-13',
  'High': '153.60',
  'Low': '152.50',
  'Open': '153.30',
  'Symbol': 'GJF.OL',
  'Volume': '508800'}]
&gt;&gt;&gt;
</code></pre>

<p>This code should print out the stock information for Monday (2016-10-17), but it does not. If I choose another stock I get the stock information for Monday in the dictionary as well.</p>

<p>Update 2:
I tried another module named ystockquote and got the same result. I get information for thursday and friday, but not monday. If i ask for a different quote i get info from all three days. When i got to the yahoo finance site it has the stock information from monday in graphs etc.</p>

<p>Update 3:
The data is now found for the GJF.OL which probably would have been related to a delay in the stock prices for the historical tables in the API as pointed out below in an answer. However, I was still able to receive stock price information from other stocks for the dates I did not receive stock price information from for the GJF.OL stock.</p>

<p>While I'm now receiving stock price information for the GJF.OL stock I tried to get the last 165 days of stock price information from the stocks, but there is 1 day missing from the NAS.OL stock meaning the dictionary returned does not contain any data for that day while the other stocks have that information. The stock is NAS.OL and the date is 3rd of August 2016 where the data is missing. Any ideas why this data is missing ?</p>

<p>This probably has nothing to do with the Python bindings, and it's entirely Yahoo data. If you read through the bindings, the command that runs is essentially</p>

<pre><code>curl -G 'https://query.yahooapis.com/v1/public/yql' \
    --data-urlencode 'env=store://datatables.org/alltableswithkeys' \
    --data-urlencode 'format=json' \
    --data-urlencode 'q=select * from yahoo.finance.historicaldata where symbol = "GJF.OL" and startDate = "2016-10-13" and endDate = "2016-10-18"'
</code></pre>

<p>When I rant it for myself, I got data for 13th, 14th, 17th, and 18th. The table you're accessing is called <em>historical</em> data, so it's not unreasonable for there to be a 24-hour for the data to show up.</p>

<p>If you see a discrepancy between that endpoint and the Python bindings, you might be onto something, but the <a href="https://github.com/lukaszbanasiak/yahoo-finance/blob/master/yahoo_finance/__init__.py" rel="nofollow">code</a> for those bindings is pretty straightforward, and it seems to just pass the date range along.</p>

python api yahoo-finance