Abstract
GnuCash provides a commandline facility gnucash-cli that one can use with the
        --quotes option in a terminal session to check the version and
        supported source modules, to display the quotes or exchange rates for selected securities or
        currencies, or to update all of the prices in a book without launching the GUI.
      
|  | Note | 
|---|---|
| In  | |
Abstract
The --quotes info option returns the version number of the currently
          installed Finance::Quote module and a list of available sources. It informs you also if there is
          a problem with your installation and gives the reasons.
        
The latest Finance::Quote version is 1.65. The list of sources that follows depends on the
        Finance::Quote version.
      
The input of
gnucash-cli  { 
              -Q
              |   
              --quotes
             }  
            info
           
in the terminal produces the following output:
$ gnucash-cli --quotes info Found Finance::Quote version 1.57. Finance::Quote sources: aex alphavantage amfiindia asegr asx aufunds australia bamosz bet bloomberg bourso bse bseindia bvb canada canadamutual comdirect cse deka dutch dwsfunds europe fetch_live_currencies fidelity fidelity_direct finanzpartner fondsweb fool france ftfunds fundata fundlibrary goldmoney googleweb greece hu hufund hungary hustock iexcloud india indiamutual known_currencies marketwatch morningstarau morningstarch morningstarjp morningstaruk mstaruk nasdaq nseindia nyse nzx onvista oslobors romania seb_funds sinvestor six tesouro_direto tiaacref tmx tradegate tradeville treasurydirect troweprice troweprice_direct tsp tsx twelvedata ukfunds unionfunds usa xetra yahoo_json yahooweb za
If there's a problem with your installation it will tell you about it. For example in this case we're missing the Perl modules Finance::Quote and JSON::Parse:
$ gnucash-cli --quotes info Failed to initialize Finance::Quote: missing_modules Finance::Quote JSON::Parse
In this case, Finance::Quote is not installed correctly and therefore cannot be used for quote retrieval
        with GnuCash. Please install Finance::Quote according to the instructions at
        Section 11.2, “Installing Finance::Quote”.
      
Abstract
The --quotes dump option provides quotes for a source and a list of of
          symbols in a format that is easy for humans to read. This is useful to verify that a
          particular online quote source is accessible and provides data.
        
You can also check to see if the symbol you want to use for your online price retrieval is available at the desired quote source.
|  | Tip | 
|---|---|
| You may use  | |
To display a quote for one or more stocks or the exchange rate for one or more currencies you can
        use gnucash-cli --quotes dump as follows:
        
gnucash-cli  { 
              -Q
              |   
              --quotes
             }  
            dump
            [ 
              -V
              |   
              --verbose
             ]  
            Source
             
            Symbol
          ... 
It offers two output forms for non-currency securities and one for currency exchange rates.
Currencies use the source currency and require at least two
                ISO 4217 currency codes; the exchange
                rates are denominated in the first code.
                [10]
                For example:
                
$ gnucash-cli --quotes dump currency USD GBP EUR 1 GBP = 1.2796 USD 1 EUR = 1.09837 USD
To retrieve quotes of your securities, please enter the quote source and the desired symbol.
A short form displaying only the fields that GnuCash uses along with comments indicating whether the
                      fields are optional or required; you can use this to determine if GnuCash will
                      be able to use the quote to update your book's price database.
                      
$ gnucash-cli --quotes dump yahooweb AAPL
Finance::Quote fields GnuCash uses:
    symbol: AAPL            <=== required
      date: 07/28/2023      <=== recommended
  currency: USD             <=== required
      last: 193.22          <=\
       nav:                 <=== one of these
     price:                 <=/
With the --verbose option a possibly longer output showing all of the fields
                      Finance::Quote returned. This can be useful to troubleshoot problems with a Finance::Quote
                      source module.
                      
$ ALPHAVANTAGE_API_KEY=123456789 gnucash-cli --verbose --quotes dump alphavantage INTC
INTC:
        open => 34.8200
     isodate => 2023-07-27
       close => 34.3600
        date => 07/27/2023
      symbol => INTC
    currency => USD
currency_set_by_fq => 1
         low => 34.1100
      volume => 58890821
     success => 1
        high => 35.0300
         net => 0.1900
        last => 34.5500
    p_change => 0.5530
      method => alphavantage
|  | Note | 
|---|---|
| Notice that in this case we used alphavantage and provided the
                           | |
To test if Finance::Quote works for currencies inside GnuCash, do the following:
        
create a transaction with the desired commodity in the book currency,
make a right click on it,
select in the context menu.
In the Section 6.1, “Transfer Funds Dialog Box” window click the Get exchange rate button.
If the exchange rate source and the symbol are set, the current rate will be entered in the exchange rate field.
With the command gnucash-cli --quotes get ${HOME}/gnucash-filenameGnuCash-file without starting the user interface. This enables an
        automatic, regular updating of the prices.
        
|  | Note | 
|---|---|
| The command fails if exclusive access to the data file is not possible, for example, the data file
            is opened in another  | |
The specified file ${HOME}/gnucash-filenameGnuCash window before the
        “-”.
        
|  | Tip | 
|---|---|
| The file name can also be found in the list of recently opened files in the menu. If you hover the mouse pointer on the menu item numbered 1 in the list of recently opened files, the full file name is displayed in the statusbar. | |
You have to register the gnucash-cli with a scheduler in order to get Online Quotes automatically and
        periodically. The method depends on your OS.
      
Example 11.1. Automated quote retrieval every Friday at 4:00 p.m.
Procedure 11.7. On Linux and macOS
Register gnucash-cli with cron.
          
Run crontab -e.
Add the following line to your crontab:
0 16 * * 5 gnucash-cli --quotes get ${HOME}/gnucash-filename
|  | Important | 
|---|---|
| On  
0 16 * * 5 env `dbus-launch` sh -c 'trap "kill $DBUS_SESSION_BUS_PID" EXIT;
gnucash-cli --quotes get (Do not copy the line breaks into the crontab, they were inserted here only for the purpose of readability). | |
Procedure 11.8. On Windows
Register gnucash-cli with Task Scheduler.
Select → →
Select .
Enter the appropirate items on Create Task Window.
Adjust the time to the close of the stock exchange and consider fund quotes, that the net asset value (NAV) is determined well after the markets closed. The types have their description in Section 8.6, “Price Editor”.
Some users have made additions to the wiki and shared their experiences on the Online Quotes Page on GnuCash Wiki.
[10] Since Finance::Quote 1.41 the default source for currencies is “Alpha Vantage”. See also the
                    notes on wiki:Online_Quotes#Finance::Quote_Sources_-_Currency_Source.
                  
[11] This replaces the command GnuCash --add-price-quotes ${HOME}/gnucash-filenameGnuCash
            version 4.x and earlier.