Skip to content

Instantly share code, notes, and snippets.

@mikaelz
Created April 20, 2020 06:34
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mikaelz/11b956c3d2e078105a19dd9df70dbf27 to your computer and use it in GitHub Desktop.
Save mikaelz/11b956c3d2e078105a19dd9df70dbf27 to your computer and use it in GitHub Desktop.
Google script to fetch stock quote data from Yahoo Finance
function YahooFinance(ticker) {
var ticker = ticker || "GOOG";
ticker = encodeURI(ticker);
var response = UrlFetchApp.fetch("https://query2.finance.yahoo.com/v7/finance/options/" + ticker);
var chain = JSON.parse(response.getContentText());
return parseFloat(chain.optionChain.result[0].quote.regularMarketPrice);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment