Current query code:
<script language="JavaScript">
var stocklist = getstocks();
( function($) {
$(document).ready(function(){
$.getJSON('https://finance.google.com/finance/info?client=ig&q='+stocklist[0]+'&callback=?',function(response){
for (var i = 0; i < response.length; i++) {
var stockInfo = response[i];
if (stockInfo.c.indexOf("-") != -1) {var scolor = "red";} else {var scolor = "green";}
var finvizt = stockInfo.t.replace('\.','\-');
var stockString ='<div style="width:210px;position:relative;" class="stockWrapper">';
stockString +='<span class="stockPrice" style="margin-left:-10px"><a class="slink" name="slink'+stockInfo.t+'" href="http://finviz.com/quote.ashx?t='+finvizt+'" onMouseOver="img_create(\''+escape(stockInfo.t)+'\');slink=getElementById(\'slink'+stockInfo.t+'\');thelink=this;var arx=getPos(thelink); var posx=arx[0]+90;var posy=arx[1]-75;var x=document.getElementById(\'stock'+stockInfo.t+'\');x.style.position=\'absolute\';x.style.display=\'block\';x.style.left=posx+\'px\';x.style.top=posy+\'px\';" onMouseOut="document.getElementById(\'stock'+stockInfo.t+'\').style.display=\'none\';" target="external">'+stockInfo.t+'</a></span>';
stockString +='<span class="stockPrice" style="position:absolute;right:120px" title="'+stockInfo.ltt+'">'+stockInfo.l+' </span>';
stockString +='<span class="stockChange" style="color:'+scolor+';position:absolute;right:75px">'+stockInfo.c+'</span>';
stockString +='<span class="stockChange" style="color:'+scolor+';position:absolute;right:25px">'+stockInfo.cp+'%</span>';
stockString +='</div>';
$('.stockTick').prepend(stockString);
}
});
});
} ) ( jQuery );
</script>
Part of that uses Finviz charts on mouseover which is cool (yes tooting my own horn).
So I have searched for answers on historical data, etc, not sure how to incorporate it into the above though. Basically I need an answer on how to convert to and from unix time, formatting in a way that google will understand, subtract one price from another (a week ago and that day), if possible move date backwards when it would land on a weekend day, perform the math to get a % change, and figure out whether it's positive or negative.
I'm overwhelmed really. I can eventually figure out the end result arithmetic process in javascript (though I'm slow so it will take me a long time), what I can't seem to find is how to get the proper price of a stock a week ago.
Any help is appreciated.