/usr/share/perl5/Finance/Quote/Troweprice.pm is in libfinance-quote-perl 1.18-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | #!/usr/bin/perl -w
#
# Copyright (C) 1998, Dj Padzensky <djpadz@padz.net>
# Copyright (C) 1998, 1999 Linas Vepstas <linas@linas.org>
# Copyright (C) 2000, Yannick LE NY <y-le-ny@ifrance.com>
# Copyright (C) 2000, Paul Fenwick <pjf@cpan.org>
# Copyright (C) 2000, Brent Neal <brentn@users.sourceforge.net>
#
# 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
#
#
# This code derived from Padzensky's work on package Finance::YahooQuote,
# but extends its capabilites to encompas a greater number of data sources.
#
# This code was developed as part of GnuCash <http://www.gnucash.org/>
package Finance::Quote::Troweprice;
require 5.005;
use strict;
use vars qw($VERSION $TROWEPRICE_URL);
use LWP::UserAgent;
use HTTP::Request::Common;
use Carp;
$VERSION = '1.18';
# URLs of where to obtain information.
$TROWEPRICE_URL = ("http://www.troweprice.com/mutual/prices.csv");
sub methods { return (troweprice => \&troweprice,
troweprice_direct => \&troweprice); }
{
my @labels = qw/method exchange name nav date isodate price/;
sub labels { return (troweprice => \@labels,
troweprice_direct => \@labels); }
}
# =======================================================================
sub troweprice
{
my $quoter = shift;
my(@q,%aa,$ua,$url,$sym);
# for T Rowe Price, we get them all.
$url = $TROWEPRICE_URL;
$ua = $quoter->user_agent;
my $reply = $ua->request(GET $url);
return unless ($reply->is_success);
foreach (split('\015?\012',$reply->content))
{
@q = $quoter->parse_csv($_);
# extract the date which is usually on the second line fo the file.
($sym = $q[0]) =~ s/^ +//;
if ($sym) {
$aa {$sym, "exchange"} = "T. Rowe Price"; # TRP
$aa {$sym, "method"} = "troweprice";
# ($aa {$sym, "name"} = $q[0]) =~ s/^ +//;
$aa {$sym, "name"} = $sym; # no name supplied ...
$aa {$sym, "nav"} = $q[1];
$quoter->store_date(\%aa, $sym, {usdate => $q[2]});
$aa {$sym, "price"} = $aa{$sym,"nav"};
$aa {$sym, "success"} = 1;
$aa {$sym, "currency"} = "USD";
} else {
$aa {$sym, "success"} = 0;
$aa {$sym, "errormsg"} = "Stock lookup failed.";
}
}
return %aa if wantarray;
return \%aa;
}
1;
=head1 NAME
Finance::Quote::Troweprice - Obtain quotes from T. Rowe Price
=head1 SYNOPSIS
use Finance::Quote;
$q = Finance::Quote->new;
%stockinfo = $q->fetch("troweprice","PRFDX"); # Can failover to other methods
%stockinfo = $q->fetch("troweprice_direct","PRFDX"); # Use this module only.
=head1 DESCRIPTION
This module obtains information about managed funds from T. Rowe Price.
Information about T. Rowe Price funds is available from a variety of
sources. The information source "troweprice" can be used if you don't
care which source you obtain information from. If you wish to be
guaranteed of fetching information from T. Rowe Price directly,
then the information source "troweprice_direct" should be used.
=head1 LABELS RETURNED
Information available from T. Rowe Price may include the following
labels: exchange, name, nav, date, price.
=head1 SEE ALSO
T. Rowe Price website - http://www.troweprice.com/
Finance::Quote::Yahoo::USA
=cut
|