Bond Price with YTM/zero-curve & NPV, IRR, annuities
Maintained. Last release 8 weeks ago, commits in 1 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install bond-pricingInstallation
pip install bond_pricing
For installation without pulling in scipy as a dependency, see below
The source code is at https://github.com/jrvarma/bond_pricing if you want to go that route.
Overview
This package provides bond pricing functions as well as basic NPV/IRR functions. Bond valuation can be done using an yield to maturity or using a zero yield curve. There is a convenience function to construct a zero yield curve from a few points on the par bond or zero yield curve or from Nelson Siegel parameters.
The documentation is available at https://bond-pricing.readthedocs.io/
The bond valuation functions can be used in two modes:
-
The first mode is similar to spreadsheet bond pricing functions. The settlement date and maturity date are given as dates and the software calculates the time to maturity and to each coupon payment date from these dates. For any
daycountother than simple counting of days (ACT/365 in ISDA terminology), this packages relies on theisda_daycountersmodule that can be downloaded from https://github.com/miradulo/isda_daycounters -
Maturity can be given in years (the
settleparameter is set toNoneand is assumed to be time 0) and there are no dates at all. This mode is particularly convenient to price par bonds or price other bonds on issue date or coupon dates. For example, finding the price of a 7 year 3.5% coupon bond if the prevailing yield is 3.65% is easier in this mode as the maturity is simply given as 7.0 instead of providing a maturity date and specifying today's date. Using this mode between coupon dates is not so easy as the user has to basically compute the day count and year fraction and provide the maturity as say 6.7 years. -
Bond Valuation
- Bond price using YTM (
bond_price) or using zero yield curve (zero_curve_bond_price) - Accrued interest and dirty bond prices using YTM (
bond_price_breakup) or using zero yield curve (zero_curve_bond_price_breakup) - Duration using YTM (
bond_duration) - Yield to maturity (
bond_yield).
- Bond price using YTM (
-
Zero curve construction