Skip to main content

luna.financial.day_count_convention

DayCountConventionBase Objects

class DayCountConventionBase(ABC)

Abstract base class for day count conventions used in financial calculations.

denominator

@property
@abstractmethod
def denominator() -> int

The denominator used for year fraction calculation.

day_count

def day_count(start: date, end: date) -> SixteenDecimal

Calculates the number of days between two dates based on the day count convention.

Thirty360DayCount Objects

class Thirty360DayCount(DayCountConventionBase)

Convention with 30 days in a month and 360 days in a year. ISDA recommended method for day count is: 360(y2-y1) + 30(m2-m1-1) + max(0,30-d1) + min(30,d2)

  • Take year diff
  • Take month diff + 1 month to be adjusted by date
  • Since every month is 30 and reduce d1 from it, and take max with 0 in case result is negative ( days to 30 )
  • days in d2, min if more than 30

Actual360DayCount Objects

class Actual360DayCount(DayCountConventionBase)

Actual difference between dates is calculated, but year is considered to be of 360 days.

Actual365FixedDayCount Objects

class Actual365FixedDayCount(DayCountConventionBase)

Actual difference between dates is calculated, but year is considered to be of 365 days.

ActualActualISDADayCount Objects

class ActualActualISDADayCount(DayCountConventionBase)

Actual difference between dates is calculated, also the difference in year.

DayCountConvention Objects

@enum.unique
class DayCountConvention(enum.Enum)

Enumeration for specifying available day count conventions.

get_day_count_convention

def get_day_count_convention(
day_count_convention: str) -> Type[DayCountConvention] | None

Retrieves the appropriate day count convention class based on the provided convention name.