-
Notifications
You must be signed in to change notification settings - Fork 11
Description
I did a small modifications on the code to allow saving the history of multiple funds.
The example code works only for one fund.
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s1 = ss.getSheetByName(sheet1);
var s2 = ss.getSheetByName(sheet2);
var lastDate = s2.getRange(s2.getLastRow(), 1).getValue();
funds.forEach(function(fund) {
var date = s1.getRange(fund.dateCell).getValue();
var parsedDate = new Date(Date.parse(date));
// var lastDate = s2.getRange(s2.getLastRow(), 1).getValue();
// Avoid inserting a NAV if we already have it
if(!(lastDate instanceof Date) || lastDate.getTime() !== parsedDate.getTime()) {
var nav = s1.getRange(fund.navCell).getValue();
s2.appendRow([ parsedDate, fund.isin, nav ]);
}
});
I set a time driven trigger.
I don't know why but for many NAV i get #error, while if I run the script manually opening the sheet on my PC is works.
Any idea?