How to update Currency Quotes in GnuCash on Ubuntu

If you use GnuCash on Ubuntu 16.04 LTS, then this will apply to you.

Over last few months, I have not been able to get stock quotes or currency updates for stocks on the NYSE, NASDAQ, Yahoo Finance. The reason is that Yahoo Finance Finance::Quotes module does not work anymore to fetch the quotes and therefore, to overcome this problem, I had to upgrade to the latest Finance::Quotes module. However, Ubuntu 16.04 does not have the latest Finance::Quotes module in it.

Finance::Quotes alone can be upgraded, but there is no later package than the one on the Ubuntu 16.04 repositories. Therefore, there is a need to rely on the gnc-fq-update program to perform the update of Finance::Quotes. Note that gnc-fq-update has not been packaged in the Finance::Quote deb file.

Follow the instructions below to do an update. Make sure you have backed up your data first.

Get the ALPHAVANTAGE API Key
Visit https://www.alphavantage.co/ enter your information and get your API key online.
Note down the key it gives you on-screen.

Open a Linux Terminal window

Update the /etc/gnucash/environment file with the key you received
$ sudo vi /etc/gnucash/environment <enter>
Add below line

ALPHAVANTAGE_API_KEY=XXXXXXXXXXX #where XXXXXXXXXXX is the key you got from alphavantage.co.
:wq

Next locate the gnc-fq-update script
$ ls -al /usr/bin/gnc-* <enter>
-rwxr-xr-x 1 root root 2820 Apr 18 2016 /usr/bin/gnc-fq-check
-rwxr-xr-x 1 root root 5902 Apr 18 2016 /usr/bin/gnc-fq-dump
-rwxr-xr-x 1 root root 11631 Apr 18 2016 /usr/bin/gnc-fq-helper
Note that the gnc-fq-update script has not been packaged with Finance::Quotes in Ubuntu 16.04 LTS.

Download the gnc-fq-update script
Therefore, download the gnc-fq-update file from the link below. It downloads to ~/Download folder for me.

https://raw.githubusercontent.com/Gnucash/gnucash/master/libgnucash/quotes/gnc-fq-update.in

Prepare gnc-fq-update as an executable
$ sudo mousepad /usr/bin/gnc-fq-update.in <enter>
Change first line to:
#!/usr/bin/perl -w
:wq

Rename gnc-fq-update.in and copy the file to /usr/bin
$ mv ~/Downloads/gnc-fq-update.in gnc-fq-update <enter>
$ cd /usr/bin <enter>
$ sudo cp home/user/Downloads/gnc-fq-update . <enter>
$ sudo chmod ugo+x gnc-fq-update <enter>

$ ls -al gnc* <enter>
-rwxr-xr-x 1 root root 2820 Apr 18 2016 gnc-fq-check
-rwxr-xr-x 1 root root 5902 Apr 18 2016 gnc-fq-dump
-rwxr-xr-x 1 root root 11631 Apr 18 2016 gnc-fq-helper
-rw-r–r– 1 root root 1509 Jan 30 21:34 gnc-fq-update

Next update 16.04 LTS Finance::Quote module using gnc-fq-update
$ sudo gnc-fq-update <enter>

Let it run automatically. All files will be in path /usr/local/share/perl/5.22.1/Finance/Quote/