Time¶
Calendars, day counters, dates, periods and schedules.
time
¶
Runtime source shim for the native itofin.time submodule.
The real itofin.time is a compiled submodule registered into
sys.modules by the extension; it wins at import time, so nothing here
runs. This file exists only so static type checkers resolve
from itofin.time import ... from time/__init__.pyi without a
reportMissingModuleSource warning.
Auto-generated by scripts/gen_submodule_shims.py from time/__init__.pyi; do not edit or delete by hand.
Calendar
¶
A business-day calendar.
target
staticmethod
¶
target() -> Calendar
The TARGET calendar.
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The TARGET business-day calendar. |
null_calendar
staticmethod
¶
null_calendar() -> Calendar
The calendar holding no holidays at all.
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The null calendar, on which every day is a business day. |
weekends_only
staticmethod
¶
weekends_only() -> Calendar
The weekends-only calendar: Saturdays and Sundays are holidays and no other day is. The calendar the ISDA CDS conventions roll on.
It is not substitutable by the null calendar, which holds no holidays at all, nor by a national calendar, which adds public holidays.
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The weekends-only calendar. |
south_africa
staticmethod
¶
south_africa() -> Calendar
The South African calendar.
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The South African calendar. |
argentina
staticmethod
¶
argentina(market: str = 'Merval') -> Calendar
The Argentine calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"Merval", the only market; matched ignoring case. |
'Merval'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Argentine calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
australia
staticmethod
¶
australia(market: str = 'Settlement') -> Calendar
The Australian calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Settlement", "ASX"; matched ignoring case. |
'Settlement'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Australian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
austria
staticmethod
¶
austria(market: str = 'Settlement') -> Calendar
The Austrian calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Settlement", "Exchange"; matched ignoring case. |
'Settlement'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Austrian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
brazil
staticmethod
¶
brazil(market: str = 'Settlement') -> Calendar
The Brazilian calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Settlement", "Exchange"; matched ignoring case. |
'Settlement'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Brazilian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
canada
staticmethod
¶
canada(market: str = 'Settlement') -> Calendar
The Canadian calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Settlement", "TSX"; matched ignoring case. |
'Settlement'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Canadian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
chile
staticmethod
¶
chile(market: str = 'SSE') -> Calendar
The Chilean calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"SSE", the only market; matched ignoring case. |
'SSE'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Chilean calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
china
staticmethod
¶
china(market: str = 'SSE') -> Calendar
The Chinese calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "SSE", "IB"; matched ignoring case. |
'SSE'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Chinese calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
croatia
staticmethod
¶
croatia(market: str = 'ZSE') -> Calendar
The Croatian calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"ZSE", the only market; matched ignoring case. |
'ZSE'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Croatian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
czech_republic
staticmethod
¶
czech_republic(market: str = 'PSE') -> Calendar
The Czech calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"PSE", the only market; matched ignoring case. |
'PSE'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Czech calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
france
staticmethod
¶
france(market: str = 'Settlement') -> Calendar
The French calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Settlement", "Exchange"; matched ignoring case. |
'Settlement'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The French calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
germany
staticmethod
¶
germany(market: str = 'Settlement') -> Calendar
The German calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Settlement", "FrankfurtStockExchange", "Xetra", "Eurex", "Euwax"; matched ignoring case. |
'Settlement'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The German calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
hong_kong
staticmethod
¶
hong_kong(market: str = 'HKEx') -> Calendar
The Hong Kong calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"HKEx", the only market; matched ignoring case. |
'HKEx'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Hong Kong calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
iceland
staticmethod
¶
iceland(market: str = 'ICEX') -> Calendar
The Icelandic calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"ICEX", the only market; matched ignoring case. |
'ICEX'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Icelandic calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
india
staticmethod
¶
india(market: str = 'NSE') -> Calendar
The Indian calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"NSE", the only market; matched ignoring case. |
'NSE'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Indian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
indonesia
staticmethod
¶
indonesia(market: str = 'BEJ') -> Calendar
The Indonesian calendar.
Its public holidays are tabulated through 2014 only, as in QuantLib; every query on this calendar raises ItofinError for a later date rather than silently omitting holidays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "BEJ", "JSX", "IDX"; matched ignoring case. |
'BEJ'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Indonesian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
israel
staticmethod
¶
israel(market: str = 'Settlement') -> Calendar
The Israeli calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Settlement", "TASE", "SHIR", "Telbor"; matched ignoring case. |
'Settlement'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Israeli calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
italy
staticmethod
¶
italy(market: str = 'Settlement') -> Calendar
The Italian calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Settlement", "Exchange"; matched ignoring case. |
'Settlement'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Italian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
malta
staticmethod
¶
malta(market: str = 'MSE') -> Calendar
The Maltese calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"MSE", the only market; matched ignoring case. |
'MSE'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Maltese calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
mexico
staticmethod
¶
mexico(market: str = 'BMV') -> Calendar
The Mexican calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"BMV", the only market; matched ignoring case. |
'BMV'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Mexican calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
montenegro
staticmethod
¶
montenegro(market: str = 'MNSE') -> Calendar
The Montenegrin calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"MNSE", the only market; matched ignoring case. |
'MNSE'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Montenegrin calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
new_zealand
staticmethod
¶
new_zealand(market: str = 'Wellington') -> Calendar
The New Zealand calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Wellington", "Auckland"; matched ignoring case. |
'Wellington'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The New Zealand calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
north_macedonia
staticmethod
¶
north_macedonia(market: str = 'MSE') -> Calendar
The North Macedonian calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"MSE", the only market; matched ignoring case. |
'MSE'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The North Macedonian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
poland
staticmethod
¶
poland(market: str = 'Settlement') -> Calendar
The Polish calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Settlement", "WSE"; matched ignoring case. |
'Settlement'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Polish calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
romania
staticmethod
¶
romania(market: str = 'Public') -> Calendar
The Romanian calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Public", "BVB"; matched ignoring case. |
'Public'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Romanian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
russia
staticmethod
¶
russia(market: str = 'Settlement') -> Calendar
The Russian calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Settlement", "MOEX"; matched ignoring case. |
'Settlement'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Russian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
saudi_arabia
staticmethod
¶
saudi_arabia(market: str = 'Tadawul') -> Calendar
The Saudi Arabian calendar.
Its Eid holidays are tabulated through 2022 only, as in QuantLib; every query on this calendar raises ItofinError for a later date rather than silently omitting holidays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"Tadawul", the only market; matched ignoring case. |
'Tadawul'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Saudi Arabian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
serbia
staticmethod
¶
serbia(market: str = 'BSE') -> Calendar
The Serbian calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"BSE", the only market; matched ignoring case. |
'BSE'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Serbian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
singapore
staticmethod
¶
singapore(market: str = 'SGX') -> Calendar
The Singapore calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"SGX", the only market; matched ignoring case. |
'SGX'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Singapore calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
slovakia
staticmethod
¶
slovakia(market: str = 'BSSE') -> Calendar
The Slovak calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"BSSE", the only market; matched ignoring case. |
'BSSE'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Slovak calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
slovenia
staticmethod
¶
slovenia(market: str = 'LSE') -> Calendar
The Slovenian calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"LSE", the only market; matched ignoring case. |
'LSE'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Slovenian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
south_korea
staticmethod
¶
south_korea(market: str = 'Settlement') -> Calendar
The South Korean calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Settlement", "KRX"; matched ignoring case. |
'Settlement'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The South Korean calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
taiwan
staticmethod
¶
taiwan(market: str = 'TSEC') -> Calendar
The Taiwanese calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"TSEC", the only market; matched ignoring case. |
'TSEC'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Taiwanese calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
ukraine
staticmethod
¶
ukraine(market: str = 'USE') -> Calendar
The Ukrainian calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"USE", the only market; matched ignoring case. |
'USE'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Ukrainian calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
united_kingdom
staticmethod
¶
united_kingdom(market: str = 'Settlement') -> Calendar
The UK calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Settlement", "Exchange", "Metals"; matched ignoring case. |
'Settlement'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The UK calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
united_states
staticmethod
¶
united_states(market: str = 'Settlement') -> Calendar
The US calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
One of "Settlement", "NYSE", "GovernmentBond", "NERC", "LiborImpact", "FederalReserve", "SOFR"; matched ignoring case. |
'Settlement'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The US calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
uzbekistan
staticmethod
¶
uzbekistan(market: str = 'UZSE') -> Calendar
The Uzbek calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
"UZSE", the only market; matched ignoring case. |
'UZSE'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The Uzbek calendar for that market. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If market is not one of the accepted names. |
joint
staticmethod
¶
A calendar combining several others.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
calendars
|
list[Calendar]
|
The calendars to combine; at least one. |
required |
rule
|
str
|
"JoinHolidays" makes a day a holiday when it is one on any calendar; "JoinBusinessDays" makes it a business day when it is one on any calendar. Matched ignoring case. |
'JoinHolidays'
|
Returns:
| Name | Type | Description |
|---|---|---|
Calendar |
Calendar
|
The joint calendar. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If calendars is empty or rule is not one of the two accepted names. |
is_business_day
¶
is_business_day(date: Date) -> bool
Whether date is a business day on this calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Date
|
The date to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when date is neither a weekend day nor a holiday. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If date is the null date or past the calendar's tabulated horizon. |
is_holiday
¶
is_holiday(date: Date) -> bool
Whether date is a holiday on this calendar, weekends included.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Date
|
The date to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when date is not a business day. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If date is the null date or past the calendar's tabulated horizon. |
is_weekend
¶
is_weekend(date: Date) -> bool
Whether date falls on this calendar's weekend, which for a market whose weekend moved over time depends on the date and not only its weekday.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Date
|
The date to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when date is a weekend day. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If date is the null date or past the calendar's tabulated horizon. |
holiday_list
¶
The holidays between two dates, both inclusive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_date
|
Date
|
The first date of the range. |
required |
to_date
|
Date
|
The last date of the range. |
required |
include_weekends
|
bool
|
Also list the weekend days; off by default. |
False
|
Returns:
| Type | Description |
|---|---|
list[Date]
|
list[Date]: The holidays in the range, in order. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If either date is the null date, if to_date is before from_date, or if a date is past the calendar's tabulated horizon. |
business_days_between
¶
business_days_between(from_date: Date, to_date: Date, include_first: bool = True, include_last: bool = False) -> int
The number of business days between two dates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_date
|
Date
|
The first date of the range. |
required |
to_date
|
Date
|
The last date of the range. |
required |
include_first
|
bool
|
Count from_date when it is a business day; on by default. |
True
|
include_last
|
bool
|
Count to_date when it is a business day; off by default. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The business-day count, negated when from_date is after to_date. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If either date is the null date or past the calendar's tabulated horizon. |
adjust
¶
adjust(date: Date, convention: BusinessDayConvention) -> Date
Roll a date to the nearest business day.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Date
|
The date to roll. |
required |
convention
|
BusinessDayConvention
|
The rolling rule to apply. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Date |
Date
|
The adjusted date, unchanged when it is already a business day. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If date is the null date or past the calendar's tabulated horizon. |
advance
¶
advance(date: Date, n: int, unit: str, convention: BusinessDayConvention, end_of_month: bool) -> Date
Advance a date by n units and adjust the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Date
|
The date to advance from. |
required |
n
|
int
|
The number of units to advance, which may be negative. |
required |
unit
|
str
|
One of "Days", "Weeks", "Months", "Years". |
required |
convention
|
BusinessDayConvention
|
The rule the advanced date is rolled under. |
required |
end_of_month
|
bool
|
Keep the result on the month end when the starting date is one. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Date |
Date
|
The advanced and adjusted date. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If unit is not one of the four accepted strings, or if date is the null date or past the calendar's tabulated horizon. |
Date
¶
A calendar date with a validation guard.
Every constructor and every arithmetic result is range-checked before the core is reached, so an out-of-range date is an error rather than a panic.
Build a date from its three components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
day
|
int
|
The day of the month, within the length of that month. |
required |
month
|
int
|
The month, from 1 to 12. |
required |
year
|
int
|
The year, from 1901 to 2199. |
required |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If month is outside [1, 12], year is outside [1901, 2199], or day is outside the length of that month. |
DayCounter
¶
A year-fraction convention.
actual360
staticmethod
¶
actual360() -> DayCounter
The Actual/360 convention.
Returns:
| Name | Type | Description |
|---|---|---|
DayCounter |
DayCounter
|
An Actual/360 day counter. |
actual365_fixed
staticmethod
¶
actual365_fixed() -> DayCounter
The Actual/365 (Fixed) convention.
Returns:
| Name | Type | Description |
|---|---|---|
DayCounter |
DayCounter
|
An Actual/365 (Fixed) day counter. |
actual_actual_isda
staticmethod
¶
actual_actual_isda() -> DayCounter
The Actual/Actual (ISDA) convention.
Returns:
| Name | Type | Description |
|---|---|---|
DayCounter |
DayCounter
|
An Actual/Actual day counter on the ISDA convention. |
thirty360_bond_basis
staticmethod
¶
thirty360_bond_basis() -> DayCounter
The 30/360 (Bond Basis) convention.
Returns:
| Name | Type | Description |
|---|---|---|
DayCounter |
DayCounter
|
A 30/360 day counter on the bond-basis convention. |
year_fraction
¶
Period
¶
A signed length in one calendar unit (unit: Days, Weeks, Months, Years).
Build a period of n units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
The length, which may be negative. |
required |
unit
|
str
|
One of "Days", "Weeks", "Months", "Years". |
required |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If unit is not one of the four accepted strings. |
Schedule
¶
Schedule(start: Date, end: Date, frequency: Frequency, calendar: Calendar, convention: BusinessDayConvention, rule: DateGeneration = Forward, termination_convention: Optional[BusinessDayConvention] = None)
A sequence of coupon dates built through MakeSchedule.
termination_convention rolls the last date only, and defaults to convention. CDS conventions need the two to differ: a credit helper leaves its maturity unadjusted while paying Following.
Build the schedule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
Date
|
The effective date, which must be strictly before end. |
required |
end
|
Date
|
The termination date. |
required |
frequency
|
Frequency
|
The coupon frequency the interior dates are spaced at. |
required |
calendar
|
Calendar
|
The calendar the dates roll on. |
required |
convention
|
BusinessDayConvention
|
The rule every date but the last is rolled under. |
required |
rule
|
DateGeneration
|
The date-generation rule; defaults to Forward. |
Forward
|
termination_convention
|
BusinessDayConvention | None
|
The rule the last date is rolled under; None applies convention to it as well. |
None
|
Raises:
| Type | Description |
|---|---|
ItofinError
|
If start is not strictly before end. |
size
¶
The number of dates in the schedule.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The date count, one more than the number of periods. |
date
¶
date(i: int) -> Date
The i-th date in the schedule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i
|
int
|
The zero-based index into the dates. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Date |
Date
|
The date at that index. |
Raises:
| Type | Description |
|---|---|
ItofinError
|
If i is out of range. |
BusinessDayConvention
¶
A holiday-rolling rule. Every core variant is covered; the four listed last are appended, so the integer values of the first three are unchanged.
Compounding
¶
Conventions used to compound a rate over time.
DateGeneration
¶
The rule a Schedule generates its dates by.
Backward and Forward roll from one end of the range to the other; Zero keeps only the two endpoints; the ThirdWednesday and Twentieth families snap the interior dates onto an IMM Wednesday or the twentieth of the month. A Schedule builds under the three CDS rules, but SpreadCdsHelper rejects them: their maturity comes from a core routine that is not ported yet.
Frequency
¶
A coupon or fixing frequency.
Only the variants the ported fixtures use are surfaced; new ones are appended, so the integer values of the existing variants are unchanged.
is_imm_date
¶
is_imm_date(date: Date, main_cycle: bool = False) -> bool
Whether date is an IMM date.
An IMM date is the third Wednesday of the month, and of March, June, September or December only when main_cycle is set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Date
|
The date to test. |
required |
main_cycle
|
bool
|
Restrict the test to the March/June/September/December cycle. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when date is an IMM date under the selected cycle. |
next_imm_date
¶
The next IMM date strictly following date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Date
|
The date to start from; the result is strictly after it. |
required |
main_cycle
|
bool
|
Restrict the result to the March/June/September/December cycle. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Date |
Date
|
The next IMM date under the selected cycle. |