This file is indexed.

/usr/share/perl5/Finance/Quote/AIAHK.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/perl -w
#    This module is based on a perl script from Wouter van Marle
#    <wouter@squirrel-systems.com> and on the existing
#    Finance::Quote::ASEGR module.
#
#    The two were compined by David Hampton <hampton@employees.org> to
#    be able to retrieve stock information from the American
#    International Assurance website in Hong Kong.
#
#    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., 51 Franklin Street, Fifth Floor, Boston, MA
#    02110-1301, USA

require 5.005;

use strict;

package Finance::Quote::AIAHK;

use vars qw($VERSION $AIAHK_URL);

use LWP::UserAgent;
use HTTP::Request::Common;
use HTML::TableExtract;

$VERSION = '1.18';
$AIAHK_URL = 'http://www.aia.com.hk/daily/fund_mst_rightb.asp?cat=BR_AC';


sub methods { return (aiahk => \&aiahk); }
{
	my @labels = qw/name code date isodate price bid offer p_change_3m
	    p_change_1y p_change_3y currency method exchange/;

	sub labels { return (aiahk => \@labels); }
}

sub aiahk {

    my $quoter = shift;
    my @funds = @_;
    my (%info,$reply,$url,$te,$fund);
    my $ua = $quoter->user_agent();

    $url=$AIAHK_URL;
    $reply = $ua->request(GET $url);
    if (!$reply->is_success) {
	print("1\n");
	foreach my $fund (@funds) {
	    print("2\n");
	    $info{$fund, "success"}=0;
	    $info{$fund, "errormsg"}="Error retreiving fund quote page.";
	}
	return wantarray() ? %info : \%info;
    }
    #print($reply->content, "\n");

    # Now parse the data table contained in the result.  This is the
    # inner of two tables.  There are no headers on this table as they
    # are part of the iframe containing this page.
    $te= new HTML::TableExtract(depth => 1);
    $te->parse($reply->content);

    unless ($te->tables) {
	foreach $fund (@funds) {
	    $info {$fund,"success"} = 0;
	    $info {$fund,"errormsg"} = "Error parsing fund table";
	}
	return wantarray() ? %info : \%info;
    }


    # Was there a parse failure?  If so, record an error for each
    # requested find and get out now.
    my @rows;
    unless (@rows = $te->rows) {
	foreach $fund (@funds) {
	    $info {$fund,"success"} = 0;
	    $info {$fund,"errormsg"} = "Parse error";
	}
	return wantarray() ? %info : \%info;
    }


    # Now find the data for the requested funds.  This is an O(n^^2)
    # algorithm; no way around it.
    foreach $fund (@funds) {
	my $found = 0;
	foreach my $row (@rows) {
	    next if $$row[1] ne $fund;

	    my $tmp;
	    $info{$fund, "success"}=1;
	    $info{$fund, "exchange"}="American International Assurance, Hong Kong";
	    $info{$fund, "method"}="aiahk";
	    $info{$fund, "name"}=$$row[0];
	    $info{$fund, "name"} =~ s/^\s*(.*)\s*$/$1/;
	    $info{$fund, "symbol"}=$fund;
	    $quoter->store_date(\%info, $fund, {usdate => $$row[2]});
	    if ($$row[3] =~ /yield/i) {
		($info{$fund, "yield"}) = $$row[3] =~ m/yield = ([0-9.%]+)/i;
	    } else {
		($tmp=$$row[3]) =~ s/\s*//g;
		($info{$fund, "currency"}, $info{$fund, "bid"}) = $tmp =~ m/([A-Z]+)[^0-9]+([0-9.]+)/;
		($tmp=$$row[4]) =~ s/\s*//g;
		($tmp, $info{$fund, "offer"}) = $tmp =~ m/([A-Z]+)[^0-9]+([0-9.]+)/;

		$info{$fund, "price"} =  $info{$fund, "bid"};

		$info{$fund,"currency"}="USD" if $info{$fund,"currency"} eq "US";
		$info{$fund,"currency"}="HKD" if $info{$fund,"currency"} eq "HK";
		$info{$fund,"currency"}="JPY" if $info{$fund,"currency"} eq "YEN";
	    }
	    # $info{$fund, "p_change_3m"}=$$row[5];
	    # $info{$fund, "p_change_1y"}=$$row[6];
	    # $info{$fund, "p_change_3y"}=$$row[7];

	    $found = 1;
	    last;
	}
	$info{$fund, "success"}=$found;
	$info{$fund, "errormsg"}="Fund $fund not found in list " if !$found;

    }
    return wantarray() ? %info : \%info;
}
1;

=head1 NAME

Finance::Quote::AIAHK - Obtain quotes from American International Assurance

=head1 SYNOPSIS

    use Finance::Quote;

    $q = Finance::Quote->new;

    %info = Finance::Quote->fetch("aiahk","SCH-HKEQ");

=head1 DESCRIPTION

This module fetches information from the American International
Assurance http://www.aia.com.hk. All funds are available.

This module is loaded by default on a Finance::Quote object. It's
also possible to load it explicity by placing "AIAHK" in the argument
list to Finance::Quote->new().

Information obtained by this module may be covered by www.aia.com.hk
terms and conditions See http://www.aia.com.hk/ for details.

=head1 LABELS RETURNED

The following labels may be returned by Finance::Quote::AIAHK :

name code date isodate price bid offer p_change_3m p_change_1y
p_change_3y currency method exchange

=head1 SEE ALSO

American International Assurance, http://www.aia.com.hk

=cut