| 1 | package Finance::GeniusTrader::Systems::AlwaysInTheMarket; | ||
| 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 @NAMES); | ||
| 9 | |||
| 10 | use Finance::GeniusTrader::Systems; | ||
| 11 | |||
| 12 | @ISA = qw(Finance::GeniusTrader::Systems); | ||
| 13 | @NAMES = ("AlwaysInTheMarket"); | ||
| 14 | |||
| 15 | =head1 AlwaysInTheMarket Trading System | ||
| 16 | |||
| 17 | =head2 Overview | ||
| 18 | |||
| 19 | This system will generate every time it is called a long and a short signal. | ||
| 20 | |||
| 21 | =head2 Examples | ||
| 22 | |||
| 23 | To set up a Buy And Hold strategy : | ||
| 24 | SY:AlwaysInTheMarket|CS:NeverClose|TF:LongOnly|TF:OneTrade | ||
| 25 | |||
| 26 | To set up a Short And Hold strategy : | ||
| 27 | SY:AlwaysInTheMarket|CS:NeverClose|TF:ShortOnly|TF:OneTrade | ||
| 28 | |||
| 29 | =head2 Note | ||
| 30 | |||
| 31 | In which way is a BuyAndHold or a ShortAndHold system usefull ? | ||
| 32 | |||
| 33 | The main purpose is to run the system on a list of securities, in order to | ||
| 34 | get the portfolio performance. Let's try to catch indices performance with | ||
| 35 | just a few stocks and beat the market only with money-management ! Welcome | ||
| 36 | to the world of portfolio selection and portfolio optimization. | ||
| 37 | |||
| 38 | =cut | ||
| 39 | |||
| 40 | sub new { | ||
| 41 | my $type = shift; | ||
| 42 | my $class = ref($type) || $type; | ||
| 43 | my $args = shift; | ||
| 44 | |||
| 45 | my $self = { "args" => defined($args) ? $args : [] }; | ||
| 46 | |||
| 47 | return manage_object(\@NAMES, $self, $class, $self->{'args'}, ""); | ||
| 48 | } | ||
| 49 | |||
| 50 | sub long_signal { | ||
| 51 | my ($self, $calc, $i) = @_; | ||
| 52 | |||
| 53 | return 1; | ||
| 54 | } | ||
| 55 | |||
| 56 | sub short_signal { | ||
| 57 | my ($self, $calc, $i) = @_; | ||
| 58 | |||
| 59 | return 1; | ||
| 60 | } | ||
| 61 | |||
| 62 | 1; |