Difference between revisions of "Online Quotes"

From GnuCash
Jump to: navigation, search
(Technical Details: perldoc -lm Finance::Quote)
(Requirements: add *x,)
Line 2: Line 2:
 
==Requirements==
 
==Requirements==
 
===Perl===
 
===Perl===
<to be moved from [[Windows#Finance::Quote]] etc.>
+
*'''Unix''' (Linux, Solaris, AIX, HPUX,...): You probably already have perl installed. Type <code>perl -v</code> on a command line to find out which version.  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 <code>perl -v</code> to find out which version.
 +
*'''Windows''': <to be moved from [[Windows#Finance::Quote]] etc.>
 +
Source: [http://www.perl.org/get.html]
 
===Finance::Quote===
 
===Finance::Quote===
 
You need to install several Perl modules in order to get online quotes. While the error message may be about Finance::Quote not being installed properly, that module alone is not sufficient.  
 
You need to install several Perl modules in order to get online quotes. While the error message may be about Finance::Quote not being installed properly, that module alone is not sufficient.  

Revision as of 16:42, 2 April 2014

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

Requirements

Perl

  • Unix (Linux, Solaris, AIX, HPUX,...): You probably already have perl installed. Type perl -v on a command line to find out which version. 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 find out which version.
  • Windows: <to be moved from Windows#Finance::Quote etc.>

Source: [1]

Finance::Quote

You need to install several Perl modules in order 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. Update: In Feb 2014 Yahoo changed their URL. So F::Q 1.20 is required.

  • If F::Q is missing or outdated, you need to install or update it. In general it can be done with
perl -MCPAN -e shell
 install Finance::Quote 
respective
 upgrade Finance::Quote

But there are easier ways dependend of 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 GnuCashs 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.4.0, uses CPAN to install:

  • LWP
  • Date::Manip
  • HTML::Parser
  • HTML::TableExtract
  • Crypt::SSLeay
  • Finance::Quote

Then read the instructions.

Warning About Open Files

Updating quotes will modify the GNUCash file/database. As multi-user access is not supported (as of 2.4), 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

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 also by running:

perldoc -lm Finance::Quote

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

Documentation