GeniusTrader/OrderFactory.pm untested

filter: Statementstmt 0.0% 0 / 53 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 86 CC 4 SCAR 18.3
CC
4
Cov
0%
new
20.0
create_buy_order
2.0
create_sell_order
2.0
CRAP 6.2
1 package Finance::GeniusTrader::OrderFactory;
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 @EXPORT %OBJECT_REPOSITORY);
9  
10 require Exporter;
11 @ISA = qw(Exporter Finance::GeniusTrader::Dependency);
12 @EXPORT = qw(&build_object_name &manage_object);
13  
14 use Finance::GeniusTrader::Registry;
15 use Finance::GeniusTrader::Dependency;
16 #ALL# use Log::Log4perl qw(:easy);
17  
18 =head1 NAME
19  
20 Finance::GeniusTrader::OrderFactory - Create orders
21  
22 An OrderFactory is used to create an order when a system has detected an
23 opportunity. This order will then be sent to the PortfolioManager by
24 the SystemManager.
25  
26 =cut
27  
28 sub new {
29 my ($type, $args, $key) = @_;
30 my $class = ref($type) || $type;
31
32 no strict "refs";
33
34 my $self = { };
35 if (defined($args)) {
36 if ( $#{$args} < $#{"$class\::DEFAULT_ARGS"} ) {
37 for (my $n=($#{$args}+1); $n<=$#{"$class\::DEFAULT_ARGS"}; $n++) {
38 push @{$args}, ${"$class\::DEFAULT_ARGS"}[$n];
39 }
40 }
41 $self->{'args'} = Finance::GeniusTrader::ArgsTree->new(@{$args});
42 } elsif (defined (@{"$class\::DEFAULT_ARGS"})) {
43 $self->{'args'} = Finance::GeniusTrader::ArgsTree->new(@{"$class\::DEFAULT_ARGS"});
44 } else {
45 $self->{'args'} = Finance::GeniusTrader::ArgsTree->new(); # no args
46 }
47
48 return manage_object(\@{"$class\::NAMES"}, $self, $class, $self->{'args'}, $key);
49 }
50  
51 =over
52  
53 =item C<< $of->create_buy_order($calc, $i, $sys_manager, $pf_manager) >>
54  
55 =item C<< $of->create_sell_order($calc, $i, $sys_manager, $pf_manager) >>
56  
57 Those functions are called by the systems to launch an order. The
58 SystemManager delegates this to an Order object. It will
59 use the Order object given by set_default_order() or it will
60 fallback to the order suggested by the system.
61  
62 =cut
63 sub create_buy_order {
64 my ($self, $calc, $i, $sys_manager, $pf_manager) = @_;
65  
66 return;
67 }
68  
69 sub create_sell_order {
70 my ($self, $calc, $i, $sys_manager, $pf_manager) = @_;
71  
72 return;
73 }
74  
75 # Default initialize that does nothing
76 sub initialize { 1 }
77  
78 # Finance::GeniusTrader::Registry functions
79 sub get_registered_object {
80 Finance::GeniusTrader::Registry::get_registered_object(\%OBJECT_REPOSITORY, @_);
81 }
82 sub register_object {
83 Finance::GeniusTrader::Registry::register_object(\%OBJECT_REPOSITORY, @_);
84 }
85 sub get_or_register_object {
86 Finance::GeniusTrader::Registry::get_or_register_object(\%OBJECT_REPOSITORY, @_);
87 }
88 sub manage_object {
89 Finance::GeniusTrader::Registry::manage_object(\%OBJECT_REPOSITORY, @_);
90 }
91  
92 =pod
93  
94 =back
95  
96 =cut
97 1;