GeniusTrader/MoneyManagement/Portfolio/OneCode.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 59 CC 5 SCAR 19.5
CC
5
Cov
0%
new
12.0
manage_quantity
12.0
BEGIN
2.0
CRAP 7.0
1 package Finance::GeniusTrader::MoneyManagement::Portfolio::OneCode;
2  
3 # Copyright 2004 Oliver Bossert
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(@NAMES @ISA);
9  
10 use Finance::GeniusTrader::MoneyManagement;
11 use Finance::GeniusTrader::Prices;
12 use Finance::GeniusTrader::Analyzers::Process;
13 use Finance::GeniusTrader::Eval;
14  
15 @NAMES = ("PF:OneCode[#1]");
16 @ISA = qw(Finance::GeniusTrader::MoneyManagement);
17  
18 =head1 Finance::GeniusTrader::MoneyManagement::Basic
19  
20 Basic and dumb money management rules (ie no rules).
21  
22 =cut
23  
24 sub new {
25 my $type = shift;
26 my $class = ref($type) || $type;
27 my $args = shift;
28
29 my $self = { 'args' => defined($args) ? $args : [ 10 ] };
30
31 $args->[0] = 100 if (! defined($args->[0]));
32  
33 return manage_object(\@NAMES, $self, $class, $self->{'args'}, '');
34 }
35  
36  
37 sub manage_quantity {
38 my ($self, $order, $i, $calc, $portfolio) = @_;
39  
40 foreach my $position ($portfolio->list_open_positions)
41 {
42 if ($position->code() eq $calc->code())
43 {
44 return 0;
45 }
46 }
47  
48  
49 if ( defined($order->{'quantity'}) )
50 {
51 print STDERR "Module OneCode returns: " . $order->{'quantity'} . "\n";
52 return $order->{'quantity'};
53 } else {
54 return 0;
55 }
56  
57 return 0;
58  
59 }
60  
61  
62 1;