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 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 = 269;
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__
82  
83 =head1 NAME
84  
85 Finance::Quote::Chart - read Chart program quotes
86  
87 =for test_synopsis my ($fq, %quotes)
88  
89 =head1 SYNOPSIS
90  
91 use Finance::Quote;
92 $fq = Finance::Quote->new ('-defaults', 'Chart');
93 %quotes = $fq->fetch('chartprog','BHP.AX','RS.WCE');
94  
95 =head1 DESCRIPTION
96  
97 ...
98  
99 =head1 DATA
100  
101 The following standard F-Q fields are returned
102  
103 =for Finance_Quote_Grab fields flowed standard
104  
105 date isodate name currency
106 bid ask
107 open high low last net
108 volume
109 method source success errormsg
110  
111 Plus the following extras
112  
113 =for Finance_Quote_Grab fields table extra
114  
115 time ISO string "HH:MM"
116 exchange
117  
118 =head1 SEE ALSO
119  
120 L<chart>
121  
122 =head1 HOME PAGE
123  
124 L<http://user42.tuxfamily.org/chart/index.html>
125  
126 =head1 LICENCE
127  
128 Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Kevin Ryde
129  
130 Chart is free software; you can redistribute it and/or modify it under the
131 terms of the GNU General Public License as published by the Free Software
132 Foundation; either version 3, or (at your option) any later version.
133  
134 Chart is distributed in the hope that it will be useful, but WITHOUT ANY
135 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
136 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
137 details.
138  
139 You should have received a copy of the GNU General Public License along with
140 Chart; see the file F<COPYING>. Failing that, see
141 L<http://www.gnu.org/licenses/>.
142  
143 =cut