When I try to get the historical quotes using the following block of code, the stockInfo array is coming back empty. Based on the criteria specified in the FinanceApp.getHistoricalStockInfo function call, I should get the prices for GOOG stock for the trading day 11/30/2012.
function TestMethod()
{
var ss = SpreadsheetApp.getActiveSheet();
var date = new Date(2012, 11, 30);
var retValue = FinanceApp.getHistoricalStockInfo("GOOG", date, date, 1);
var ret = retValue.stockInfo[0];
Logger.log(ret); /* This comes back as 'undefined' */
Logger.log(retValue.close); /* This comes back as 'undefined' */
if (retValue != undefined && retValue.stockInfo[0] != undefined)
Logger.log(retValue);
}
This method used to work properly until about 10 days ago. I have tried posting this to the google groups forums also but no one has responded yet.
When you put the interval of 1 day, then you will have to have difference of at lease one day between start and end date. e.g
function TestMethod(){
var ss = SpreadsheetApp.getActiveSheet();
var startDate = new Date(2012, 10, 30);
var endDate = new Date(2012, 11, 1);
var retValue = FinanceApp.getHistoricalStockInfo('GOOG', startDate, endDate, 1);
var ret = retValue.stockInfo[0];
Logger.log(ret);
Logger.log(retValue);
}