Add new script that dumps all the data returned by F::Q for a stock.

It also indicates which data field gnucash requires, which are
optional, etc.  Intended for troubleshooting.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7877 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2003-01-23 03:54:37 +00:00
parent 238f756297
commit db578fc4a9
3 changed files with 118 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2003-01-22 David Hampton <hampton@employees.org>
* src/quotes/dump-finance-quote: Add new script that dumps all the
data returned by F::Q for a stock. It also indicates which data
field gnucash requires, which are optional, etc.
2003-01-22 Derek Atkins <derek@ihtfp.com> 2003-01-22 Derek Atkins <derek@ihtfp.com>
* src/business/business-reports/business-reports.scm -- need to * src/business/business-reports/business-reports.scm -- need to

View File

@ -1,7 +1,7 @@
gncsharedir = ${GNC_SHAREDIR} gncsharedir = ${GNC_SHAREDIR}
bin_SCRIPTS = gnc-prices update-finance-quote bin_SCRIPTS = dump-finance-quote gnc-prices update-finance-quote
gncshare_SCRIPTS = finance-quote-helper finance-quote-check gncshare_SCRIPTS = finance-quote-helper finance-quote-check
EXTRA_DIST = \ EXTRA_DIST = \

111
src/quotes/dump-finance-quote Executable file
View File

@ -0,0 +1,111 @@
#!/usr/bin/perl
#
# Copyright (C) 2003, David Hampton <hampton@employees.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA
#
use strict;
use Finance::Quote;
sub report {
my($itemname, $qh) = @_;
my ($symbol, $date, $currency, $last, $nav, $price, $timezone, $keyname);
# Parse the quote fields and put warnings where necessary.
$symbol = defined($$qh{$itemname, "symbol"})
? $$qh{$itemname, "symbol"} : "$itemname (deduced)";
$date = defined($$qh{$itemname, "date"})
? $$qh{$itemname, "date"} : "** missing **";
$currency = defined($$qh{$itemname, "currency"})
? $$qh{$itemname, "currency"} : "** missing **";
if ((!defined($$qh{$itemname, "last"})) &&
(!defined($$qh{$itemname, "nav" })) &&
(!defined($$qh{$itemname, "price"}))) {
$$qh{$itemname, "last"} = "**missing**";
$$qh{$itemname, "nav"} = "**missing**";
$$qh{$itemname, "price"} = "**missing**";
} else {
$last = defined($$qh{$itemname, "last"})
? $$qh{$itemname, "last"} : "";
$nav = defined($$qh{$itemname, "nav"})
? $$qh{$itemname, "nav"} : "";
$price = defined($$qh{$itemname, "price"})
? $$qh{$itemname, "price"} : "";
}
$timezone = defined($$qh{$itemname, "timezone"})
? $$qh{$itemname, "timezone"} : "";
# Dump gnucsah recognized fields
printf "Finance::Quote fields Gnucash uses:\n";
printf " symbol: %-20s <=== required\n", $symbol;
printf " date: %-20s <=== required\n", $date;
printf " currency: %-20s <=== required\n", $currency;
printf " last: %-20s <=\\ \n", $last;
printf " nav: %-20s <=== one of these\n", $nav;
printf " price: %-20s <=/ \n", $price;
printf " timezone: %-20s <=== optional\n", $timezone;
# Dump all fields
printf "\nAll Finance::Quote Fields\n";
foreach $keyname (sort keys %$qh) {
my ($item, $key) = split('\034', $keyname);
printf "%10s: %s\n", $key, $$qh{$item, $key}, "\n";
}
print "\n";
}
my $q = Finance::Quote->new;
$q->timeout(60);
if ($#ARGV < 1) {
my @sources = $q->sources();
printf "\nUsage: $0 <quote-source> <stock> [<stock> ...]\n\n";
printf "Available sources are: \n %s\n\n", join(' ', @sources);
exit 0;
}
my $exchange = shift;
while ($#ARGV >= 0) {
my $stock = shift;
my %quotes = $q->fetch($exchange, $stock);
$stock =~ tr/a-z/A-Z/;
report($stock, \%quotes);
if ($#ARGV >= 0) {
printf "=====\n\n";
}
}
=head1 NAME
dump-finance-quote - Print out data from the F::Q module
=head1 SYNOPSIS
dump-finance-quote yahoo CSCO JNPR
dump-finance-quote yahoo BAESY.PK
dump-finance-quote europe 48406.PA 13000.PA
dump-finance-quote vwd 632034
dump-finance-quote ftportfolios FKYGTX
=head1 DESCRIPTION
This program obtains information from Finance::Quote about any
specified stock, and then dumps it to the screen in annotated form.
This will allow someone to see what is returned, and whether it
provides all the information needed by Gnucash.
=cut