Finance/Quote/Chart.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 59 CC 3 SCAR 16.1
CC
3
Cov
0%
chartprog_quotes
12.0
labels
2.0
methods
2.0
CRAP 5.0
1 # Finance::Quote interface to Chart latest prices.
2  
3 # Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2023, 2024 Kevin Ryde
4  
5 # This file is part of Chart.
6 #
7 # Chart is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3, or (at your option) any later version.
10 #
11 # Chart is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 # details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with Chart. If not, see <http://www.gnu.org/licenses/>.
18  
19  
20 package Finance::Quote::Chart;
21 use 5.006;
22 use strict;
23 use warnings;
24 use Carp;
25  
26 our $VERSION = 275;
27  
28 sub chartprog_quotes {
29 my ($quoter, @symbol_list) = @_;
30 require App::Chart::Latest;
31  
32 my %quotes = ();
33 foreach my $symbol (@symbol_list) {
34 my $latest = App::Chart::Latest->get ($symbol);
35  
36 # standard F-Q fields
37 if (my $date = $latest->{'last_date'}) {
38 $quoter->store_date(\%quotes, $symbol, {isodate => $date});
39 }
40 $quotes{$symbol,'name'} = $latest->{'name'};
41 $quotes{$symbol,'currency'} = $latest->{'currency'};
42  
43 $quotes{$symbol,'bid'} = $latest->{'bid'};
44 $quotes{$symbol,'ask'} = $latest->{'offer'};
45 $quotes{$symbol,'last'} = $latest->{'last'};
46 $quotes{$symbol,'open'} = $latest->{'open'};
47 $quotes{$symbol,'high'} = $latest->{'high'};
48 $quotes{$symbol,'low'} = $latest->{'low'};
49 $quotes{$symbol,'net'} = $latest->{'change'};
50 $quotes{$symbol,'volume'} = $latest->{'volume'};
51  
52 $quotes{$symbol,'method'} = 'chartprog';
53 $quotes{$symbol,'source'} = __PACKAGE__;
54 $quotes{$symbol,'success'} = 1;
55 $quotes{$symbol,'errormsg'} = $latest->{'error'};
56  
57 # extras
58 $quotes{$symbol,'time'} = $latest->{'last_time'};
59 $quotes{$symbol,'exchange'} = $latest->{'exchange'};
60 # my $div_amount = $latest->{'ex_dividend'};
61 # $latest->{'ex_div'};
62 # $quotes{$symbol,'ex_div'} = $ex_date;
63 # $quotes{$symbol,'div'} = $div_amount;
64  
65 }
66 ### \%quotes
67 return wantarray ? %quotes : \%quotes;
68 }
69  
70 sub labels {
71 return (chartprog => [ qw(date isodate time name price change currency
72 method source) ]);
73 }
74  
75 sub methods {
76 return (chartprog => \&chartprog_quotes);
77 }
78  
79  
80 1;
81 __END__