An in-depth examination of Yahoo! Financial Web Services
I am using these services for three years now, and I have to admit that it is one of the best tool for anyone working on stock quotations (all over the world) and... it's free (massive argument for testing) !! There are so many data sources (Telekurs, Comstock...), that it's best to have a look and try to see wich company provides it.
All datas are available on web page (see http://finance.yahoo.com/q?s=GE for a summary of financial information on stock code GE : General electric for example), some datas are available as Excel spreadsheet download, and, finally, some datas are available as "Web Services". Well, it's more a proprietary service on internet than a Web Services (no web service description file...).
I will go into details about 3 services : quotation service, index components service and historical data service.
Quotation Web Service
As you can see on http://finance.yahoo.com/q?s=GE page, there is a small "Download data" link. This link will download a CSV file using the hyperlink http://finance.yahoo.com/d/quotes.csv?s=GE&f=sl1d1t1c1ohgv&e=.csv .
The data received look like the following :
GE,34.74,"6/27/2005","1:25pm",-0.04,34.72,34.86,34.60,14050200
Let's try to understand how it works :
Obviously the GE parameter in the URL (s=GE) is related to the stock code, in fact on New Yorck Stock Exchange, General electric stocks are symbolized by GE code. You will notice that the quotation place is not showed. You can write comma separated stock quotes to retrieve several quotations at the same time. For example : http://finance.yahoo.com/d/quotes.csv?s=GE,MSFT&f=sl1d1t1c1ohgv&e=.csv .
Once the stock code is references, the f parameter is a long string composed of letters and figures. Strangely, I found no web site describing precisely these parameters. I found their meaning empirically :
a Ask a2 Average Daily Volume a5 Ask Size b Bid b2 Ask (Real-time) b3 Bid (Real-time) b4 Book Value b6 Bid Size c Change & Percent Change c1 Quotation Net Change c3 Commission c6 Change (Real-time) c8 After Hours Change (Real-time) d Dividend/Share d1 Last Trade Date d2 Trade Date e Earnings/Share e1 Error Indication (returned for symbol changed / invalid) e7 EPS Estimate Current Year e8 EPS Estimate Next Year e9 EPS Estimate Next Quarter f6 Float Shares g Day's Low h Day's High j 52-week Low k 52-week High g1 Holdings Gain Percent g3 Annualized Gain g4 Holdings Gain g5 Holdings Gain Percent (Real-time) g6 Holdings Gain (Real-time) i More Info i5 Order Book (Real-time) j1 Market Capitalization j3 Market Cap (Real-time) j4 EBITDA j5 Change From 52-week Low j6 Percent Change From 52-week Low k1 Last Trade (Real-time) With Time k2 Change Percent (Real-time) k3 Last Trade Size k4 Change From 52-week High k5 Percent Change From 52-week High l Last Trade (With Time) l1 Last Trade (Price Only) l2 High Limit l3 Low Limit m Day's Range m2 Day's Range (Real-time) m3 50-day Moving Average m4 200-day Moving Average m5 Change From 200-day Moving Average m6 Percent Change From 200-day Moving Average m7 Change From 50-day Moving Average m8 Percent Change From 50-day Moving Average n Name n4 Notes o Open p Previous Close p1 Price Paid p2 Change in Percent p5 Price/Sales p6 Price/Book q Ex-Dividend Date r P/E Ratio r1 Dividend Pay Date r2 P/E Ratio (Real-time) r5 PEG Ratio r6 Price/EPS Estimate Current Year r7 Price/EPS Estimate Next Year s Symbol s1 Shares Owned s7 Short Ratio t1 Last Trade Time t6 Trade Links t7 Ticker Trend t8 1 yr Target Price v Volume v1 Holdings Value v7 Holdings Value (Real-time) w 52-week Range w1 Day's Value Change w4 Day's Value Change (Real-time) x Stock Exchange y Dividend Yield
The only web site giving this information (as far as I searched it) is http://www.gummy-stuff.org/Yahoo-data.htm.
It e querystring parameter (e for extension?) looks like being optional (e=.csv).
We will see later in this article how to retrieve quotation data from a VB.Net Application (ASP.Net or Windows Application). As said before, you can't declare the quotation place when you call the web service. In fact, the stock code contains this information. For General electric (GE), this is not obvious, but if you take a stock on the french market, L'Oreal for example, its code will be OR.PA where PA means Paris. Some companies can be quoted on several stock exchange, and each quotation is different. For example, let's take Microsoft shares : on XETRA Stock Exchange (Germany), its code is MSF.DE, the quotation is in Euro, and on NASDAQ, the code is MSFT ans the quotation in Dollars. Of course, to make things more difficult, codes are not standardized ! So you should pay the highest attention in choosing the Stock Symbol to use in the quotation web service. Unfortunately, Yahoo doesn't provide any web service for symbol lookup.
Indices components Web Service
This is probably the simplest web service provided, but it can be very helpful. It's goal is to provide a list of all stocks composing an indice : Dow Jones Industrial, Nasdaq 100, CAC40... These indices quotations are calculated as an average of its components quotation. This web service maintains the list of components (a huge work in itself) and their quotation.
Its call is very similar to the regular quotation service, as if you were adding all stock symbols in the querystring. This is web page of the service : http://finance.yahoo.com/q/cp?s=%5ENDX for Nasdaq 100 components which symbol is ^NDX. To download the information, we call http://finance.yahoo.com/d/quotes.csv?s=@%5ENDX&f=sl1d1t1c1ohgv&e=.csv where we recognize the parameters of the quotation web service. The result is a csv stream that can be considered as a web service and looks like :
AAPL,37.31,"6/28/2005","4:00pm",+0.21,37.49,37.59,37.17,12555196
ADBE,28.70,"6/28/2005","4:00pm",-0.14,29.05,29.05,28.25,7916337
ADSK,34.81,"6/28/2005","4:00pm",+0.86,34.00,34.92,33.49,2695397
ALTR,19.52,"6/28/2005","4:00pm",-0.19,20.00,20.00,19.41,9181970
AMAT,16.31,"6/28/2005","4:00pm",+0.08,16.36,16.42,16.24,16429051
However, this web service has a strange behavior depending on the URL called. For American indices, you have to deal with pagination : you can only get 50 stocks in your file. So, to download all data for Nasdaq 100, you have to call the service 6twice (there are 100 stocks composing the indice !). This is highly inefficient but understandable as a provider point of view. But what strikes me, is that it is not the same policy on other countries stock markets ! Considering French Yahoo, if you download the information from http://fr.old.finance.yahoo.com/d/quotes.csv?s=@^NDX&f=snl1d1t1c1ohgv&e=.csv , you will get the whole information with a single call !!!
Historical data Web Service
A list of historical quotations (and dividend payment) is available through a web service. This web service takes as parameters 2 dates , a stock symbol and a frequency (daily, weekly, monthlyor dividend only). In the case of weekly and monthly frequency, an average on each period is done.
At this URl , http://finance.yahoo.com/q/hp?s=GE&a=00&b=1&c=2004&d=05&e=28&f=2005&g=d, a list of daily quotations for General Electric is given from january 1st 2004 to june 28th 2005. The parameters are almost strightforward :
a : first date month (0-based array : january =0, february = 1,... december =11)
b : first date day
c : fist date year
d : last date month (0-based array : january =0, february = 1,... december =11)
e : last date day
f : last date year
g : frequency (d = daily, w = weekly, m = monthly, v = dividends only)
The URL to call as a web service is http://ichart.finance.yahoo.com/table.csv?s=GE&a=00&b=1&c=2004&d=05&e=28&f=2005&g=d&ignore=.csv
No pagination problem here, the result is a table with the first row describing the columns :
Date,Open,High,Low,Close,Volume,Adj. Close*
27-Jun-05,34.72,34.86,34.59,34.61,23402900,34.61
24-Jun-05,34.75,35.98,34.15,34.78,67540496,34.78
23-Jun-05,35.50,35.63,34.52,34.66,48926900,34.66
22-Jun-05,36.20,36.34,35.68,35.72,29200400,35.50
Brightly, Yahoo guys provides us with the Adjusted Close which takes into consideration dividends payment and stock splits.