stock-app

Simple Stock Lookup app

I wanted to have some fun with JSON and jQuery, so I decided to create this simple Stock Lookup app. It uses the Yahoo Query Language to retrive an JSON object.

Have a look at the stock app and let me know what you think.

The HTML used is:

<form action="aktieapp.html" method="post">
		<label>Stock</label><input type="text" id="stockcode" placeholder="Type your stock code"><input type="submit" value="Lookup stock info">
	</form>
	<div class="footer">
<p>All information is received from <a href="http://finance.yahoo.com/">finance.yahoo.com</a>, with a 15 minute delay. Non US stocks need to have an indentifier added like '.CO' for Copenhagen, as in 'VWS.CO' for Vestas Wind Systems.</p>
	<p>Developed by <a href="http://www.muhammadhussain.net">Muhammad Hussain</a></p>
	</div>

The code for the jQuery is:

$('form').submit(function(event){

var stock = $('#stockcode').val();
var link = "http://chart.finance.yahoo.com/z?s="+stock+"&z=l";

//Connect to JSON feed
$.getJSON('http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.
finance.quotes%20where%20symbol%20in%20%28%22'+stock+'%22%29&env=
store://datatables.org/alltableswithkeys&format=json', function(data){

var Value = data.query.results.quote;
var Ask = Value.AskRealtime;
var Name = Value.Name;
var PercentChange = Value.ChangeinPercent;
var Exchange = Value.StockExchange;

$('<p></p>', {
 html: '<b>'+Name+':</b> <a href='+link+' target="_blank">Chart</a> | <b>Price:</b>
 '+Ask+'('+PercentChange+')| <b>Stock Exchange:</b>'+Exchange,
 class: 'my class'
 }).appendTo('form');

})

$('#stockcode').val('');

 event.preventDefault();

});