-
-
Save icy/2c1455a07b56ec0fe9eb434976f41e3f to your computer and use it in GitHub Desktop.
Google script to fetch stock quote data from Yahoo Finance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* | |
Author: Ky-Anh Huynh | |
Original script: https://gist.github.com/mikaelz/11b956c3d2e078105a19dd9df70dbf27 | |
Usage: | |
ticker : Your ticker name, eg. ETH-EUR | |
token : A random string otherwise yahoo output may be a bit messy | |
You should have random token on each call! | |
*/ | |
function MyYahooTicker(ticker,token) { | |
var ticker = ticker || "SXR8.DE"; | |
var token = token || "secure-random-string"; | |
ticker = encodeURI(ticker); | |
var response = UrlFetchApp.fetch("https://query2.finance.yahoo.com/v10/finance/quoteSummary/" + ticker + "?modules=price,summaryDetail&hello=" + token); | |
var chain = JSON.parse(response.getContentText()); | |
return parseFloat(chain.quoteSummary.result[0].price.regularMarketPrice.raw); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment