GeniusTrader/CloseStrategy/ChannelBreakout.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 58 CC 3 SCAR 12.0
CC
3
Cov
0%
manage_long_position
6.0
manage_short_position
6.0
initialize
2.0
CRAP 3.3
1 package Finance::GeniusTrader::CloseStrategy::ChannelBreakout;
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::CloseStrategy;
13 use Finance::GeniusTrader::Eval;
14 use Finance::GeniusTrader::Tools qw(:generic);
15  
16 @ISA = qw(Finance::GeniusTrader::CloseStrategy);
17 @NAMES = ("ChannelBreakout[#*]");
18 @DEFAULT_ARGS = ();
19  
20 =head1 NAME
21  
22 Finance::GeniusTrader::CloseStrategy::ChannelBreakout
23  
24 =head1 DESCRIPTION
25  
26 This Channel Breakout exit strategy close a position once the lower level
27 has been triggered for a long position, as well as the upper level for a
28 short position.
29  
30 =cut
31  
32 sub initialize {
33 my ($self) = @_;
34  
35 $self->add_arg_dependency(1, 1);
36 $self->add_arg_dependency(2, 1);
37 }
38  
39 sub long_position_opened {
40 my ($self, $calc, $i, $position, $pf_manager, $sys_manager) = @_;
41  
42 return;
43 }
44  
45 sub short_position_opened {
46 my ($self, $calc, $i, $position, $pf_manager, $sys_manager) = @_;
47  
48 return;
49 }
50  
51 sub manage_long_position {
52 my ($self, $calc, $i, $position, $pf_manager, $sys_manager) = @_;
53  
54 return 0 if (! $self->check_dependencies($calc, $i));
55  
56 my $price = $self->{'args'}->get_arg_values($calc, $i, 1);
57 my $order = $pf_manager->sell_conditional($calc, $sys_manager->get_name, $price);
58 $pf_manager->submit_order_in_position($position, $order, $i, $calc);
59 $position->set_no_intent_to_close;
60
61 return;
62 }
63  
64 sub manage_short_position {
65 my ($self, $calc, $i, $position, $pf_manager, $sys_manager) = @_;
66  
67 return 0 if (! $self->check_dependencies($calc, $i));
68  
69 my $price = $self->{'args'}->get_arg_values($calc, $i, 2);
70 my $order = $pf_manager->buy_conditional($calc, $sys_manager->get_name, $price);
71 $pf_manager->submit_order_in_position($position, $order, $i, $calc);
72 $position->set_no_intent_to_close;
73
74 return;
75 }
76  
77 1;