CustomCalendar#
-
class sigtech.framework.infra.calendar.business_calendar.CustomCalendar
Class providing business day and holiday utility methods.
Note
Holidays are considered work dates. Weekends are not considered work dates and can be defined in the calendar (e.g. Friday and Saturday instead of Saturday and Sunday).
Note
Holidays and weekends are not considered business dates.
-
add_business_months(date: ndarray, months: int) ndarray
Return the array of offset dates which are number of months (
months
) away from given dates in arraydate
if date indate
array falls before the last business date of the date’s month. If the date falls on or after the last business date of the date’s month, then takes end of month date of the corresponding offset date.- Parameters:
date – Input date/s.
months – Number of months.
- Returns:
Array of dates.
-
classmethod add_relative(date: array, days: int = 0, weeks: int = 0, months: int = 0, years: int = 0) ndarray
Add relative time-period (holidays and weekends included) to a date.
- Parameters:
date – Input date/s.
days – Number of days.
weeks – Number of weeks.
months – Number of months.
years – Number of years.
- Returns:
Array of dates.
-
addbusdays(date: ndarray, offset: Union[int, ndarray]) ndarray
Add a number (
offset
) of business days to a given date. Examples:offset
= 0 returns input date, even it is not a business date.offset
= 1 returns next business date, even if input date is not a business date.offset
< 0 moves date backward.
- Parameters:
date – Input date/s.
offset – Offset.
- Returns:
Array of dates.
-
addworkdays(date: ndarray, offset: Union[int, ndarray]) ndarray
Add number (
offset
) of work days to a given date. Examples:offset
= 0 returns input date, even it is not a business date.offset
= 1 returns next business date, even if input date is not a business date.offset
< 0 moves date backward.
Holidays are considered work dates. Weekends are not considered work dates.
- Parameters:
date – Input date/s.
offset – Offset.
- Returns:
Array of dates.
-
adjust(date: ndarray, mode: int) ndarray
Adjust the date to the closest business date. The available
mode
rules, which are constants defined insigtech.framework.infra.calendar.business_calendar
, are:FOLLOWING
: Adjust to the next business date.PREVIOUS
: Adjust to the previous business date.MODIFIEDFOLLOWING
: Adjust to the next business date unless it falls on a different month, in which case adjust to the previous business date.
Holidays are not considered business dates. Weekends are not considered business dates.
- Parameters:
date – Input date/s.
mode – Mode rule.
- Returns:
Array of dates.
-
busdaycount(start: date, end: date)
Count business dates from
start
date (inclusive) toend
date (exclusive). Holidays are not considered business dates. Weekends are not considered business dates.- Parameters:
start – Start date.
end – End date.
- Returns:
Array of dates.
-
classmethod end_of_month(date: ndarray) ndarray
Return the calendar date, including holidays and weekends, which is the nearest future month-end to a given date. If the date is already end of month, return the date.
- Parameters:
date – Input date/s.
- Returns:
Array of dates.
-
isbusday(date: ndarray) ndarray
Check if
date
is a business date. Holidays are not considered business dates. Weekends are not considered business dates.- Parameters:
date – Input date/s.
- Returns:
Array of bool.
-
isholiday(date: ndarray) ndarray
Check if
date
is a holiday date. Weekends are not considered holiday dates.- Parameters:
date – Input date/s.
- Returns:
Array of bool.
-
isworkday(date: ndarray) ndarray
Check if
date
is a work date. Holidays are considered work dates. Weekends are not considered work dates.- Parameters:
date – Input date/s.
- Returns:
Array of bool.
-
range(start: date, end: date)
Return business dates from
start
date (inclusive) toend
date (exclusive). Holidays are not considered business dates. Weekends are not considered business dates.- Parameters:
start – Start date.
end – End date.
- Returns:
Array of dates.