NamedCal#

class rateslib.scheduling.NamedCal(name)#

Bases: object

A wrapped UnionCal constructed with a string parsing syntax.

Parameters:

name (str) – The names of the calendars to populate the calendars and settlement_calendars arguments of a UnionCal. The individual calendar names must pre-exist in the defaults. The pipe operator separates the two fields.

Examples

In [1]: named_cal = NamedCal("ldn,tgt|fed")

In [2]: assert len(named_cal.union_cal.calendars) == 2

In [3]: assert len(named_cal.union_cal.settlement_calendars) == 1

Attributes Summary

holidays

A list of specifically provided non-business days.

name

The string identifier for this constructed calendar.

union_cal

The wrapped UnionCal object.

week_mask

A list of days in the week defined as weekends.

Methods Summary

add_bus_days(date, days, settlement)

Return a business date separated by days from an input business date.

add_cal_days(date, days, adjuster)

Return a date separated by calendar days from input date, and rolled with a modifier.

add_months(date, months, adjuster, roll)

Return a date separated by months from an input date, and rolled with a modifier.

adjust(date, adjuster)

Adjust a non-business date to a business date under a specific modification rule.

adjusts(dates, adjuster)

Adjust a list of dates under a date adjustment rule.

bus_date_range(start, end)

Return a list of business dates in a range.

cal_date_range(start, end)

Return a list of calendar dates in a range.

is_bus_day(date)

Return whether the date is a business day.

is_non_bus_day(date)

Return whether the date is not a business day.

is_settlement(date)

Return whether the date is a business day in an associated settlement calendar.

lag_bus_days(date, days, settlement)

Adjust a date by a number of business days, under lag rules.

roll(date, modifier, settlement)

Roll a date under a simplified adjustment rule.

to_json()

Return a JSON representation of the object.

Attributes Documentation

holidays#

A list of specifically provided non-business days.

name#

The string identifier for this constructed calendar.

union_cal#

The wrapped UnionCal object.

week_mask#

A list of days in the week defined as weekends.

Methods Documentation

add_bus_days(date, days, settlement)#

Return a business date separated by days from an input business date.

See Cal.add_bus_days.

add_cal_days(date, days, adjuster)#

Return a date separated by calendar days from input date, and rolled with a modifier.

See Cal.add_cal_days.

add_months(date, months, adjuster, roll)#

Return a date separated by months from an input date, and rolled with a modifier.

See Cal.add_months.

adjust(date, adjuster)#

Adjust a non-business date to a business date under a specific modification rule.

See Cal.adjust.

adjusts(dates, adjuster)#

Adjust a list of dates under a date adjustment rule.

See Cal.adjusts.

bus_date_range(start, end)#

Return a list of business dates in a range.

See Cal.bus_date_range.

cal_date_range(start, end)#

Return a list of calendar dates in a range.

See Cal.cal_date_range.

is_bus_day(date)#

Return whether the date is a business day.

See Cal.is_bus_day.

is_non_bus_day(date)#

Return whether the date is not a business day.

See Cal.is_non_bus_day.

is_settlement(date)#

Return whether the date is a business day in an associated settlement calendar.

If no such associated settlement calendar exists this will return True.

See Cal.is_settlement.

lag_bus_days(date, days, settlement)#

Adjust a date by a number of business days, under lag rules.

See Cal.lag_bus_days.

roll(date, modifier, settlement)#

Roll a date under a simplified adjustment rule.

See Cal.roll.

to_json()#

Return a JSON representation of the object.

Return type:

str