bond-pricing


Namebond-pricing JSON
Version 0.7.1 PyPI version JSON
download
home_page
SummaryBond Price with YTM/zero-curve & NPV, IRR, annuities
upload_time2023-12-20 12:38:19
maintainer
docs_urlNone
author
requires_python>=3.0
licenseOSI Approved :: GNU General Public License v3 (GPLv3)
keywords bond pricing npv and irr zero yield curve annuities and perpetuities
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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 `daycount` other than simple counting of days (ACT/365 in ISDA terminology), this packages relies on the `isda_daycounters` module that can be downloaded from <https://github.com/miradulo/isda_daycounters>

* Maturity can be given in years (the `settle` parameter is set to `None` and 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`). 

* Zero curve construction
    - bootstrap zero yields from par yields (`par_yld_to_zero`) or vice versa (`zero_to_par`)
    - compute zero rates from Nelson Siegel parameters (`nelson_siegel_zero_rate`)
    - construct zero prices from par or zero yields at selected knot points using a cubic spline or assuming a flat yield curve (`make_zero_price_fun`)

* Present Value functions
    - Net Present Value (`npv`)
    - Internal Rate of Return (`irr`) 
    - Duration (`duration`). 
  These functions allow different compounding frequencies: for example, the cash flows may be monthly while the interest rate is semi-annually compounded. The function `equiv_rate` converts between different compounding frequencies.

* Annuity functions
    - Annuity present value (`annuity_pv`)
    - Future value (`annuity_fv`)
    - Implied interest rate (`annuity_rate`)
    - Number of periods to achieve given present value or terminal value (`annuity_periods`).
    - Periodic instalment to achieve given present value or terminal value (`annuity_instalment`).
    - Breakup of instalment into principal and interest (`annuity_instalment_breakup`) 
    
  In these functions also, the cash flow frequency may be different from the compounding frequency.

# Reducing Dependencies

This module requires `numpy`, `pandas` and `scipy`. In some environments, installing `scipy` may be difficult, and only a couple of functions (the `newton` root finder and `CubicSpline` interpolation) are actually needed from the huge `scipy` package. So a provision has been made to avoid `scipy` with some loss of functionality (the `newton` root finder is replaced by a less sophisticated root bracketing and bisection algorithm and `CubicSpline` interpolation is replaced by the much cruder linear interpolation). At run time, the module checks for the availability of `scipy` and uses the cruder methods (with a suitable warning) if `scipy` is not available.

To install this package without pulling in `scipy` as a dependency, do the following:

```
git clone https://github.com/jrvarma/bond_pricing.git
export no_scipy=1
pip install bond_pricing
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "bond-pricing",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.0",
    "maintainer_email": "\"Jayanth R. Varma\" <jrvarma@gmail.com>",
    "keywords": "Bond Pricing,NPV and IRR,Zero yield curve,Annuities and Perpetuities",
    "author": "",
    "author_email": "\"Jayanth R. Varma\" <jrvarma@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/a4/4f/0ab02c50930db8ef327b1e891ab8743d953437e7481a09f007905bd7e0ee/bond_pricing-0.7.1.tar.gz",
    "platform": null,
    "description": "# Overview\n\nThis 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.\n\nThe documentation is available at <https://bond-pricing.readthedocs.io/>\n\nThe bond valuation functions can be used in two modes:\n\n* 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 `daycount` other than simple counting of days (ACT/365 in ISDA terminology), this packages relies on the `isda_daycounters` module that can be downloaded from <https://github.com/miradulo/isda_daycounters>\n\n* Maturity can be given in years (the `settle` parameter is set to `None` and 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.\n\n* Bond Valuation\n    - Bond price using YTM (`bond_price`) or using zero yield curve (`zero_curve_bond_price`)\n    - Accrued interest and dirty bond prices using YTM (`bond_price_breakup`)  or using zero yield curve (`zero_curve_bond_price_breakup`)\n    - Duration using YTM (`bond_duration`)\n    - Yield to maturity (`bond_yield`). \n\n* Zero curve construction\n    - bootstrap zero yields from par yields (`par_yld_to_zero`) or vice versa (`zero_to_par`)\n    - compute zero rates from Nelson Siegel parameters (`nelson_siegel_zero_rate`)\n    - construct zero prices from par or zero yields at selected knot points using a cubic spline or assuming a flat yield curve (`make_zero_price_fun`)\n\n* Present Value functions\n    - Net Present Value (`npv`)\n    - Internal Rate of Return (`irr`) \n    - Duration (`duration`). \n  These functions allow different compounding frequencies: for example, the cash flows may be monthly while the interest rate is semi-annually compounded. The function `equiv_rate` converts between different compounding frequencies.\n\n* Annuity functions\n    - Annuity present value (`annuity_pv`)\n    - Future value (`annuity_fv`)\n    - Implied interest rate (`annuity_rate`)\n    - Number of periods to achieve given present value or terminal value (`annuity_periods`).\n    - Periodic instalment to achieve given present value or terminal value (`annuity_instalment`).\n    - Breakup of instalment into principal and interest (`annuity_instalment_breakup`) \n    \n  In these functions also, the cash flow frequency may be different from the compounding frequency.\n\n# Reducing Dependencies\n\nThis module requires `numpy`, `pandas` and `scipy`. In some environments, installing `scipy` may be difficult, and only a couple of functions (the `newton` root finder and `CubicSpline` interpolation) are actually needed from the huge `scipy` package. So a provision has been made to avoid `scipy` with some loss of functionality (the `newton` root finder is replaced by a less sophisticated root bracketing and bisection algorithm and `CubicSpline` interpolation is replaced by the much cruder linear interpolation). At run time, the module checks for the availability of `scipy` and uses the cruder methods (with a suitable warning) if `scipy` is not available.\n\nTo install this package without pulling in `scipy` as a dependency, do the following:\n\n```\ngit clone https://github.com/jrvarma/bond_pricing.git\nexport no_scipy=1\npip install bond_pricing\n```\n",
    "bugtrack_url": null,
    "license": "OSI Approved :: GNU General Public License v3 (GPLv3)",
    "summary": "Bond Price with YTM/zero-curve & NPV, IRR, annuities",
    "version": "0.7.1",
    "project_urls": {
        "Homepage": "https://github.com/jrvarma/bond_pricing"
    },
    "split_keywords": [
        "bond pricing",
        "npv and irr",
        "zero yield curve",
        "annuities and perpetuities"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "870034099062de3c3f59f940c41137a2d8114ab4ec67f9286ef07d87c2a5b58e",
                "md5": "036c3d34716811abf1a8fa07106f647a",
                "sha256": "f8cd92ef9328f6edbed7225f5552bb1e4b3331b1439a35132b4ea5a2d67b9823"
            },
            "downloads": -1,
            "filename": "bond_pricing-0.7.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "036c3d34716811abf1a8fa07106f647a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.0",
            "size": 34002,
            "upload_time": "2023-12-20T12:38:17",
            "upload_time_iso_8601": "2023-12-20T12:38:17.311461Z",
            "url": "https://files.pythonhosted.org/packages/87/00/34099062de3c3f59f940c41137a2d8114ab4ec67f9286ef07d87c2a5b58e/bond_pricing-0.7.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a44f0ab02c50930db8ef327b1e891ab8743d953437e7481a09f007905bd7e0ee",
                "md5": "aef2e614413193ca24a28b32ec882f5c",
                "sha256": "9f0d0fb3d82dd83265d82a25b141266b9c1c9d9cf19407257d2597e72f97b95a"
            },
            "downloads": -1,
            "filename": "bond_pricing-0.7.1.tar.gz",
            "has_sig": false,
            "md5_digest": "aef2e614413193ca24a28b32ec882f5c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.0",
            "size": 32749,
            "upload_time": "2023-12-20T12:38:19",
            "upload_time_iso_8601": "2023-12-20T12:38:19.313502Z",
            "url": "https://files.pythonhosted.org/packages/a4/4f/0ab02c50930db8ef327b1e891ab8743d953437e7481a09f007905bd7e0ee/bond_pricing-0.7.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-20 12:38:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jrvarma",
    "github_project": "bond_pricing",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "bond-pricing"
}
        
Elapsed time: 0.16161s