GeniusTrader/DateTime/Day.pm

filter: Statementstmt 50.0% 13 / 26 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 3 totaltotal 36.9% 17 / 46 CC 6 SCAR 30.8
CC
6
Cov
36%
timeframe_ratio
42.0
map_date_to_time
2.0
map_time_to_date
2.0
CRAP 21.7
« GeniusTrader/Indicators/DMI.pm ↑ Summary GeniusTrader/DateTime/Hour.pm »
1 package Finance::GeniusTrader::DateTime::Day;
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 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use vars qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Finance::GeniusTrader::DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 #ALL# use Log::Log4perl qw(:easy);
12 1 ▶use Time::Local;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 =head1 Finance::GeniusTrader::DateTime::Day
15  
16 This module treat dates describing a day. They have the following format :
17 YYYY-MM-DD
18  
19 =cut
20 0 ▶sub map_date_to_time {
Subroutine map_date_to_time: not called CC=1 SCAR=6.9
Pod undocumented
21 0 my ($date) = @_;
22 0 my ($y, $m, $d) = split /-/, $date;
23 0 ($d) = split / /, $d;
24 0 return timelocal(0, 0, 0, $d, $m - 1, $y - 1900);
25 }
26  
27 0 ▶sub map_time_to_date {
Subroutine map_time_to_date: not called CC=1 SCAR=6.9
Pod undocumented
28 0 my ($time) = @_;
29 0 my ($sec, $min, $hour, $d, $m, $y, $wd, $yd) = localtime($time);
30 0 return sprintf("%04d-%02d-%02d", $y + 1900, $m + 1, $d);
31 }
32  
33 0 ▶sub timeframe_ratio {
Subroutine timeframe_ratio: not called CC=6 SCAR=37.4
Pod undocumented
34 0 my ($tf) = @_;
35  
36 #WAR# WARN "timeframe must be smaller than a day" unless ($tf < $DAY);
37  
38 0 ▶ $tf == $PERIOD_1MIN && return 8 * 60; # 8 hours approximatively
Branch: 1 branch
BranchTrueFalseTotal
$tf == $Finance::GeniusTrader::DateTime::Day::PERIOD_1MIN and return 480 0 0 0
39 0 ▶ $tf == $PERIOD_5MIN && return 8 * 12;
Branch: 1 branch
BranchTrueFalseTotal
$tf == $Finance::GeniusTrader::DateTime::Day::PERIOD_5MIN and return 96 0 0 0
40 0 ▶ $tf == $PERIOD_10MIN && return 8 * 6;
Branch: 1 branch
BranchTrueFalseTotal
$tf == $Finance::GeniusTrader::DateTime::Day::PERIOD_10MIN and return 48 0 0 0
41 0 ▶ $tf == $PERIOD_30MIN && return 8 * 2;
Branch: 1 branch
BranchTrueFalseTotal
$tf == $Finance::GeniusTrader::DateTime::Day::PERIOD_30MIN and return 16 0 0 0
42 0 ▶ $tf == $HOUR && return 8;
Branch: 1 branch
BranchTrueFalseTotal
$tf == $Finance::GeniusTrader::DateTime::Day::HOUR and return 8 0 0 0
43 }
44  
45 1 1;
« GeniusTrader/Indicators/DMI.pm ↑ Summary GeniusTrader/DateTime/Hour.pm »