finpricing.model.utils.bond_pricing_utils
#
Module Contents#
Functions#
|
Calculate the constant hazard rate given the survival probabilities at two time points. |
|
Calculate the principal integral. |
|
calculate the accrual of a coupon leg |
Attributes#
- finpricing.model.utils.bond_pricing_utils.MINIMUM_DENOMINATOR = 1e-12#
- finpricing.model.utils.bond_pricing_utils.hazard_rate_from_probs(start_p, end_p, start_date, end_date, day_count_type=DayCountTypes.ACT_ACT_ISDA)[source]#
Calculate the constant hazard rate given the survival probabilities at two time points.
- Parameters:
start_p – Survival probability at start date
end_p – Survival probability at end date
start_date – Start date.
end_date – End date.
- Returns:
The hazard rate.
- finpricing.model.utils.bond_pricing_utils.principal_integral(N, R, valuation_date: datetime.date | finpricing.utils.Date, maturity_date: datetime.date | finpricing.utils.Date, granularity_in_days: int, survival_curve, discount_curve)[source]#
Calculate the principal integral.
- Parameters:
N – Total notional.
R – Recovery rate.
end_date – End date.
granularity_in_days – The granularity parameter in days.
survival_curve – Function that returns the survival probability at a given date.
discount_curve – Function that returns the bond price at a given date.
- Returns:
The principal integral value.
- finpricing.model.utils.bond_pricing_utils.accrual_integral(survival_curve, discount_curve, accrual_start_date, accrual_end_date, granularity_in_days, R, day_count_type=DayCountTypes.ACT_ACT_ISDA)[source]#
calculate the accrual of a coupon leg
- Parameters:
start_date – start date of the calculation period
granularity_in_days – granularity of the partition in days
R – recovery rate
survival_curve – survival curve
discount_curve – discount curve
accrual_start_date – accrual start date, the lower bound of the integral
accrual_end_date – accrual end date, the upper bound of the integral
- Returns:
The accrual value