Quant::Framework::TradingCalendar
This module is responsible about everything related to time-based status of an exchange (whether exchange is open/closed, has holiday, is partially open, ...) Plus all related helper modules (trading days between two days where exchange is open, trading breaks, DST effect, open/close time, ...). One important feature of this module is that it is designed for READING information not writing.
my $calendar = Quant::Framework::TradingCalendar->new({ symbol => 'LSE', chronicle_reader => $chronicle_r, });
The standard symbol used to reference this exchange
UnderlyingConfig used for query on weighting of an underlying. Not required if this modules is not used for that purpose.
Used to work with Chronicle storage data (Holidays and Partial trading data)
for_date is to for historical search of holiday information
The hashref mapping of the days_since_epoch of all the holidays to their descriptions or weights. If the weight is non-zero, the exchange still trades on that day.
These are holidays defined by us. During this period, market is still open but less volatile.
An exchange's trading day category. The list is enumerated in the exchanges_trading_days_aliases.yml file.
List the trading day index which defined on exchanges_trading_days_aliases.yml
The timezone in which the exchange conducts business.
This should be a string which will allow the standard DateTime modules to find the proper information.
Internal method to pre-process construction arguments
Returns the weight assigned to the day of a given Date::Utility object. Return 0 if the exchange does not trade on this day and 1 if there is no pseudo-holiday.
Returns true if the exchange has a holiday on the day of a given Date::Utility object.
Returns true if trading is done on the day of a given Date::Utility.
Returns a Date::Utility for the date on which trading is open after the given Date::Utility
The date on which trading is considered to be taking place even if it is not the same as the GMT date.
Returns a Date object representing midnight GMT of the trading date.
Note that this does not handle trading dates are offset forward beyond the next day (24h). It will need additional work if these are found to exist.
Returns the number of calendar days between a given Date::Utility and the next day on which trading is open.
Returns a Date::Utility representing the trading day before a given Date::Utility
If given the additional arg 'lookback', will look back X number of trading days, rather than just one.
Returns the number of trading days _between_ two given dates.
$exchange->trading_days_between(Date::Utility->new('4-May-10'),Date::Utility->new('5-May-10'));
Returns the number of holidays _between_ two given dates.
Quant::Framework::TradingCalendar can be questioned about various things related to opening/closing. The following shows all these questions via code examples:
if ($self->is_open)
if ($self->is_open_at($epoch))
if ($self->will_open)
if ($self->will_open_after($epoch))
my $seconds = $self->seconds_since_open_at($epoch);
my $seconds = $self->seconds_since_close_at($epoch);
The following methods tell us when the exchange opens/closes on a given date.
Returns the opening time (Date::Utility) of the exchange for a given Date::Utility.
my $opening_epoch = $exchange->opening_on(Date::Utility->new('25-Dec-10')); # returns undef (given Xmas is a holiday)
Similar to opening_on.
my $closing_epoch = $exchange->closing_on(Date::Utility->new('25-Dec-10')); # returns undef (given Xmas is a holiday)
This is used to fetch regular non dst closing time for an exchange.
my $settlement_epoch = $exchange->settlement_on(Date::Utility->new('25-Dec-10')); # returns undef (given Xmas is a holiday)
Defines the breaktime for this exchange.
Given an epoch returns true if exchange in in break time
Returns true if the exchange closes early on the given date.
Returns true if the exchange opens late on the given date.
Boolean which indicates if the exchange is trading in its normal hours on a given Date::Utility
Does this Exchange always shift from regular trading hours on Dates "like" the provided Date?
Is this exchange trading on daylight savings times for the given epoch?
Get total number of seconds of trading time between two epochs accounting for breaks.
Tells whether the exchange's opening times change due to daylight savings at some point in the year.
Syntatic sugar to easily identify if the exchange is closed(already closed for the day or holiday or weekend). We are not expecting any more activity in this exchange for today.
Returns the last_trading_period as { begin => ..., end => ... }
a trading day that has no late open or early close
Given an epoch returns the period of trading of the exchange in that day
Returns the sum of the weights we apply to each day in the requested period.
Returns the weight for a given day (given as a Date::Utility object). Returns our closed weight for days when the market is closed.
Weights assigned for days when the markets are closed, based on empirical study and industry standards.
To install Quant::Framework, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Quant::Framework
CPAN shell
perl -MCPAN -e shell install Quant::Framework
For more information on module installation, please visit the detailed CPAN module installation guide.