[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GT] SVN Commit r650 - in branches/exp/GT: . DB Indicators



Author: joao
Date: 2008-07-24 12:04:50 +0200 (Thu, 24 Jul 2008)
New Revision: 650

Modified:
   branches/exp/GT/Calculator.pm
   branches/exp/GT/DB/genericdbi.pm
   branches/exp/GT/Indicators/EVWMA.pm
   branches/exp/GT/Indicators/FromTimeframe.pm
   branches/exp/GT/Prices.pm
Log:
Apply various patches previously sent to the mailing list in the exp branch


Modified: branches/exp/GT/Calculator.pm
===================================================================
--- branches/exp/GT/Calculator.pm	2008-07-24 09:49:17 UTC (rev 649)
+++ branches/exp/GT/Calculator.pm	2008-07-24 10:04:50 UTC (rev 650)
@@ -5,7 +5,6 @@
 # version 2 or (at your option) any later version.
 
 use GT::CacheValues;
-use GT::MetaInfo;
 
 =head1 NAME
 
@@ -14,7 +13,7 @@
 =head1 DESCRIPTION
 
 This is a facility object to ease the collaboration between GT::Prices
-and GT::CacheValues and GT::MetaInfo. It contains the prices (GT::Prices),
+and GT::CacheValues. It contains the prices (GT::Prices),
 and the result of various indicators and signals within two GT::CacheValues
 object. This object is manipulated by all the indicators, signals and
 systems.
@@ -46,10 +45,6 @@
 Return the corresponding object of the indicated timeframe. Learn
 more about the timeframes in GT::DateTime.
 
-=item C<< $c->metainfo() >>
-
-Returns the metainfo object associated to the share.
-
 =item C<< $c->set_code($code) >>
 
 Sets the code of the share which datas are stored in this object.
@@ -71,8 +66,6 @@
     $self->{'tf'}{$prices->timeframe}{'indics'} = GT::CacheValues->new;
     $self->{'tf'}{$prices->timeframe}{'signals'} = GT::CacheValues->new;
     
-    $self->{'_metainfo'} = GT::MetaInfo->new();
-    
     bless $self, $class;
     
     $self->set_current_timeframe($prices->timeframe);
@@ -91,8 +84,6 @@
 sub indicators { $_[0]->{'_indics'}  }
 sub signals    { $_[0]->{'_signals'} }
 
-sub metainfo   { $_[0]->{'_metainfo'} }
-
 sub prices_on_timeframe     { $_[0]->{'tf'}{$_[1]}{'prices'} }
 sub indicators_on_timeframe { $_[0]->{'tf'}{$_[1]}{'indics'} }
 sub signals_on_timeframe    { $_[0]->{'tf'}{$_[1]}{'signals'} }

Modified: branches/exp/GT/DB/genericdbi.pm
===================================================================
--- branches/exp/GT/DB/genericdbi.pm	2008-07-24 09:49:17 UTC (rev 649)
+++ branches/exp/GT/DB/genericdbi.pm	2008-07-24 10:04:50 UTC (rev 650)
@@ -8,9 +8,7 @@
 use vars qw(@ISA);
 
 use GT::DB;
-use GT::Prices;
 use GT::Conf;
-use GT::DateTime;
 use DBI;
 
 @ISA = qw(GT::DB);
