Module imm
Expand description
IMM and CDS-IMM date generation — pure Gregorian date arithmetic.
Two distinct conventions live here:
- IBOR-IMM dates (
imm_code_to_dates): the third Wednesday of the cycle month. An IMM code such as"JUN27"resolves to the unadjusted(start, end)reference window of the IMM-cycled future it names, which starts on the coded date. - CDS-IMM dates (
next_cds_imm_date/cds_standard_maturity): the 20th of March / June / September / December (calendar dates, never business-day-adjusted), per the ISDA 2014 CDS Standard Maturity convention.
These are pure functions — no calendar, no holiday math. Callers apply their own business-day adjustment downstream.
Structs§
- ImmCode
Error - Error resolving an IMM code.
Enums§
- ImmCycle
- The IMM reference-period cycle for
imm_code_to_dates. - ImmDay
- Which day of a cycle month an IMM date is: the third Wednesday, or the first Wednesday on or after the 9th, the New Zealand bank bill roll (a Wednesday 9th is the date itself). The NZ bank bill exchange’s own wording for the second rule was not checked against a primary source.
Constants§
- FUTURES_
MONTH_ 🔒LETTERS - The exchanges’ futures month letters, January first:
"H22"is March 2022. - MONTH_
CODES 🔒 - The three-letter month codes an IMM code is written in, indexed by month - 1.
Functions§
- cds_
imm_ 🔒date_ on_ or_ after - The first CDS-IMM date on or after
today—todayitself when it is one. The inclusive rule, for an anchor that may be a CDS-IMM date. - cds_
imm_ 🔒date_ on_ or_ before - The most recent CDS-IMM date on or before
today—todayitself when it is one: the anchor a CDS2015 schedule accrues from. - cds_
standard_ maturity - The CDS2015 standard maturity for a
tenor_years-year CDS traded ontoday. - cds_
standard_ maturity_ months cds_standard_maturityover a tenor in months, so sub-annual quotes (a 6M point) pin their own pillar.- imm_
code_ of - The IMM code (
"JUN27") namingdate, the inverse ofimm_code_to_dates’s reference-period start. - imm_
code_ to_ dates - Resolves an IMM code (three-letter month + two-digit year, e.g.
"JUN27") to its unadjusted(start, end)reference-period dates: the period of the futures contract the code names, as aFutureTemplate’s reference period read it. - imm_
date - The IBOR-IMM date of
monthinyear— the third Wednesday — orNonewheremonthis outsidecycleor not a month. - imm_
date_ on - The IMM date of
monthinyearundercycle, on the daydaynames;Nonefor a month outside the cycle. - imm_
date_ 🔒on_ or_ after - The first IBOR-IMM date on or after
dateundercycle—dateitself when it is one. The inclusive rule, for an anchor that may be an IMM date. - imm_
date_ 🔒on_ or_ before - The last IBOR-IMM date on or before
dateundercycle—dateitself when it is one. - is_
cycle_ 🔒month - Whether
monthis a cycle month undercycle: any month for the monthly cycle, and only March / June / September / December for the quarterly one. - is_
imm_ date - Whether
dateis an IBOR-IMM date undercycle— the third Wednesday of a cycle month. - next_
cds_ imm_ date - The next CDS-IMM date strictly after
today— the 20th of the next March / June / September / December (calendar date, not business-day adjusted). A CDS-IMM date rolls to the following one, asnext_semi_annual_roll_datedoes. - next_
cycle_ 🔒month - Previous-IMM
(year, month)undercycle. - next_
imm_ date - The next IBOR-IMM date strictly after
dateundercycle: an IMM date rolls to the following one. - next_
semi_ annual_ roll_ date - The next semi-annual CDS roll date — the 20th of the next March or September.
- preceding_
standard_ 🔒maturity - The standard CDS maturity — a 20-Jun or 20-Dec — on or before
date. - prior_
cds_ imm_ date - The prior CDS-IMM date strictly before
today: a CDS-IMM date rolls to the preceding one. - prior_
imm_ date - The prior IBOR-IMM date strictly before
dateundercycle: an IMM date rolls to the preceding one. - third_
wednesday 🔒 - Third Wednesday of
(year, month).Noneonly if(year, month)is invalid.