The command gnucash-cli --quotes get
[15]
can be used to fetch the current quotes of your stocks and write them directly into your
${HOME}/gnucash-filename
GnuCash
-data file without starting the GUI. Thus an automatic, regular updating of the price
database is possible.
Note | |
---|---|
The command will fail if it cannot get a lock on the data file, for example if the
data file is open in another |
The file specified
will depend on the name and location of your data file. This can
be determined by the name displayed in the top frame of the ${HOME}/gnucash-filename
GnuCash
window, before the
“-”.
Tip | |
---|---|
The file name can also be found under status bar. in the recently opened file list. If you place the mouse over the menu item with the number 1 in the list of recently opened files, the complete file name is displayed in the |
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.8. 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
> /dev/null 2>&1
Important | |
---|---|
If there is no graphic session that has already started the dbus, running on your computer at the time of the quote request, you must do the entry as follows instead: 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.9. 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.
[15] The Online Quotes Retrieval command has been changed from GnuCash
4.0. The old command
gnucash --add-price-quotes
is still available, but it
is deprecated and will be removed in the future release. If you've upgraded from ${HOME}/gnucash-filename
GnuCash
3.11 or previous version, it is recommended to use the new command
gnucash-cli.