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.
- PyDay
Count 🔒Fraction - 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). - PyMeeting
Schedule - 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.
- PyRoll
Convention 🔒 - 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
PyPeriodor its spelling.
Enums§
- Calendar
Tenor 🔒 - A tenor a calendar can step: a
Period, or"<n>B"business days — the unit only a calendar resolves, so it is not aPeriod. - PyBusiness
DayConvention 🔒 - How a non-business date rolls to a business date.
- PyJoint
Calendar 🔒Rule - How a joint calendar combines its members:
JoinHolidays(a holiday in any member is a holiday) orJoinBusinessDays(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_yearsout fromdate. - cds_
standard_ 🔒maturity_ months - The CDS2015 standard maturity
monthsout fromdate— 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
Nonefor 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, orFrequency("28D")where no member names it. - imm_
code_ 🔒of - The IMM code naming
date("JUN27"), orNonewheredateis 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 ofimm_code_of, which renders theend. - imm_
date 🔒 - The IBOR-IMM date of
monthinyear, the third Wednesday. A month outsidecycleraisesValueError.dayis"ThirdWednesday"or"WednesdayOnOrAfterNinth", the first Wednesday on or after the 9th. - is_
imm_ 🔒date - Whether
dateis 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 isCalendar.end_of_month. - meeting_
dates 🔒 - The dates
bank’s policy decisions take effect betweenstartandendinclusive — 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
weekdayon or afterdate. Calendar-blind: may be a holiday. - nth_
weekday 🔒 - The
nthweekdayin a month, counting from one.Nonewhere 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 aValueErrorwhere it falls outside the years 1 to 9999 thatdatetime.dateholds — returned as it is, the conversion would panic.- roll 🔒
- Snaps
dateto the day of the month a roll convention names, staying insidedate’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
startand up toend: 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
weekendnames — 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.