FinancePy

FinancePy API Reference

Discount Curve

financepy.market.curves.discount_curve

Classes

DiscountCurve

DiscountCurve(anchor_dt: financepy.utils.date.Date, df_dates: list = None, df_values: list | numpy.ndarray = None, interp_type: financepy.market.curves.interpolator.InterpTypes = <InterpTypes.FLAT_FWD_RATES: 1>, curve_dc_type: financepy.utils.day_count.DayCountTypes = <DayCountTypes.ACT_365F: 7>) -> None
This is a base discount curve which has an internal representation of a vector of times and discount factors and an interpolation scheme for interpolating between these fixed points.

Methods

set_times

set_times(self, times: numpy.ndarray)

No description available.

set_dfs

set_dfs(self, dfs: numpy.ndarray)
Set the discount factor at the last maturity time.

set_last_df

set_last_df(self, df)
Set the discount factor at the last maturity time.

fit

fit(self, times: numpy.ndarray, dfs: numpy.ndarray)
Fit the interpolator to the given times and discount factors.

fwd_rate

fwd_rate(self, start_dt: list | financepy.utils.date.Date, date_or_tenor: financepy.utils.date.Date | str | list, accrual_dc_type: financepy.utils.day_count.DayCountTypes = <DayCountTypes.ACT_360: 8>, comp_type: financepy.utils.compounding.CompoundingTypes = <CompoundingTypes.MMKT: 1>, freq_type: financepy.utils.frequency.FrequencyTypes = None)
Simple-compounded forward rate between dates. accrual_dc_type is used for the forward accrual denominator. self.curve_dc_type is used for curve time conversion / interpolation.

fwd_rate_t

fwd_rate_t(self, start_t: float | list | numpy.ndarray, end_t: float | list | numpy.ndarray, accrual: float | list | numpy.ndarray = None, comp_type: financepy.utils.compounding.CompoundingTypes = <CompoundingTypes.MMKT: 1>, freq_type: financepy.utils.frequency.FrequencyTypes = None)
Forward rate between curve times.

fwd_rate_inst

fwd_rate_inst(self, dts: financepy.utils.date.Date | list, dt: float = 1e-06)
Instantaneous continuously compounded forward rate at date(s).

fwd_rate_inst_t

fwd_rate_inst_t(self, t: float | list | numpy.ndarray, dt: float = 0.0001)
Instantaneous continuously compounded forward rate at time t. Computes: f(t) = - d ln Z(t) / dt using a central finite difference.

zero_rate

zero_rate(self, maturity_dt: list | financepy.utils.date.Date, freq_type: financepy.utils.frequency.FrequencyTypes = <FrequencyTypes.ANNUAL: 1>)
Calculate zero rates with specified compounding frequency.

curve_years

curve_years(self, maturity_dt: list | financepy.utils.date.Date)
Calculate zero rates with continuous compounding.

fwd_zero_rate_cc

fwd_zero_rate_cc(self, start_dt: financepy.utils.date.Date, end_dt: financepy.utils.date.Date)
Calculate fwd zero rates with continuous compounding.

zero_rate_cc

zero_rate_cc(self, maturity_dt: list | financepy.utils.date.Date)
Calculate zero rates with continuous compounding.

zero_rate_cc_t

zero_rate_cc_t(self, t)
Calculate zero rates with continuous compounding.

zero_rate_t

zero_rate_t(self, t, freq_type: financepy.utils.frequency.FrequencyTypes = <FrequencyTypes.ANNUAL: 1>)

No description available.

swap_rate

swap_rate(self, effective_dt: financepy.utils.date.Date, maturity_dt: list | financepy.utils.date.Date, freq_type: financepy.utils.frequency.FrequencyTypes = <FrequencyTypes.ANNUAL: 1>, accrual_dc_type: financepy.utils.day_count.DayCountTypes = <DayCountTypes.THIRTY_E_360: 2>)

No description available.

swap_rate_old

swap_rate_old(self, effective_dt: financepy.utils.date.Date, maturity_dt: list | financepy.utils.date.Date, freq_type: financepy.utils.frequency.FrequencyTypes = <FrequencyTypes.ANNUAL: 1>, accrual_dc_type: financepy.utils.day_count.DayCountTypes = <DayCountTypes.THIRTY_E_360: 2>)
Calculate the swap rate to maturity date. This is the rate paid by a swap that has a price of par today. This is the same as a Libor swap rate except that we do not do any business day adjustments.

par_rate

par_rate(self, effective_dt: financepy.utils.date.Date, maturity_dt: list | financepy.utils.date.Date, freq_type: financepy.utils.frequency.FrequencyTypes = <FrequencyTypes.ANNUAL: 1>, accrual_dc_type: financepy.utils.day_count.DayCountTypes = <DayCountTypes.THIRTY_E_360: 2>)
Calculate the swap rate to maturity date. This is the rate paid by a swap that has a price of par today. This is the same as a Libor swap rate except that we do not do any business day adjustments.

par_rate_simple_t

par_rate_simple_t(self, t_maturity, freq=2)
Simple spot-starting par rate from curve times. Handles bonds with coupons equal to c/f. Calculates payments backwards from maturity. Not exact for swaps as it ignores accrual factor weighted coupon payments. Parameters ---------- maturity : float Final maturity in years. freq : int Fixed-leg payments per year.

par_rate_t

par_rate_t(self, t_start: float, payment_times: numpy.ndarray, accrual_factors: numpy.ndarray)

No description available.

df

df(self, dt: list | financepy.utils.date.Date)
Function to calculate a discount factor from a date or a vector of dates. The time day count determines how dates get converted to years.

df_t

df_t(self, t: float | numpy.ndarray)
Function to calculate a discount factor from a time or a vector of times. Discourage usage in favour of passing in dates.

bump_parallel

bump_parallel(self, bump_size: float)
Adjust the continuously compounded forward rates by a perturbation upward equal to the bump size and return a curve object with this bumped curve. This is used for interest rate risk.

bump_bucket

bump_bucket(self, bucket_start: float, bucket_end: float, bump_size: float, interp_type=None)
Apply a bucket (key rate) shift: shift continuous forward rates only between bucket_start and bucket_end years.

survival_prob

survival_prob(self, dt: financepy.utils.date.Date) -> float
This returns a survival probability to a specified date based on the assumption that the continuously compounded rate is a default hazard rate in which case the survival probability is directly analogous to a discount factor.

plot

plot(self, title, times: numpy.ndarray = None, ymin: float = None, ymax: float = None, filename: str = None)
Display discount curve.
Generated automatically from the FinancePy source code. Do not edit this file manually.