Difference between revisions of "Online Quotes"

From GnuCash
Jump to: navigation, search
(Perl: Note about gnc-fq-* is not recognized as an internal or external command)
(Finance::Quote: MacOs section)
Line 23: Line 23:
 
from the command line.
 
from the command line.
  
* If F::Q is missing or outdated, you need to install or update it. It can be done with
+
* If F::Q is missing or outdated, you need to install or update it. Generally it can be done with
 
  perl -MCPAN -e shell
 
  perl -MCPAN -e shell
 
   install Finance::Quote  
 
   install Finance::Quote  
Line 29: Line 29:
 
   upgrade Finance::Quote
 
   upgrade Finance::Quote
  
You also need  
+
:You also need  
 
   install Date::Manip
 
   install Date::Manip
 +
:in case you disabled the resolving of dependencies.
  
 
But there are easier ways depending on your operating system:
 
But there are easier ways depending on your operating system:
Line 36: Line 37:
 
:[[Windows#Finance::Quote]]
 
:[[Windows#Finance::Quote]]
 
:[[FAQ#Q: How do I fix a system error when getting stock quotes?]]
 
:[[FAQ#Q: How do I fix a system error when getting stock quotes?]]
:'''Linux:'''
+
:*'''Linux:'''
:If there is no recent perl-finance-quote offered by your ''package manager'' do the following:
+
::If there is no recent perl-finance-quote offered by your ''package manager'' do the following:
:As root (su / sudo) run the GnuCash Finance Quote update script  
+
::As root (su / sudo) run the GnuCash Finance Quote update script  
 
  gnc-fq-update
 
  gnc-fq-update
:It will install Finance::Quote and its dependencies.
+
::It will install Finance::Quote and its dependencies.
:* Some (Ubuntu based) distributions removed it from the package. In this case you can download it from [https://raw.github.com/Gnucash/gnucash/master/src/quotes/gnc-fq-update.in github].
+
::* Some (Ubuntu based) distributions removed it from the package. In this case you can download it from [https://raw.github.com/Gnucash/gnucash/master/src/quotes/gnc-fq-update.in github].
::*In the first line replace <tt>@-PERL-@</tt> with the path to your perl executable, e.g., <tt>/usr/bin/perl</tt> and mark the file as executable.
+
:::*In the first line replace <tt>@-PERL-@</tt> with the path to your perl executable, e.g., <tt>/usr/bin/perl</tt> and mark the file as executable.
::A discussion of how to set it up (in Ubuntu) can be found at [http://gnucash.1415818.n4.nabble.com/Installing-activeperl-for-automatic-retrieval-of-quotes-td4656798.html].
+
:::A discussion of how to set it up (in Ubuntu) can be found at [http://gnucash.1415818.n4.nabble.com/Installing-activeperl-for-automatic-retrieval-of-quotes-td4656798.html].
  
That script, as of 2.6.12, uses CPAN to install:
+
::That script, as of 2.6.12, uses CPAN to install:
 +
:::* Date::Manip
 +
:::* Finance::Quote
  
* Date::Manip
+
:*'''MacOs:'''
* Finance::Quote
+
::*from a Terminal prompt:
 +
/Applications/Gnucash.app/Contents/Resources/bin/gnc-fq-update
 +
::*Or use the applet that runs it from Finder in the dmg.
  
Then read the [http://www.gnucash.org/docs/v2.6/C/gnucash-help/acct-create.html#Online-price-setup instructions].
+
 
 +
Finally read the [http://www.gnucash.org/docs/v2.6/C/gnucash-help/acct-create.html#Online-price-setup instructions].
  
 
==Warning About Open Files==
 
==Warning About Open Files==

Revision as of 16:14, 25 July 2017

GnuCash can update your price database by fetching quotes online via the Perl module Finance::Quote.

Note: Both the Microsoft Windows and MacOS X GnuCash packages include update tools for Finance::Quote. In Windows it's called "Install Online Banking" and it's located in the GnuCash group in the Start Menu. In OS X it's "Update Finance::Quote" and it's in the dmg along with GnuCash.

Note: Because websites change frequently we advise you to keep Finance::Quote up-to-date. You can re-run the Windows or OS X installation tools as often as you like or you can use CPAN as explained below.

Requirements

Perl

  • Unix (Linux, Solaris, AIX, HPUX,...): You probably already have perl installed. Type perl -v on a command line to get the version number. If not, use your package manager to install it.
  • Mac OS X already has Perl installed. Open a Terminal application (in the Utilities folder of your Applications folder) and run perl -v to the version number.
  • Windows: <to be moved from Windows#Finance::Quote etc.>

Source: [1]

Note
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
gnc-fq-dump --help 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-dump --help

Finance::Quote

You need to install several Perl modules to get online quotes. While the error message may be about Finance::Quote not being installed properly, that module alone is not sufficient.

  • You can check the version and the list of available modules by running
gnc-fq-check

from the command line.

  • If F::Q is missing or outdated, you need to install or update it. Generally it can be done with
perl -MCPAN -e shell
 install Finance::Quote 
respective
 upgrade Finance::Quote
You also need
  install Date::Manip
in case you disabled the resolving of dependencies.

But there are easier ways depending on your operating system:

FAQ#Q: How do I install Finance::Quote on a Mac?
Windows#Finance::Quote
FAQ#Q: How do I fix a system error when getting stock quotes?
  • Linux:
If there is no recent perl-finance-quote offered by your package manager do the following:
As root (su / sudo) run the GnuCash Finance Quote update script
gnc-fq-update
It will install Finance::Quote and its dependencies.
  • Some (Ubuntu based) distributions removed it from the package. In this case you can download it from github.
  • In the first line replace @-PERL-@ with the path to your perl executable, e.g., /usr/bin/perl and mark the file as executable.
A discussion of how to set it up (in Ubuntu) can be found at [2].
That script, as of 2.6.12, uses CPAN to install:
  • Date::Manip
  • Finance::Quote
  • MacOs:
  • from a Terminal prompt:
/Applications/Gnucash.app/Contents/Resources/bin/gnc-fq-update
  • Or use the applet that runs it from Finder in the dmg.


Finally read the instructions.

Warning About 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

If you attempt to run

gnucash --add-price-quotes /path/to/file.gnucash

or on MacOSX:

/Applications/Gnucash.app/Contents/MacOS/Gnucash --add-price-quotes /Users/<username>/Documents/test.gnucash

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 http://projects.gnome.org/gconf/ 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

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 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:\Perl\site\lib\Finance\Quote

You can get the path by running:

perldoc -lm Finance::Quote

(Tested on Linux. Please update for: MacOS, Windows)

Documentation