GeniusTrader/Indicators/VROC.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 45 CC 3 SCAR 16.7
CC
3
Cov
0%
calculate
12.0
initialize
2.0
BEGIN
2.0
CRAP 5.3
1 package Finance::GeniusTrader::Indicators::VROC;
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 # Standards-Version: 1.0
8  
9 use strict;
10 use vars qw(@ISA @NAMES @DEFAULT_ARGS);
11  
12 use Finance::GeniusTrader::Indicators;
13 use Finance::GeniusTrader::Indicators::ROC;
14 use Finance::GeniusTrader::Prices;
15  
16 @ISA = qw(Finance::GeniusTrader::Indicators);
17 @NAMES = ("VROC[#1]");
18 @DEFAULT_ARGS = (12, "{I:Prices VOLUME}");
19  
20 =head1 Finance::GeniusTrader::Indicators::VROC
21  
22 =head2 Overview
23  
24 The VROC is the Volume Rate Of Change.
25  
26 =head2 Calculation
27  
28 VROC = ((Volume(i) * 100) / Volume(i-n)) - 100
29  
30 =head2 Parameters
31  
32 The standard VROC is equal to Finance::GeniusTrader::Indicators::ROC->new([12], "VOLUME", $GET_VOLUME)
33  
34 =head2 Example
35  
36 Finance::GeniusTrader::Indicators::VROC->new()
37 Finance::GeniusTrader::Indicators::VROC->new([20])
38  
39 =cut
40  
41 sub initialize {
42 my $self = shift;
43 $self->{'roc'} = Finance::GeniusTrader::Indicators::ROC->new([ $self->{'args'}->get_arg_names(1), $self->{'args'}->get_arg_names(2) ] );
44 $self->add_indicator_dependency($self->{'roc'}, 1);
45 }
46  
47 =head2 Finance::GeniusTrader::Indicators::VROC::calculate($calc, $day)
48  
49 =cut
50 sub calculate {
51 my ($self, $calc, $i) = @_;
52 my $indic = $calc->indicators;
53 my $roc = $self->{'roc'};
54 my $roc_name = $roc->get_name;
55 my $vroc_name = $self->get_name(0);
56  
57 return if ($indic->is_available($vroc_name, $i));
58 return if (! $self->check_dependencies($calc, $i));
59
60 # Get and retrun the results from the ROC indicator
61 my $vroc_value = $indic->get($roc_name, $i);
62 $indic->set($vroc_name, $i, $vroc_value);
63 }
64  
65 1;