finpricing.utils.day_count#

Module Contents#

Classes#

DayCountTypes

Generic enumeration.

DayCount

class finpricing.utils.day_count.DayCountTypes[source]#

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

ACT_360 = 0#
ACT_365 = 1#
THIRTY_360 = 2#
ACT_ACT_ISDA = 3#
Thirty_E_360 = 4#
Thirty_E_360_ISDA = 5#
class finpricing.utils.day_count.DayCount(dccType: DayCountTypes)[source]#
year_frac#
days_between(start_date: finpricing.utils.date.Date, end_date: finpricing.utils.date.Date, include_end=False) tuple[source]#

Return the number of days and year fraction using a specific day count convention

Returns:

(days, fraction of year)

Return type:

tuple

year_fraction(start_date: finpricing.utils.date.Date | datetime.date, end_date: finpricing.utils.date.Date | datetime.date, next_coupon_date: finpricing.utils.date.Date = None) float[source]#

Return the fraction of year between two dates using a specific day count convention

The actual calculation is done in days_between() method.

Parameters:
  • start_date (Date) – start date of the accrual period

  • end_date (Date) – end date of the accrual period. For a bond trade, it is the settlement date of the trade.

  • next_coupon_date (Date) – next coupon date of the bond / maturity date of the bond if no more coupon payment

convert_dates_to_times(anchor_date: finpricing.utils.date.Date, dates: list[finpricing.utils.date.Date]) list[float][source]#

Return a list of time fraction (year fraction) between anchor date and each date in the list

Parameters:
  • anchor_date (Date) – anchor date

  • dates (list[Date]) – list of dates

Returns:

list of time fraction (year fraction)

Return type:

list[float]

__repr__() str[source]#

Return the string representation of the object