The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Finance::GeniusTrader::DateTime - Manage TimeFrames and provides date/time helper functions

DESCRIPTION

This module exports all the variable describing the available "periods" commonly used for trading : $PERIOD_TICK $PERIOD_1MIN, $PERIOD_5MIN, $PERIOD_10MIN, $PERIOD_15MIN, $PERIOD_30MIN, $HOUR, $PERIOD_2HOUR, $PERIOD_3HOUR, $PERIOD_4HOUR, $DAY, $WEEK, $MONTH, $YEAR.

The timeframes are represented by those variables which are only numbers. You can compare those numbers to know which timeframe is smaller or which one is bigger.

It also provides several functions to manipulate dates and periods. Those functions use modules Finance::GeniusTrader::DateTime::* to do the actual work depending on the selected timeframe.

Functions provided by submodules

map_date_to_time($date) is a function returning a time (ie a number of seconds since 1970) representing that date in the history. It is usually corresponding to the first second of the given period.

map_time_to_date($time) is the complementary function. It will return a date describing the period that includes the given time.

Functions

Finance::GeniusTrader::DateTime::map_date_to_time($timeframe, $date)
Finance::GeniusTrader::DateTime::map_time_to_date($timeframe, $time)

Those are the generic functions used to convert a date into a time and vice versa.

Finance::GeniusTrader::DateTime::convert_date($date, $orig_timeframe, $dest_timeframe)

This function does convert the given date from the $orig_timeframe in a date of the $dest_timeframe. Take care that the destination timeframe must be bigger than the original timeframe.

Finance::GeniusTrader::DateTime::list_of_timeframe()

Returns the list of timeframes that are managed by the DateTime framework.

Finance::GeniusTrader::DateTime::name_of_timeframe($tf)

Return the official name of the corresponding timeframe.

Finance::GeniusTrader::DateTime::name_to_timeframe($name)

Returns the timeframe associated to the given name.

Finance::GeniusTrader::DateTime::timeframe_ratio($first, $second)

Returns how many times the second timeframe fits in the first one.