I wrote a script with Apps Script for my Google Sheet, in order to have a record of stock prices at a given time. The script is executed every hour by a time-driven trigger.
function logStockPrices() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var writeSheet = ss.getSheetByName('Stock History');
var timestamp = Utilities.formatDate(new Date(), "GMT+1", "dd.MM.yyyy hh:mm:ss");
writeSheet.appendRow([timestamp, '=googlefinance("NASDAQ:AAPL")', '=googlefinance("NYSE:SPCE")', '=googlefinance("FRA:D7G")', '=googlefinance("FRA:11L1")', '=googlefinance("FRA:LHA")', '=googlefinance("FRA:AIR")', '=googlefinance("FRA:10E")']);
}
But the price which is logged is always the same, even tho the price is changing. The timestamp however is correct.
This is the link to the spreadsheet: https://docs.google.com/spreadsheets/d/11empPIZzVOc1tc7toTU6YVbeygVfaR_izW60QNYTjwI/edit?usp=sharing
I am thankful for any hint and comment.