| 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
| |||||||||||
| 39 | 0 | ▶ | $tf == $PERIOD_5MIN && return 8 * 12; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | ▶ | $tf == $PERIOD_10MIN && return 8 * 6; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | ▶ | $tf == $PERIOD_30MIN && return 8 * 2; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 0 | ▶ | $tf == $HOUR && return 8; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 1 | 1; | |||||||||