Online Quotes

From GnuCash
Revision as of 03:34, 14 June 2020 by Goodvibes (talk | contribs) (Source Alphavantage, US - Add Source Yahoo)
Jump to: navigation, search
Back to: Using GnuCash german version

GnuCash can automatically retrieve the current share price of marketable commodities (e.g., stocks, mutual funds, currency exchange rates), called a quote, so that you do not need to manually update the prices of these securities in the GnuCash Price Database one at a time. If you are tracking the prices of more than a handful of securities, this features saves an enormous amount of time.


GnuCash stores the share prices of investments in the respective buy/sell/split transactions and additional quotes in an internal price database. Although it is possible to enter prices manually into the price database, it is more convenient to update them from online sources. GnuCash uses an external program written in the Perl programming language called Finance::Quote (often shortened to simply F::Q) to fetch these quotes online. Therefore, for this feature of GnuCash to work, your computer will need to have some additional software installed beyond simply the GnuCash application itself, as well as have an active Internet connection.

About Finance::Quote

The Finance::Quote Perl module is managed at

Since the Finance::Quote software is not part of GnuCash proper, if you believe you have found a bug in the Finance::Quote module, there is probably not a lot the GnuCash developers can do to fix the problem for you. Instead, you should report the issue directly to the Finance::Quote developers at the following bugtrackers:

However, please be reasonably confident that the problem truly lies in the Finance::Quote software and not somewhere else (e.g., could your Internet connection simply be down right now?) before you submit a bug report to the Finance::Quote developers.

The Finance::Quote software gathers its price data from several Web sites around the world that provide this information in different ways. Some sources offer

  • an API like JSON or YQL,
  • downloads, usually as CSV file, and finally,
  • quite literally by extracting information from the web page itself.

As these sources change frequently, we advise you to keep Finance::Quote up-to-date. (See below for instructions.)

Setting up online quotes in GnuCash

The GnuCash Guide includes instructions on setting up online quotes. This set up procedure provides the input to Finance::Quote, so it must be completed before the "Get Quotes" button in GnuCash's Price Database will have any effect.

Once again, Finance::Quote is external to GnuCash. Thus, for it to work, you need some additional installed beyond GnuCash itself. This includes the Perl language interpreter itself, the Finance::Quote module, and any dependencies required by this software. Occasionally, you may need to update the Finance::Quote software module (and, more occasionally, the Perl interpreter) separately from GnuCash.

To ease this update process, the GnuCash developers provide several helper scripts.

Helper Scripts

For your convenience, we ship several helper programs designed to make it easier to install, update, and diagnose problems with your installation of the Finance::Quote software module. These programs have names that begin with gnc-fq-*, and are themselves written in the Perl programming language. Along with your GnuCash installation, you should have the following helper programs:

