Created
November 7, 2024 22:57
-
-
Save mtrimarchi/89838c43261fdda2a1b36eba0a6c8ac6 to your computer and use it in GitHub Desktop.
Get quote data from justETF
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
function GETQUOTEDATA(isin, dataPoint) { | |
if (!isin) { | |
return "Error: ISIN required"; | |
} | |
const url = "https://www.justetf.com/api/etfs/" + isin + "/quote?currency=EUR&locale=it"; | |
try { | |
const response = UrlFetchApp.fetch(url); | |
const data = JSON.parse(response.getContentText()); | |
switch(dataPoint.toLowerCase()) { | |
case "latest": | |
return data.latestQuote.raw; | |
case "previous": | |
return data.previousQuote.raw; | |
case "change%": | |
return data.dtdPrc.raw; | |
case "change": | |
return data.dtdAmt.raw; | |
case "venue": | |
return data.quoteTradingVenue; | |
case "low": | |
return data.quoteLowHigh.low.raw; | |
case "high": | |
return data.quoteLowHigh.high.raw; | |
default: | |
return "Error: Invalid data point"; | |
} | |
} catch (error) { | |
return "Error fetching data"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment