I am using a function named getStockQuote()
in Google Sheets.
=getStockQuote()
The getStockQuote
function is pretty simple.
function getStockQuote() {
var url = 'SOME STOCK API SERVER';
var options = {
'method' : 'post',
'contentType': 'application/json',
headers: {
"Cache-Control": "no-cache"
},
// Convert the JavaScript object to a JSON string.
'payload' : JSON.stringify({"columns":["QUOTE"],"ignore_unknown_fields":false,"symbols":{"query":{"types":[]},"tickers":["SPY"]}})
}
var response = UrlFetchApp.fetch(url, options);
return JSON.parse(response).data[0].d[0];
}
The above code works and fetches the Stock value.
However, I need the updated value of this function in my Google Sheets every 5 minutes. Currently, it only runs the function once and the value doesn't get updated.
I tried time-based triggers but still not able to retrieve updated value in Google Sheets every 5 mins.