Windows only
Note that while unixoid operating systems use a shebang (#!) to associate perl scripts with the Perl interpreter, others might fail. So, if you get an error like
C:\> gnc-fq-check
gnc-fq-check is not recognized as an internal or external command, operable program or batch file
you should repeat the command with a preceeding perl:
perl gnc-fq-check
This program returns the version number of and the list of modules available to the Finance::Quote software. It will also inform you if there is a problem with your Finance::Quote installation or if it is missing, and may suggest a fix.
Example with broken dependency
$ gnc-fq-check 
Can't locate Mozilla/ in @INC (you may need to install the Mozilla::CA module) (@INC contains: /usr/lib/perl5/site_perl/5.30.1/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.30.1 /usr/lib/perl5/vendor_perl/5.30.1/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.30.1 /usr/lib/perl5/5.30.1/x86_64-linux-thread-multi /usr/lib/perl5/5.30.1 /usr/lib/perl5/site_perl) at /usr/lib/perl5/vendor_perl/5.30.1/Finance/Quote/ line 33.
Compilation failed in require at (eval 303) line 1.
BEGIN failed--compilation aborted at (eval 303) line 1.
 at /usr/local/bin/gnc-fq-check line 91.
("1.47" "adig" "aex" "aiahk" "alphavantage" "amfiindia" "asegr" "asia" "asx" "australia" "bamosz" "bet" "bmonesbittburns" "bourso" "brasil" "bse" "bsero" "canada" "canadamutual" "citywire" "cominvest" "cse" "deka" "dutch" "dwsfunds" "europe" "fetch_live_currencies" "fidelity" "fidelity_direct" "fidelityfixed" "financecanada" "finanzpartner" "finland" "fool" "france" "ftfunds" "ftportfolios" "ftportfolios_direct" "fundlibrary" "goldmoney" "greece" "hex" "hu" "hufund" "hungary" "hustock" "indiamutual" "known_currencies" "lerevenu" "maninv" "morningstar" "morningstarjp" "mstaruk" "nasdaq" "nyse" "nz" "nzx" "platinum" "romania" "seb_funds" "sixfunds" "sixshares" "stockhousecanada_fund" "tdefunds" "tdwaterhouse" "tiaacref" "tnetuk" "troweprice" "troweprice_direct" "trustnet" "tsp" "tsx" "uk_unit_trusts" "ukfunds" "unionfunds" "usa" "usfedbonds" "vanguard" "vwd" "yahoo" "yahoo_asia" "yahoo_australia" "yahoo_brasil" "yahoo_europe" "yahoo_json" "yahoo_nz" "yahoo_yql" "za" "za_unittrusts")
The first part is the error message about a missing Mozilla/
At the end in brackets is the normal output of version and available sources.
If an error is displayed, see the next section gnc-fq-update, else continue with gnc-fq-dump.
This program installs or updates the Finance::Quote software module along with its dependencies. This program normally needs superuser or administrative privileges to succeed.
This program returns quote data for a source and a list of symbols in a format, which is easy to read for humans. It is useful for checking that a given online quote source is online and functional.
To get a stock price, run a command from the command line of the form:
gnc-fq-dump -v <source> <symbol>
gnc-fq-dump -v alphavantage IBM
To get a currency conversion rate between 2 currencies aaa and bbb using source Yahoo as JSON:
gnc-fq-dump -v yahoo_json aaabbb=X
gnc-fq-dump -v yahoo_json USDEUR=X
Since Finance::Quote version 1.41, the default source for currencies is hardcoded to be Alpha Vantage. E.g.
gnc-fq-dump currency USD EUR
This program is a filter, which does the same thing as gnc-fq-dump, but in a form which the program understands. Input and output are Scheme expressions. This helps developers to decide, if the error is in GnuCash or F::Q. It shows also trailing spaces in downloaded quotes.
As an example, in September 2008 an Unilever bond was reported to fail. Here is a sample execution and result of this helper program:
user@host:~$ echo '(yahoo_json "A0GFY7.SG")' | gnc-fq-helper
(("A0GFY7.SG" (symbol . "A0GFY7.SG") (gnc:time-no-zone . "2008-09-26 16:58:00") (last . 89.50) (currency . "EUR ")))
Do you see the error? Solution

Since these helper programs are Perl scripts, you must have a functioning Perl installation before any of these helper programs will run successfully.


This section describes the software installation required for GnuCash's online quote feature to work. Briefly, in addition to the GnuCash application itself, you will need to install Perl and its Finance::Quote module.


The Finance::Quote module relies on Perl, so Perl must be installed first. The procedure for installing Perl is handled differently on different operating systems.

Installing Perl on Unix

On most Unix-like operating systems (Linux, AIX, *BSD, HPUX, Solaris, etc.), Perl is probably already installed. If it is not, but your Unix-like operating system has a package manager, it will likely be installed automatically as a dependency of Finance::Quote.

To check if Perl is installed, invoke the perl -v command at a terminal prompt to get the Perl interpreter's version number. If that fails, the best bet is to use your package manager to install it. Refer to your operating system's documentation for additional details on using your package manager.

Installing Perl on macOS

On Apple's macOS computers, Perl is already installed by default. To confirm this, open the Terminal application (usually located in the Utilities folder of your Applications folder), and invoke the perl -v command to see the Perl interpreter's version number.

Installing Perl on Windows

Source: [1]


As mentioned previously, Finance::Quote is a Perl module that must be installed to enable online quote fetching. Finance::Quote, in turn, depends on a number of other Perl modules.

You can check to see if your system has Finance::Quote installed by running the gnc-fq-check helper program after you have installed Perl itself. Alternatively, you can open the "About GnuCash" window (from the menu, choose Help → About, or on macOS, from the menu choose GnuCash → About GnuCash) and look for a line reading Finance::Quote: 1.58 or similar; this screen reports the currently installed version of Finance::Quote (1.58 in the example given), if it can find one. If GnuCash cannot find a Finance::Quote version, this line will read Finance::Quote: -.

The easiest way to install the Finance::Quote software needed for retrieving online price quotes is to use the provided installation tools, or your system's package manager. Both the Windows and macOS GnuCash packages include provided update tools for Finance::Quote, while many Linux distributions provide a standard way to install packages (e.g., the apt program on Debian-based Linux distributions and the dnf tool on RedHat-based Linux distrubtions such as Fedora). These methods are described next.

Installing Finance::Quote on Windows

On a Windows computer, GnuCash provides the Install Online Price Retrieval program, which is located in the GnuCash group in the Start Menu. Simply click on it to begin the Finance::Quote installation process. You can re-run the Install Online Price Retrieval program as often as you like to ensure the Finance::Quote module remains up to date.

Installing Finance::Quote on macOS

Until GnuCash 3.6, GnuCash provided the FinanceQuote Update app, which was located in the disk image (.dmg file) along with the main GnuCash app itself. When you installed GnuCash by dragging and dropping the GnuCash app icon to a location on your computer's hard drive (like your Applications folder), you could also consider installing the FinanceQuote Update app into the same folder as you installed the main GnuCash app.

Launch the FinanceQuote Update app by double-clicking it to begin the Finance::Quote installation process. You can re-run the FinanceQuote Update app program as often as you like to ensure the Finance::Quote module remains up to date.

Installing Finance::Quote on macOS from a Terminal prompt

New security requirements for MacOS 10.14.6 and 10.15.0 put an end to the FinanceQuote Update app. Users must now use to install Finance Quote.

sudo /Applications/

If the FinanceQuote Update applet fails, you can simply run the above command while logged in to a user account with administrative privileges. (Note that a mere su may not be sufficient; you should log out of all user accounts, then log in as the admin user for the computer on which you want to install Finance::Quote, then run the above command from a Terminal.)

As with the applet, you can re-run the command as often as you like to ensure the Finance::Quote module remains up to date.

Installing Finance::Quote on Linux

On a Linux computer, the recommended way to install Finance::Quote is by searching in your OS distribution's package manager for finance-quote. Note that your distribution's package maintainer may prefix the package name with perl, lib, or both. We also recommend that you check the version of Finance::Quote offered by your OS package repositories to ensure it is a recent-enough version.

If no recent version of the Finance::Quote module is offered by your package manager, you should run the gnc-fq-update helper script manually. As root (using the su and/or the sudo commands) run the GnuCash Finance Quote update script:


This will begin the installation procedure for Finance::Quote and all of its dependencies.

Note for (Ubuntu based) distributions
Some of them removed it from the package. In this case you can
  • download it from github e.g. into your personal ~/bin directory,
  • In the first line replace @-PERL-@ with the path to your perl executable, e.g., /usr/bin/perl, remove the trailing .in from its name and mark the file as executable.
A discussion of how to fix it in Ubuntu can be found at gnucash-user/2012-September.

Since GnuCash version 2.6.12, this helper script uses CPAN (see the next section) to install the following Perl modules:

  • Date::Manip
  • Finance::Quote
  • and their dependencies

Installing Finance::Quote using CPAN

CPAN is the Comprehensive Perl Archive Network, which provides a collection of free Perl software (called modules) from which you can obtain the perl Finance::Quote module along with all of its dependencies. If the methods listed above for your specific Operating System distribution fails, you may nevertheless be able to install Finance::Quote by directly interfacing with CPAN yourself.

To do so using CPAN:

perl -MCPAN -e shell
# Either, if F::Q is missing, install it with
  install Finance::Quote
# or, if F::Q is outdated, update it with
  upgrade Finance::Quote
# finally check for Date::Manip
  install Date::Manip
# and exit:

On the first run of cpan it needs some configuration: requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.
Would you like to configure as much as possible automatically? [yes]

It is usually safe to accept the defaults.

FAQ#Q: How do I install Finance::Quote on a Mac?
FAQ#Q: How do I fix a "system error" or "unknown error" when getting stock quotes?

Finding the right Source and Symbol

Not all sources offer all commodities and different sources use different symbols. Common symbols are:

  • Ticker symbols: 1-4 character abbreviation of company names, often used for US shares;
  • National Security Identification Numbers: like CUSIP, often used by national fund companies;
  • ISIN: International Security Identification Numbers, at least in the EU they are more and more replacing the different NSINs;
  • sometimes completed by an appendix indicating the market place.

If your commodity is a mutual fund and F::Q offers its fund's company as a source (deka, dws, ...) look for the symbol on the mutual fund's website.

If there is a source for its registered exchange (AEX, ASX, ...) do the same.

In other cases google the ISIN to get a list of possible sources.

Global players: Alpha Vantage and Yahoo* are stronger in shares and Morningstar* in funds.

A fast way to check you have the correct source and symbol is to use Helper Script gnc-fq-dump. Run from a commandline
gnc-fq-dump -v <Source> <Symbol>

Source Alphavantage, US

Finance::Quote's alphavantage and currency sources require an AlphaVantage API key that you can get free from the AlphaVantage Website. Command-line Helper Scripts like gnc-fq-dump will obtain the key from the ALPHAVANTAGE_API_KEY environment variable. GnuCash will too if it uses the same environment.

Some sources are multiple sources. Multiple sources will be tried, until a price is obtained. If you use a multiple source that includes alphavantage, then you should use an AlphaVantage API key. See A.1.3. Finance::Quote Sources - Multiple sources

For GnuCash to be able to use Online Quotes, if the API key is not already specified in the environment, it can be entered in

  • GnuCash versions 2.6.20/2.7.4 and newer:
Online Quotes tab of GnuCash Preferences
  • GnuCash versions 2.6.19/2.7.3 and older:
environment.local file. Quit GnuCash if it's running and using any text editor (Windows users should prefer Notepad to WordPad or Word); you'll need administrator privileges in most cases) add
to the environment.local file, substituting your key for "#############".

