Skip to main content

Module calendars

Module calendars 

Expand description

The date substrate a Python caller names directly: calendars, schedules, day counts, tenors and the roll families.

Every other module here marshals a market concept — a curve, a trade, a measure. This one marshals the layer beneath them, the one a caller reaches for without reaching for a market at all: which days a centre is open, what T+2 lands on, where a schedule’s boundaries fall.

Two rules shape it. Nothing here computes: every date returned is a date the core produced, so a schedule built here is the schedule an instrument would have accrued on. And nothing here restates a vocabulary: every string argument is parsed by the core’s own FromStr, and the rejection a caller reads is the core’s own message naming the core’s own accepted set. A list typed out on this side could disagree with the parser, and eventually would.

Structs§

PyCalendar 🔒
A business-day calendar, resolved from a lookup expression.
PyDayCountFraction 🔒
A day-count convention, named once and measured with repeatedly.
PyFrequency 🔒
A coupon frequency: one of the named members, or a period a caller spells (Frequency("28D") for the 28-day markets).
PyMeetingSchedule
A central bank’s schedule: its published decision days, with the date each decision takes effect derived by the bank’s rule — the Fed the next business day, the ECB the following Wednesday, the Bank of England the decision day. Pinned on a market with MarketContext.with_meetings, so a policy window opened on an effective date carries its decision’s name; seeded(bank) is the embedded 2026 schedule the market uses where none is pinned.
PyPeriod
A tenor: a signed count of days, weeks, months or years, or the whole term.
PyRollConvention 🔒
Where a period boundary sits inside its month: one of the named members, or a day of the month from RollConvention.day(n).
PySchedule 🔒
A generated set of calculation-period boundary dates.
Tenor 🔒
A tenor argument: a PyPeriod or its spelling.

Enums§

CalendarTenor 🔒
A tenor a calendar can step: a Period, or "<n>B" business days — the unit only a calendar resolves, so it is not a Period.
PyBusinessDayConvention 🔒
How a non-business date rolls to a business date.
PyJointCalendarRule 🔒
How a joint calendar combines its members: JoinHolidays (a holiday in any member is a holiday) or JoinBusinessDays (a business day in any member is a business day).

Functions§

__pyfunction_add_period 🔒 ⚠
__pyfunction_cds_standard_maturity 🔒 ⚠
__pyfunction_cds_standard_maturity_months 🔒 ⚠
__pyfunction_forward_tenor 🔒 ⚠
__pyfunction_imm_code_of 🔒 ⚠
__pyfunction_imm_code_to_dates 🔒 ⚠
__pyfunction_imm_date 🔒 ⚠
__pyfunction_is_imm_date 🔒 ⚠
__pyfunction_last_day_of_month 🔒 ⚠
__pyfunction_meeting_dates 🔒 ⚠
__pyfunction_next_cds_imm_date 🔒 ⚠
__pyfunction_next_imm_date 🔒 ⚠
__pyfunction_next_weekday 🔒 ⚠
__pyfunction_nth_weekday 🔒 ⚠
__pyfunction_prior_cds_imm_date 🔒 ⚠
__pyfunction_prior_imm_date 🔒 ⚠
__pyfunction_roll 🔒 ⚠
__pyfunction_schedule 🔒 ⚠
__pyfunction_tenor 🔒 ⚠
__pyfunction_turn_dates 🔒 ⚠
add_period 🔒
Adds a tenor to a date by calendar arithmetic — no calendar, no adjustment. Month and year steps clamp into short months (31 Jan + 1M = 28 Feb).
cds_standard_maturity 🔒
The CDS2015 standard maturity tenor_years out from date.
cds_standard_maturity_months 🔒
The CDS2015 standard maturity months out from date — the sub-annual form, which the whole-year one is a case of.
cds_tenor 🔒
Refuses a CDS tenor the core asserts against: none, or past 200 years.
day_count_spelling 🔒
The typed spelling of a day count, for a repr that reads back: DayCountFraction.ActActIcma.
forward_tenor 🔒
A forward tenor split into its segments, each in canonical spelling: the forward start, or None for a term from spot, and the tenor. "2y2y" is ("2Y", "2Y"); "10Y" is (None, "10Y"). Three segments are refused.
frequency_spelling 🔒
The typed spelling of a frequency, for a repr that reads back: Frequency.SemiAnnual, or Frequency("28D") where no member names it.
imm_code_of 🔒
The IMM code naming date ("JUN27"), or None where date is not a third Wednesday or its year is outside the 2000–2099 window a two-digit code can spell.
imm_code_to_dates 🔒
The unadjusted (start, end) reference period an IMM code names — the inverse of imm_code_of, which renders the end.
imm_date 🔒
The IBOR-IMM date of month in year, the third Wednesday. A month outside cycle raises ValueError. day is "ThirdWednesday" or "WednesdayOnOrAfterNinth", the first Wednesday on or after the 9th.
is_imm_date 🔒
Whether date is an IBOR-IMM date — the third Wednesday of a cycle month. The quarterly cycle admits only March, June, September and December.
last_day_of_month 🔒
The last calendar day of date’s month, blind to weekends and holidays. The business month end is Calendar.end_of_month.
meeting_dates 🔒
The dates bank’s policy decisions take effect between start and end inclusive — the dates a step curve’s meeting knots land on — from the given schedule or the seeded one ("FED", "ECB", "BOE").
next_cds_imm_date 🔒
The next CDS-IMM date strictly after date — the 20th of the next March, June, September or December; a CDS-IMM date rolls to the following one. A calendar date, never adjusted.
next_imm_date 🔒
The next IBOR-IMM date strictly after date: an IMM date rolls to the following one.
next_weekday 🔒
The first weekday on or after date. Calendar-blind: may be a holiday.
nth_weekday 🔒
The nth weekday in a month, counting from one. None where the month holds no such day — most months have four of each weekday and some five.
prior_cds_imm_date 🔒
The prior CDS-IMM date strictly before date: a CDS-IMM date rolls to the preceding one.
prior_imm_date 🔒
The prior IBOR-IMM date strictly before date: an IMM date rolls to the preceding one.
representable 🔒
date, or a ValueError where it falls outside the years 1 to 9999 that datetime.date holds — returned as it is, the conversion would panic.
roll 🔒
Snaps date to the day of the month a roll convention names, staying inside date’s own month. A day-of-month roll clamps: 31 in February lands on the 28th or 29th.
schedule 🔒
Generates a calculation-period schedule.
tenor 🔒
Normalizes a tenor to its canonical spelling ("12M" stays "12M"; "1Y" stays "1Y" — the unit is part of the tenor, not a quantity to convert away).
turn_dates 🔒
The turn-of-period dates after start and up to end: every 31 December for "YearEnd", every quarter end for "QuarterEnd" — the dates a step curve’s turn knots land on.
weekmask_of 🔒
The weekend mask weekend names — days parsed by the core’s own day-of-week vocabulary — Saturday and Sunday where it names none.
word 🔒
Parses one word of a core vocabulary, forwarding the core’s rejection.

Type Aliases§

DayCount 🔒
A day count as a Python caller names it: a spelling, or a value in hand.