Skip to content

Instantly share code, notes, and snippets.

@ubuntupunk
Forked from mikaelz/YahooFinance.js
Created July 5, 2021 12:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ubuntupunk/4e7bd5b5433ab928998f084144a59fa1 to your computer and use it in GitHub Desktop.
Save ubuntupunk/4e7bd5b5433ab928998f084144a59fa1 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