You need Finance::Quote version 1.41 or later to use Alpha Vantage.

Alpha Vantage has limited the number of stock and currency quotes that may be requested in a given period using their free API key. If this limit is exceeded, GnuCash will show "unknown error". Finance::Quote v#1.48 and later copes with this for stock quotes, and v1.49 copes with this for currency quotes, although v1.50 (yet to be released as at Jun 14 2020) does it better. Paid Premium Alpha Vantage subscriptions do not have this limit.

Source Yahoo

On 1 November 2017 Yahoo! discontinued its csv interface, which had been the primary source that Finance::Quote used for all currency quotes and the following stock quotes:

yahoo* (with exception of json and yql), canada, usa, nyse, nasdaq, vanguard.

The Finance::Quote maintainers have set up a new source, Alpha Vantage, to replace most of the discontinued Yahoo sources.

To update yahoo sources that no longer work, use the Security Editor in GnuCash to edit every security with Get Online Quotes enabled that uses a discontinued Yahoo! source and either disable (uncheck) Get Online Quotes or

[GnuCash 2.6.20/2.7.7 and newer]
change the source to "Alphavantage, US", "Yahoo as JSON" or "Yahoo as YQL".
change the the type of quote source to "Unknown" and the source to "alphavantage".

If using "Yahoo as JSON" or "Yahoo as YQL" for a non-US stock, you may have to append a suffix to the end of the stock symbol to tell Finance::Quote what stock exchange the stock is listed on. E.g. CBA.AX gets the quote price for stock CBA on the Australian Stock Exchange in currency AUD.

