App/Chart/Series/Derived/ASI.pm untested

filter: Statementstmt 0.0% 0 / 46 Branchbran n/a Conditioncond 0.0% 0 / 6 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 15 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 72 CC 1 SCAR 6.9
CC
1
Cov
0%
longname
2.0
shortname
2.0
manual
2.0
CRAP 2.0
1 # Copyright 2006, 2007, 2009, 2010 Kevin Ryde
2  
3 # This file is part of Chart.
4 #
5 # Chart is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3, or (at your option) any later version.
8 #
9 # Chart is distributed in the hope that it will be useful, but WITHOUT ANY
10 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 # details.
13 #
14 # You should have received a copy of the GNU General Public License along
15 # with Chart. If not, see <http://www.gnu.org/licenses/>.
16  
17 package App::Chart::Series::Derived::ASI;
18 use 5.010;
19 use strict;
20 use warnings;
21 use Carp;
22 use List::Util qw(min max);
23 use Locale::TextDomain ('App-Chart');
24  
25 use base 'App::Chart::Series::Indicator';
26 use App::Chart::Series::Derived::OBV;
27 use App::Chart::Series::Derived::SwingIndex;
28  
29  
30 # http://www.ensignsoftware.com/espl/espl71.htm
31 # Code for swing index, ASI part confusing though.
32 #
33 # http://www.investopedia.com/articles/technical/02/100702.asp
34 # Sample chart of Apple (AAPL).
35 #
36  
37  
38 sub longname { __('ASI - Accumulative Swing Index') }
39 sub shortname { __('ASI') }
40 sub manual { __p('manual-node','Accumulative Swing Index') }
41  
42 use constant
43 { type => 'indicator',
44 units => 'ASI',
45 parameter_info => [ ],
46 };
47  
48 sub new {
49 my ($class, $parent) = @_;
50  
51 return $class->SUPER::new
52 (parent => $parent,
53 parameters => [ ],
54 arrays => { values => [] },
55 array_aliases => { });
56 }
57 *fill_part = \&App::Chart::Series::Derived::OBV::fill_part;
58  
59 sub proc {
60 my ($self) = @_;
61 my $parent = $self->parent;
62  
63 my $p = $parent->values_array;
64 my $po = $parent->array('opens') || [];
65 my $ph = $parent->array('highs') || [];
66 my $pl = $parent->array('lows') || [];
67  
68 sub {
69 my ($i, $value, $i_prev, $value_prev) = @_;
70  
71 return App::Chart::Series::Derived::SwingIndex::swing_index_calc
72 ($po->[$i_prev], $value_prev,
73 $po->[$i], $ph->[$i], $pl->[$i], $value);
74 };
75 }
76  
77  
78 1;
79 __END__
80  
81 # =head1 NAME
82 #
83 # App::Chart::Series::Derived::ASI -- Accumulative Swing Index
84 #
85 # =head1 SYNOPSIS
86 #
87 # my $series = $parent->ASI();
88 #
89 # =head1 DESCRIPTION
90 #
91 # ...
92 #
93 # =head1 SEE ALSO
94 #
95 # L<App::Chart::Series>
96 #
97 # =cut