date_utils

Utility functions for dates and date resolutions.

bermuda.date_utils.add_months(dt: date, delta: float) date

Add a floating-point number of months to a date and return a date.

bermuda.date_utils.calculate_dev_lag(period_end: date, evaluation_date: date, unit: str = 'months') int | float | timedelta

Compute the development lag of the cell in the specified units.

bermuda.date_utils.dev_lag_months(start: date, stop: date) float

Compute the floating-point number of months between two dates.

bermuda.date_utils.drop_off_diagonals(triangle: Triangle) Triangle

Drop off-diagonal values from a triangle.

Only keep the most common resolution and diagonals with the most popular origin at that resolution.

bermuda.date_utils.eval_date_resolution(tri: Triangle) int

Determine the biggest unit of resolution (expressed in months) that can losslessly represent all evaluation dates in a triangle.

bermuda.date_utils.id_to_month(id: int, beginning=True) date

Convert an integer representing a month to the first date in the month.

bermuda.date_utils.is_triangle_monthly(tri: Triangle) bool

Test if all periods and evaluation dates in a triangle are in monthly increments.

bermuda.date_utils.month_to_id(dt: date) int

Convert a date to an integer representing the month containing the date.

bermuda.date_utils.period_resolution(tri: Triangle) int

Determine the biggest unit of resolution (expressed in months) that can losslessly represent all experience periods in a triangle.