GeniusTrader/CloseStrategy/OppositeSignal.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 40 CC 3 SCAR 13.3
CC
3
Cov
0%
manage_long_position
6.0
manage_short_position
6.0
long_position_opened
2.0
CRAP 3.8
1 package Finance::GeniusTrader::CloseStrategy::OppositeSignal;
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);
11  
12 use Finance::GeniusTrader::CloseStrategy;
13  
14 @ISA = qw(Finance::GeniusTrader::CloseStrategy);
15 @NAMES = ("OppositeSignal");
16  
17 =head1 Finance::GeniusTrader::CloseStrategy::OppositeSignal
18  
19 This strategy closes the position once the opposite signal has been emitted
20 by the system. It will will close a long position on a sell signal and
21 close a short position on a buy signal.
22  
23 =cut
24  
25 sub long_position_opened {
26 my ($self, $calc, $i, $position, $pf_manager, $sys_manager) = @_;
27  
28 return;
29 }
30  
31 sub short_position_opened {
32 my ($self, $calc, $i, $position, $pf_manager, $sys_manager) = @_;
33  
34 return;
35 }
36  
37 sub manage_long_position {
38 my ($self, $calc, $i, $position, $pf_manager, $sys_manager) = @_;
39  
40 if ($sys_manager->system->short_signal($calc, $i))
41 {
42 my $order = $pf_manager->sell_market_price($calc,
43 $sys_manager->get_name);
44 $pf_manager->submit_order_in_position($position, $order, $i, $calc);
45 }
46
47 return;
48 }
49  
50 sub manage_short_position {
51 my ($self, $calc, $i, $position, $pf_manager, $sys_manager) = @_;
52
53 if ($sys_manager->system->long_signal($calc, $i))
54 {
55 my $order = $pf_manager->buy_market_price($calc,
56 $sys_manager->get_name);
57 $pf_manager->submit_order_in_position($position, $order, $i, $calc);
58 }
59
60 return;
61 }
62