How to get the latest commodity pricing in Google Sheet

Minhaz
CodeX
Published in
5 min readMay 31, 2022

--

Google sheet has easy macros to get price of US stocks and currency, but not for gold or silver. Here’s easy & free trick to get latest prices!

Screenshot of Google Sheet by Author using a custom hand written function.

I use Google Sheets for tracking my expenses, assets, and liabilities. Google Sheet has first-class support for querying the latest values of stocks on US-based exchanges like NASDAQ or NYSE. On the other hand, it doesn’t have as well support for other exchanges like SGX: Singapore Exchange.

To overcome this we are supposed to run awkward hacks like crawling yahoo finance pages.

In this article, I’ll share about how to write an AppScript code that will allow you to crawl such information from certain API repositories. Some of these API services only provide limited API call per month —so we shall look at the caching approach as well.

I’ll be using the example of

How to get the latest gold price in Google Sheet or How to get the latest metal price in Google Sheet in general.

This can be easily extended to solve questions on how to get the latest gold prices in India or the latest price of Indian stocks or Singapore Exchange stocks.

Disclaimer: In this article I am not giving any…

--

--

Minhaz
CodeX
Writer for

Staff Software Engineer @Google. Leading teams democratising On device AI for for masses. Writes about programming generics & specifics.