UnionCal#

class rateslib.scheduling.UnionCal(calendars, settlement_calendars=None)#

Bases: object

A calendar defined by a business day intersection of multiple Cal objects.

Parameters:
  • calendars (list[Cal]) – A list of Cal objects whose combination will define the business and non-business days.

  • settlement_calendars (list[Cal]) – A list of Cal objects whose combination will define the settleable and non-settleable days.

Attributes Summary

calendars

A list of Cal objects defining business days.

holidays

A list of specifically provided non-business days.

settlement_calendars

A list of Cal objects defining settleable days.

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.

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

calendars#

A list of Cal objects defining business days.

holidays#

A list of specifically provided non-business days.

settlement_calendars#

A list of Cal objects defining settleable days.

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:
  • comparator (Cal, UnionCal, NamedCal) – The secondary calendar to compare dates against.

  • year (int) – The year of the calendar to display.

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
 _  _  _  _  _  _  _       _  _  _  _  _  _          _  _  _  _  _          _  _  _  _  _ 
 _  _  _  _  _  _  _    _  _  _  _  _  _  _    _  _  _  _  _  _  _    _  _  _  _  _  _  _ 
 _  _  _  _  _  _  _    _  _  _  _  _  _  _    _  _  _  _  _  _  _    _  _  _  _  _  _  _ 
 _  _  _  _  _  _  _    _  _  _  _  _  _  _    _  _  _  _  _  _  _    _  _  _  _  _  _  _ 
 _  _  _                _  _  _                _  _  _  _             _  _  _  _  _       
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