Im using jQuery and highcharts.js to build a single line chart on my webpage that shows historical financial data for whatever company the user requests. I have been playing around with YQL and used this statement to retrieve some quotes in JSON format:
select * from yahoo.finance.historicaldata where symbol = "AAPL" and startDate = "2013-02-01" and endDate = "2013-02-25"
Heres a link to the YQL console with my query:
http://developer.yahoo.com/yql/console/?q=show%20tables&env=store://datatables.org/alltableswithkeys#h=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22AAPL%22%20and%20startDate%20%3D%20%222013-02-01%22%20and%20endDate%20%3D%20%222013-02-25%22
It returns a bunch of info about execution-start-time and exection-end-time and then at the end it gives me the quotes im after:
"results": {
"quote": [
{
"date": "2013-02-25",
"Date": "2013-02-25",
"Open": "453.85",
"High": "455.12",
"Low": "442.57",
"Close": "442.80",
"Volume": "13306400",
"Adj_Close": "442.80"
},
Im having trouble extracting the Close price information from the results, ive tried the following code but im having trouble.
$.getJSON('http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22AAPL%22%20and%20startDate%20%3D%20%222013-02-01%22%20and%20endDate%20%3D%20%222013-02-25%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=cbfunc', function(data){
console.log(data);
var close = data.query.results.quote.close;
document.write(close);
})
Can somebody tell me where im going wrong as I am new to jquery, yql and json.
Thanks