NamedCal#
- class rateslib.scheduling.NamedCal(name)#
Bases:
objectA wrapped
UnionCalconstructed with a string parsing syntax.- Parameters:
name (str) – The names of the calendars to populate the
calendarsandsettlement_calendarsarguments of aUnionCal. 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
A list of specifically provided non-business days.
The string identifier for this constructed calendar.
The wrapped
UnionCalobject.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.
print(year[, month])Return a string representation of a calendar under a legend.
print_compare(comparator, year)Return a string representation of a calendar compared to another.
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.
- 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.
- print(year, month=None)#
Return a string representation of a calendar under a legend.
- Parameters:
year (int) – The year of the calendar to display.
month (int, optional) – The optional month of the calendar to display.
- Return type:
str
- print_compare(comparator, year)#
Return a string representation of a calendar compared to another.
- Parameters:
- Return type:
str
Examples
The following example highlights the differences between the FED and NYC calendars in 2026.
In [1]: print(get_calendar("nyc").print_compare(get_calendar("fed"), 2026)) January 2026 April 2026 July 2026 October 2026 Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa _ _ _ _ _ [] _ _ _ [] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ February 2026 May 2026 August 2026 November 2026 Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ March 2026 June 2026 September 2026 December 2026 Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- to_json()#
Return a JSON representation of the object.
- Return type:
str