Something has changed in the Yahoo Finance page and I need help to figure how to fix the linking of stock option prices from Yahoo to my Google Sheets spreadsheet.
The execution log shows; Error - Exception: DNS error: https://QUERY.finance.yahoo.com/v10/finance/quoteSummary/undefined?modules=price,summaryDetail&hello=undefined YAHOO_STOCK @ Code.gs:4
Can anyone give me a hand here on if this is fixable and how?
function YAHOO_STOCK(ticker, token) {
const url = "https://QUERY.finance.yahoo.com/v10/finance/quoteSummary/" + ticker + "? modules=price,summaryDetail" + "&hello=" + token;
const source = UrlFetchApp.fetch(url).getContentText();
const data = JSON.parse(source);
const price = data.quoteSummary.result[0].price;
const summaryDetail = data.quoteSummary.result[0].summaryDetail;
const marketPrice = price['regularMarketPrice'].raw;
const bidPrice = summaryDetail['bid'].raw;
const askPrice = summaryDetail['ask'].raw;
const change = price['regularMarketChange'].raw;
return [[marketPrice, bidPrice, askPrice, change]];
}
Seems it needs a token maybe?, but I don't know how to change that.