@@ -135,7 +133,7 @@
 =cut
 sub get_last_prices {
     my ($self, $code, $limit, $timeframe) = @_;
-    $timeframe = $DAY unless ($timeframe);
+    $timeframe = $GT::DateTime::DAY unless ($timeframe);
     $limit = 99999999 if ($limit==-1);
 
     my $q = GT::Prices->new($limit);

Modified: branches/exp/GT/Indicators/EVWMA.pm
===================================================================
--- branches/exp/GT/Indicators/EVWMA.pm	2008-07-24 09:49:17 UTC (rev 649)
+++ branches/exp/GT/Indicators/EVWMA.pm	2008-07-24 10:04:50 UTC (rev 650)
@@ -16,6 +16,7 @@
 
 use GT::Indicators;
 use GT::Prices;
+use GT::MetaInfo;
 
 @ISA = qw(GT::Indicators);
 @NAMES = ("EVWMA");
@@ -69,6 +70,12 @@
 =head2 GT::Indicators::EVWMA::calculate($calc, $day)
 
 =cut
+sub initialize {
+    my ($self) = @_;
+
+    $self->{'metainfo'} = GT::MetaInfo->new();
+}
+
 sub calculate {
     my ($self, $calc, $i) = @_;
     my $getvalue = $self->{'_func'};
@@ -84,8 +91,8 @@
     return if not (-e "/bourse/metainfo/" . $calc->code . ".xml");
        
     # Find the number of floating shares
-    $calc->metainfo->load("/bourse/metainfo/" . $calc->code . ".xml");
-    my $floating_shares = $calc->metainfo->get("floating_shares");
+    $self->{'metainfo'}->load("/bourse/metainfo/" . $calc->code . ".xml");
+    my $floating_shares = $self->{'metainfo'}->get("floating_shares");
     
     for (my $n = 0; $n <= $i; $n++) {
     

Modified: branches/exp/GT/Indicators/FromTimeframe.pm
===================================================================
--- branches/exp/GT/Indicators/FromTimeframe.pm	2008-07-24 09:49:17 UTC (rev 649)
+++ branches/exp/GT/Indicators/FromTimeframe.pm	2008-07-24 10:04:50 UTC (rev 650)
@@ -17,7 +17,7 @@
 use GT::Tools qw(extract_object_number);
 
 @ISA = qw(GT::Indicators);
-
AT
NAMES = ("Prices[#*]");
+
AT
NAMES = ("FromTimeframe[#*]");
 @DEFAULT_ARGS = ("{I:Prices CLOSE}", "week", 0);
 
 =head1 NAME
@@ -54,35 +54,37 @@
 
 sub calculate {
     my ($self, $calc, $i) = @_;
+    my $code = $calc->{'code'};
     my $indic = $calc->indicators;
     my $nb = $self->{'args'}->get_arg_values($calc, $i, 3);
 
     # Initialize
-    if (!defined($self->{'special_calc'})) {
-        $self->{'special_tf'} = GT::DateTime::name_to_timeframe($self->{'args'}->get_arg_constant(2));
-        $self->{'special_prices'} = $calc->prices->convert_to_timeframe($self->{'special_tf'});
-        $self->{'special_calc'} = GT::Calculator->new($self->{'special_prices'});
-	$self->{'special_calc'}->set_code($calc->code());
+    if (!defined($self->{$code}->{'special_calc'})) {
+        $self->{$code}->{'special_tf'} = GT::DateTime::name_to_timeframe($self->{'args'}->get_arg_constant(2));
+        $self->{$code}->{'special_prices'} = $calc->prices->convert_to_timeframe($self->{$code}->{'special_tf'});
+        $self->{$code}->{'special_calc'} = GT::Calculator->new($self->{$code}->{'special_prices'});
+	$self->{$code}->{'special_calc'}->set_code($calc->code());
+    } else {
     }
 
 
     my $date = $calc->prices->at($i)->[$DATE];
     my $time = GT::DateTime::map_date_to_time($calc->prices->timeframe(), $date);
-    $date = GT::DateTime::map_time_to_date($self->{'special_tf'}, $time);
+    $date = GT::DateTime::map_time_to_date($self->{$code}->{'special_tf'}, $time);
 
-    if ($self->{'special_prices'}->has_date($date)) {
-        my $j = $self->{'special_prices'}->date($date);
+    if ($self->{$code}->{'special_prices'}->has_date($date)) {
+        my $j = $self->{$code}->{'special_prices'}->date($date);
         my $tmp = $self->{'args'}->get_arg_names(1);
         $tmp =~ s/^{|}$//g;
 
         my $args = GT::ArgsTree->new( $tmp );
         my $name_index = extract_object_number($args->get_arg_names(1));
 	    my $ob = $self->{'args'}->get_arg_object(1);
-	    $ob->calculate($self->{'special_calc'}, $j - $nb);
-	    my $res = $self->{'special_calc'}->indicators->get($ob->get_name($name_index), $j - $nb);
+	    $ob->calculate($self->{$code}->{'special_calc'}, $j - $nb);
+	    my $res = $self->{$code}->{'special_calc'}->indicators->get($ob->get_name($name_index), $j - $nb);
         $indic->set($self->get_name, $i, $res);
     }
 
 }
 
-1;
\ No newline at end of file
+1;

Modified: branches/exp/GT/Prices.pm
===================================================================
--- branches/exp/GT/Prices.pm	2008-07-24 09:49:17 UTC (rev 649)
+++ branches/exp/GT/Prices.pm	2008-07-24 10:04:50 UTC (rev 650)
@@ -10,10 +10,9 @@
 use Date::Calc qw(Decode_Date_US Decode_Date_EU Today);
 #ALL#  use Log::Log4perl qw(:easy);
 use GT::DateTime;
-use GT::Serializable;
 
 require Exporter;
-
AT
ISA = qw(Exporter GT::Serializable);
+
AT
ISA = qw(Exporter);
 @EXPORT = qw($FIRST $OPEN $HIGH $LOW $LAST $CLOSE $VOLUME $DATE);
 
 $FIRST = $OPEN = 0;