GeniusTrader/Systems/Swing/Trend.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 78 CC 5 SCAR 18.4
CC
5
Cov
0%
long_signal
12.0
short_signal
12.0
new
2.0
CRAP 6.3
1 package Finance::GeniusTrader::Systems::Swing::Trend;
2  
3 # Copyright 2000-2002 Raphaƫl Hertzog, Fabien Fulhaber
4 # This file is distributed under the terms of the General Public License
5 # version 2 or (at your option) any later version.
6  
7 use strict;
8 use vars qw(@ISA @NAMES);
9  
10 use Finance::GeniusTrader::Prices;
11 use Finance::GeniusTrader::Systems;
12 use Finance::GeniusTrader::Signals::Swing::Trend;
13 use Finance::GeniusTrader::Signals::Swing::TrendEnding;
14  
15 @ISA = qw(Finance::GeniusTrader::Systems);
16 @NAMES = ("Trend");
17  
18 =pod
19  
20 =head1 Trend following system
21  
22 =cut
23  
24 sub new {
25 my $type = shift;
26 my $class = ref($type) || $type;
27  
28 my $self = { "args" => [] };
29  
30 return manage_object(\@NAMES, $self, $class, [ ], "");
31 }
32  
33 sub initialize {
34 my ($self) = @_;
35  
36 $self->{'trend'} = Finance::GeniusTrader::Signals::Swing::Trend->new;
37 $self->{'trendending'} = Finance::GeniusTrader::Signals::Swing::TrendEnding->new;
38  
39 $self->add_signal_dependency($self->{'trend'}, 1);
40 $self->add_signal_dependency($self->{'trendending'}, 1);
41 $self->add_prices_dependency(1);
42 }
43  
44  
45 sub long_signal {
46 my ($self, $calc, $i) = @_;
47
48 return 0 if (!$self->check_dependencies($calc, $i));
49
50 if ($calc->signals->get($self->{'trend'}->get_name(1), $i) ||
51 $calc->signals->get($self->{'trendending'}->get_name(1), $i))
52 {
53 return 1;
54 }
55 return 0;
56 }
57  
58 sub short_signal {
59 my ($self, $calc, $i) = @_;
60  
61 return 0 if (!$self->check_dependencies($calc, $i));
62
63 if ($calc->signals->get($self->{'trend'}->get_name(0), $i) ||
64 $calc->signals->get($self->{'trendending'}->get_name(0), $i))
65 {
66 return 1;
67 }
68 return 0;
69 }