Reputation: 441
The price of CVE on TSX can be retrived by =GOOGLEFINANCE("TSE:CVE", "price")
in Google Sheets. How does one get the price of CVE-WT using GOOGLEFINANCE?
Upvotes: 1
Views: 124
Reputation: 15328
I can't find it on googlefinance. You can retrieve by yahoo :
function marketPrice(code) {
var url='https://finance.yahoo.com/quote/'+code
var source = UrlFetchApp.fetch(url).getContentText()
var jsonString = source.match(/(?<=root.App.main = ).*(?=}}}})/g) + '}}}}'
var data = JSON.parse(jsonString)
var regularMarketPrice = data.context.dispatcher.stores.StreamDataStore.quoteData[code].regularMarketPrice.raw
return regularMarketPrice
}
function test() {Logger.log(marketPrice('CVE-WT'))}
Upvotes: 1