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

[GT] package Finance::GeniusTrader::DateTime::Day;



Hi all,

I tried to load a time series where the start date is before 1960-12-31, but I always get the 
following error:

my time series:

1960-01-25,56.78,56.78,56.78,56.78,2790000,56.78
1960-01-22,57.38,57.38,57.38,57.38,2690000,57.38
1960-01-21,57.21,57.21,57.21,57.21,2700000,57.21
1960-01-20,57.07,57.07,57.07,57.07,2720000,57.07
1960-01-19,57.27,57.27,57.27,57.27,3100000,57.27
1960-01-18,57.89,57.89,57.89,57.89,3020000,57.89
1960-01-15,58.38,58.38,58.38,58.38,3400000,58.38
1960-01-14,58.40,58.40,58.40,58.40,3560000,58.40
1960-01-13,58.08,58.08,58.08,58.08,3470000,58.08
1960-01-12,58.41,58.41,58.41,58.41,3760000,58.41
1960-01-11,58.77,58.77,58.77,58.77,3470000,58.77
1960-01-08,59.50,59.50,59.50,59.50,3290000,59.50
1960-01-07,59.69,59.69,59.69,59.69,3310000,59.69
1960-01-06,60.13,60.13,60.13,60.13,3730000,60.13
1960-01-05,60.39,60.39,60.39,60.39,3710000,60.39
1960-01-04,59.91,59.91,59.91,59.91,3990000,59.91
1959-12-31,59.89,59.89,59.89,59.89,3810000,59.89


$HOME/eclipse-workspace/geniustrader/script/graphic.pl --file $HOME/eclipse-
workspace/geniustrader/own-scripts/graphic/graphic_examples.conf ^GSPC > foobar.png
Day too big - 32871 > 24853
Cannot handle date (0, 0, 0, 31, 11, 2059) at /home/josef/cpan/Finance/GeniusTrader/DateTime/Day.pm 
line 24


When I remove the last line in my time series it worked, so I looked in 
Finance::GeniusTrader::DateTime::Day and took a look to the function timelocal from Time::Local.

I wrote a small script time-date-test.pl. It should test all dates from 1900-01-01 to 2039-01-01, 
but it fails from 1938-01-17.

#!/usr/bin/perl

use warnings;
use strict;
use Time::Local;
use Date::Calc qw( Delta_Days Add_Delta_Days );

# sub from package Finance::GeniusTrader::DateTime::Day;
sub map_date_to_time {
    my ($date) = @_;
    my ($y, $m, $d) = split /-/, $date;
                ($d) = split / /, $d;
                print $d . "," . ($m - 1) . "," . ($y - 1900) . "\n";
    print timelocal(0, 0, 0, $d, $m - 1, $y - 1900) . "\n";
}



my @start = (1900,1,1);
my @stop  = (2039,01,01);

my $j = Delta_Days(@start,@stop);

for (my $i = 0; $i <= $j; $i++ )
{
    my ($year,$month,$day) = Add_Delta_Days(@start,$i);
    printf("%4d/%02d/%02d\n", $year,$month,$day);
    &map_date_to_time("$year-$month-$day");
}


So what is timelocal doing?


Best regards
Josef

Attachment: time-date-test.pl
Description: Perl program