41

How to retrieve KLSE, SGX, and gold prices in Google Sheets (Updated for 2020)

 3 years ago
source link: https://anonoz.github.io/tech/2020/11/04/google-sheets-klse-sgx.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to retrieve KLSE, SGX, and gold prices in Google Sheets (Updated for 2020)

For Bursa Malaysia (KLSE) and Singapore Exchange (SGX), we can scrape from i3investor websites. This is how.

This is the formula for KLSE:

=index(ImportXML("https://klse.i3investor.com/servlets/stk/5099.jsp", "//td[contains(@class, 'big16')]"), 1, 1)

And this is for SGX:

=index(ImportXML("https://sgx.i3investor.com/servlets/stk/g3b.jsp", "//td[contains(@class, 'big16')]"), 1, 1)

Just remember to replace the stock code with whatever you want, the part right before .jsp.

Gold Prices

First, install ImportJSON functions from https://github.com/bradjasper/ImportJSON into your Google Sheets script editor.

Then, you can use this formula to fetch USD per oz:

=index(ImportJSON("https://data-asg.goldprice.org/dbXRates/USD", "/items"), 2, 2)

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK