Getting the Google Finance Stock Data
Regardless of the programming language your using you can use YQL since it’s REST based. (did I mention how much I love REST?)Here is a quick example of the YQL call to get Apple and Google stock data. (AAPL and GOOG)
select * from google.igoogle.stock where stock in ('AAPL','GOOG'); |
The Stock Information as a Result
So when you call the Google Finance YQL function (REST API) you get data like so:<? xml version = "1.0" encoding = "UTF-8" ?> yahoo:count = "2" yahoo:created = "2012-03-06T04:16:21Z" yahoo:lang = "en-US" > < diagnostics > < publiclyCallable >true</ publiclyCallable > < url execution-start-time = "20" execution-stop-time = "23" execution-time = "3" proxy = "DEFAULT" > <![CDATA[http://www.datatables.org/google/google.igoogle.stock.xml]]> </ url > < url execution-start-time = "25" execution-stop-time = "112" < url execution-start-time = "25" execution-stop-time = "163" < user-time >164</ user-time > < service-time >228</ service-time > < build-version >25587</ build-version > </ diagnostics > < results > < xml_api_reply version = "1" > < finance mobile_row = "0" mobile_zipped = "1" module_id = "0" row = "0" section = "0" tab_id = "0" > < symbol data = "AAPL" /> < pretty_symbol data = "AAPL" /> < symbol_lookup_url data = "/finance?client=ig&q=AAPL" /> < company data = "Apple Inc." /> < exchange data = "Nasdaq" /> < exchange_timezone data = "ET" /> < exchange_utc_offset data = "+05:00" /> < exchange_closing data = "960" /> < divisor data = "2" /> < currency data = "USD" /> < last data = "533.16" /> < high data = "547.48" /> < low data = "526.00" /> < volume data = "28897169" /> < avg_volume data = "19174" /> < market_cap data = "497102.36" /> < open data = "545.42" /> < y_close data = "545.18" /> < change data = "-12.02" /> < perc_change data = "-2.20" /> < delay data = "0" /> < trade_timestamp data = "7 hours ago" /> < trade_date_utc data = "20120305" /> < trade_time_utc data = "210001" /> < current_date_utc data = "20120306" /> < current_time_utc data = "041621" /> < symbol_url data = "/finance?client=ig&q=AAPL" /> < chart_url data = "/finance/chart?q=NASDAQ:AAPL&tlf=12" /> < disclaimer_url data = "/help/stock_disclaimer.html" /> < ecn_url data = "" /> < isld_last data = "532.20" /> < isld_trade_date_utc data = "20120306" /> < isld_trade_time_utc data = "005926" /> < brut_last data = "" /> < brut_trade_date_utc data = "" /> < brut_trade_time_utc data = "" /> < daylight_savings data = "false" /> </ finance > </ xml_api_reply > < xml_api_reply version = "1" > < finance mobile_row = "0" mobile_zipped = "1" module_id = "0" row = "0" section = "0" tab_id = "0" > < symbol data = "GOOG" /> < pretty_symbol data = "GOOG" /> < symbol_lookup_url data = "/finance?client=ig&q=GOOG" /> < company data = "Google Inc" /> < exchange data = "Nasdaq" /> < exchange_timezone data = "ET" /> < exchange_utc_offset data = "+05:00" /> < exchange_closing data = "960" /> < divisor data = "2" /> < currency data = "USD" /> < last data = "614.25" /> < high data = "622.49" /> < low data = "611.38" /> < volume data = "1593250" /> < avg_volume data = "2817" /> < market_cap data = "199714.99" /> < open data = "620.43" /> < y_close data = "621.25" /> < change data = "-7.00" /> < perc_change data = "-1.13" /> < delay data = "0" /> < trade_timestamp data = "7 hours ago" /> < trade_date_utc data = "20120305" /> < trade_time_utc data = "210005" /> < current_date_utc data = "20120306" /> < current_time_utc data = "041621" /> < symbol_url data = "/finance?client=ig&q=GOOG" /> < chart_url data = "/finance/chart?q=NASDAQ:GOOG&tlf=12" /> < disclaimer_url data = "/help/stock_disclaimer.html" /> < ecn_url data = "" /> < isld_last data = "" /> < isld_trade_date_utc data = "" /> < isld_trade_time_utc data = "" /> < brut_last data = "" /> < brut_trade_date_utc data = "" /> < brut_trade_time_utc data = "" /> < daylight_savings data = "false" /> </ finance > </ xml_api_reply > </ results > </ query > |
If you want more info on how to parse the Google Finance API data in C# take a look at the Yahoo Finance version I’ve posted Reading the Yahoo Finance API in C#
No comments:
Post a Comment