Click to See Complete Forum and Search --> : Retrieving Yahoo finance data


rynato
09-24-2009, 11:04 AM
OK I developed a widget to track the DJIA (^DJI). It uses Yahoo Finance's free data.

I have one script which is run by a crontab, it grabs the DJIA quotes every 20 minutes while markets are open. This script runs fine. It retrieves the .csv file, parses it, and stores the relevant data in a mySQL database table.

A second script gets the final data for the day by using the same URL:

http://finance.yahoo.com/d/quotes.csv?s=^DJI&f=l1d1t1oghv

and running it sometime after market close in New York and before market open on the next trading day. The purpose for this is that the widget shows the change in quote between the (near-)current quote and yesterday's closing quote by comparing the most-recent quote to the close of the last trading day. Eventually we'd like to also implement the option of viewing a graph of historical data.

Anyway, the above URL does not return accurate data after end-of-day for the high, low and volume. They are always off. High and low are off by roughly 20 to 40 points, while volume is always WAY off. The open and close are correct, which is good... but the other three data are not correct if you compare it to the historical data for that day.

I have tried running this script at 9am ET on the day following the trading day (about as late as you can poll current data and still get yesterday's data). It is the same as if the script were run an hour after market close.

I tried getting the historical data instead:

http://ichart.finance.yahoo.com/table.csv?s=^DJI&a=[start month]&b=[start date]&c=[start year]&d=[end month]&e=[end date]&f=[end year]&g=d&ignore=.csv

I discovered that one cannot retrieve historical data in this way, for any date more recent than one month back - it returns an empty document or no document at all. You can look up the information 'manually' in the browser, but it seems it won't let you directly access that data with a script.

Has anyone out there been working with Yahoo Finance data and found a workaround for this? Or perhaps I'm doing something wrong?

Thanks in advance.