Updating enabled Quotes from outside GnuCash

To update all enabled quotes, you can run

GnuCash 4.0 and later

gnucash-cli --quotes get /path/to/file.gnucash
/Applications/ --quotes get /Users/<username>/Documents/test.gnucash
gnucash-cli.exe --quotes get file://C:/path/to/file.gnucash

GnuCash 3.11 and earlier

gnucash --add-price-quotes /path/to/file.gnucash
/Applications/ --add-price-quotes /Users/<username>/Documents/test.gnucash
gnucash.exe --add-price-quotes file://C:/path/to/file.gnucash


Windows Paths

On Windows if the path includes a "disk letter" then you must pass a "file URI" or GnuCash will confuse the drive letter for an URI scheme and fail to open it. e.g. file://C:/path/to/file.gnucash

Open Files

Updating quotes will modify the GNUCash file/database. As multi-user access is not supported, the file/database should be closed prior to updating quotes.

Cron and Non-X Usage - Linux & macOS (macOS TBC?)

If you attempt to do that without dbus running (for example, from a cron job or ssh without X forwarding), you may get errors such as
GConf Error: Failed to contact configuration server; the most common cause is a missing or misconfigured D-Bus session bus daemon. 
See for information. 
(Details -  1: Not running within active session)

One resolution for this, courtesy of SyncEvolution - The Missing Link, is to launch dbus for the duration of the quote retrieval with a cron command similar to:

GnuCash 4.0 and later

env `dbus-launch` sh -c 'trap "kill $DBUS_SESSION_BUS_PID" EXIT; gnucash-cli --quotes get /path/to/file.gnucash'

GnuCash 3.11 and earlier

env `dbus-launch` sh -c 'trap "kill $DBUS_SESSION_BUS_PID" EXIT; gnucash --add-price-quotes /path/to/file.gnucash'

Note: This has been documented in Bug #639776.

Technical Details

Where the F::Q files are stored depends on your OS/Distro:

  • Linux depends on the way it was installed:
    • by package manager: /usr/share/perl5/[vendor/]Finance/Quote
    • by CPAN or gnc-fq-update: /usr/share/perl5/site/Finance/Quote
    • self compiled: /usr/local/share/perl/5.xx.x/Finance/Quote
  • Windows: C:\Strawberry\perl\site\lib\Finance\Quote

You can get the path by running:

perldoc -lm Finance::Quote

Trouble Shooting

Try the steps below. After each step, run GnuCash and see if that solution resolved the problem of retrieving stock quotes.

Note for Microsoft Windows users to run perl scripts like gnc-fq-check
  1. Open a command line window:
    Windows 10 (not in Tablet Mode)
    Click in the Cortana Ask me anything field to the right of the Start button, begin typing cmd, a search menu should appear. The menu should display Command Prompt. Left-click or tap the Command Prompt icon.
    Windows 8 (or Windows 10 in Tablet Mode)
    From the Start screen, begin typing cmd, a search menu should appear. The menu should display Command Prompt. Left-click or tap the Command Prompt icon.
    Windows 7
    click Start button, type cmd in the Search programs and files field, press Enter
    Windows XP
    click Start button, All Programs, Accessories, Command Prompt
  2. Change to the drive containing the GnuCash program files (usually C drive) if that is not already the current drive:
  3. Change to the ...\gnucash\bin directory which contains the required gnc-fq-xxx perl script:
    32 bit version of Windows
    cd \Program Files\gnucash\bin
    64 bit version of Windows
    cd \Program Files (x86)\gnucash\bin
  4. Prefix any gnc-fq-xxx perl script command with perl and a space:
    perl gnc-fq-check
  1. Make sure you're running the latest version of Finance::Quote. Use gnc-fq-check to check what version you are running. Compare this with the latest release at CPAN or Finance::Quote Releases. The CPAN link is a search, and Finance::Quote will be the first hit; the latest version number and release date are under the name.
    On Windows or macOS you can update to the latest F::Q release by running the Online Quote Retrieval Installation program again or from the Unix command line run gnc-fq-update. The providers periodically change interfaces and it's important to keep Finance::Quote up to date to deal with the changes.
  2. Use gnc-fq-dump from the command line to check your F::Q sources and stock symbols, and if a currency conversion rate is available between your Default Currency (see Preferences, Accounts) and other currencies used by accounts.
  3. If the output of the gnc-fq-dump command
    • seems ok but Gnucash still fails to get the quote, run from a command line:
    echo '(yahoo_json "CSCO")' | gnc-fq-helper
    echo '(yahoo_json "CSCO")' | /Applications/
    echo (yahoo_json "CSCO") | perl gnc-fq-helper
    You should get something that looks like (("CSCO" (symbol . "CSCO") ..... (currency . "USD"))). There you can also find bad things like trailing blanks.
    • gives an error message about a missing file instead, that's your problem. This is a dependency that gnucash doesn't know about and so doesn't check for it. You will need to satisfy the missing dependency.
    But usually, at least under linux, it helps to run gnc-fq-update as root.
    For Windows see also Windows Finance::Quote.
  4. Run gnucash from the command line with the --debug argument (see Tracefile), attempt a quote retrieval, and then contact the developers either via email to a User Mailing List or on IRC.
  5. Sometimes it might help to know what module Perl does actually load.
This command will tell you exactly that for e.g. Tiaacref:
perldoc -lm Finance::Quote::Tiaacref


Back to: Using GnuCash