{ "info": { "author": "luphord", "author_email": "luphord@protonmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 3.7" ], "description": "============================\nNelson-Siegel-Svensson Model\n============================\n\n\n.. image:: https://img.shields.io/pypi/v/nelson_siegel_svensson.svg\n :target: https://pypi.python.org/pypi/nelson_siegel_svensson\n\n.. image:: https://img.shields.io/travis/luphord/nelson_siegel_svensson.svg\n :target: https://travis-ci.org/luphord/nelson_siegel_svensson\n\n.. image:: https://readthedocs.org/projects/nelson-siegel-svensson/badge/?version=latest\n :target: https://nelson-siegel-svensson.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n\n\n\nImplementation of the Nelson-Siegel-Svensson interest rate curve model in Python.\n\n.. code-block:: python\n\n from nelson_siegel_svensson import NelsonSiegelSvenssonCurve\n import numpy as np\n from matplotlib.pyplot import plot\n\n y = NelsonSiegelSvenssonCurve(0.028, -0.03, -0.04, -0.015, 1.1, 4.0)\n t = np.linspace(0, 20, 100)\n plot(t, y(t))\n\n.. image:: docs/_static/an_example_nelson-siegel-svensson-curve.png\n\n* Free software: MIT license\n* Documentation: https://nelson-siegel-svensson.readthedocs.io.\n\n\nFeatures\n--------\n\n* Python implementation of the Nelson-Siegel curve (three factors)\n* Python implementation of the Nelson-Siegel-Svensson curve (four factors)\n* Methods for zero and forward rates (as vectorized functions of time points)\n* Methods for the factors (as vectorized function of time points)\n* Calibration based on ordinary least squares (OLS) for betas and nonlinear optimization for taus\n* Simple command line interface (CLI) for evaluating, calibrating and plotting curves\n\n\nCalibration\n-----------\n\nIn order to calibrate a curve to given data you can use the `calibrate_ns_ols` and\n`calibrate_nss_ols` functions in the `calibrate` module:\n\n.. code-block:: python\n\n import numpy as np\n from nelson_siegel_svensson.calibrate import calibrate_ns_ols\n\n t = np.array([0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0])\n y = np.array([0.01, 0.011, 0.013, 0.016, 0.019, 0.021, 0.026, 0.03, 0.035, 0.037, 0.038, 0.04])\n\n curve, status = calibrate_ns_ols(t, y, tau0=1.0) # starting value of 1.0 for the optimization of tau\n assert status.success\n print(curve)\n\nwhich gives the following output:\n\n.. code-block:: python\n\n NelsonSiegelCurve(beta0=0.04201739383636799, beta1=-0.031829031569430594, beta2=-0.026797319779108236, tau=1.7170972656534174)\n\n.. image:: docs/_static/calibrated_nelson-siegel-curve.png\n\n\nCommand Line interface\n----------------------\n\n`nelson_siegel_svensson` provides basic functionality using a command line interface (CLI):\n\n.. code-block:: console\n\n Usage: nelson_siegel_svensson [OPTIONS] COMMAND [ARGS]...\n\n Commandline interface for nelson_siegel_svensson.\n\n Options:\n --help Show this message and exit.\n\n Commands:\n calibrate Calibrate a curve to the given data points.\n evaluate Evaluate a curve at given points.\n plot Plot a curve at given points.\n\n\nIn order to calibrate a curve to given data points on the command line, try\n\n.. code-block:: console\n\n nelson_siegel_svensson calibrate -t '[0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0]' -y '[0.01, 0.011, 0.013, 0.016, 0.019, 0.021, 0.026, 0.03, 0.035, 0.037, 0.038, 0.04]' --nelson-siegel --initial-tau1 1.0\n\nwhich gives\n\n.. code-block:: console\n\n {\"beta0\": 0.042017393764903765, \"beta1\": -0.03182903146166806, \"beta2\": -0.026797320316066128, \"tau\": 1.717097232403383}\n\nThis curve can then be evaluated on the command line using\n\n.. code-block:: console\n\n nelson_siegel_svensson evaluate -c '{\"beta0\": 0.042017393764903765, \"beta1\": -0.03182903146166806, \"beta2\": -0.026797320316066128, \"tau\": 1.717097232403383}' -t '[0, 1, 2, 3]'\n\nresulting in\n\n.. code-block:: console\n\n [0.010188362303235707, 0.012547870204470839, 0.01574855552855885, 0.01897955804146046]\n\nAnd finally, the curve can be plotted with\n\n.. code-block:: console\n\n nelson_siegel_svensson plot -o cli_plot_example.png -c '{\"beta0\": 0.042017393764903765, \"beta1\": -0.03182903146166806, \"beta2\": -0.026797320316066128, \"tau\": 1.717097232403383}'\n\n.. image:: docs/_static/cli_plot_example.png\n\nNote that the quoting in the above commands prevents `bash` from evalutating the JSON-based parameters. Depending on your shell, you may require a different quoting mechanism.\n\nCredits\n-------\n\nMain developer is luphord_.\n\n.. _luphord: https://github.com/luphord\n\nThis package was prepared with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n\n=======\nHistory\n=======\n\n0.4.0 (2019-07-08)\n------------------\n\n* Simple command line interface (CLI) supporting curve evaluation, calibration and plotting\n* Added more documentation\n\n0.3.0 (2019-03-17)\n------------------\n\n* Added type annotations\n\n0.2.0 (2019-02-20)\n------------------\n\n* Ordinary least squares based calibration of Nelson-Siegel-Svensson\n* Ordinary least squares based calibration of Nelson-Siegel\n* A little bit of usage documentation\n\n0.1.0 (2019-02-13)\n------------------\n\n* First release on PyPI.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/luphord/nelson_siegel_svensson", "keywords": "nelson_siegel_svensson", "license": "MIT license", "maintainer": "", "maintainer_email": "", "name": "nelson-siegel-svensson", "package_url": "https://pypi.org/project/nelson-siegel-svensson/", "platform": "", "project_url": "https://pypi.org/project/nelson-siegel-svensson/", "project_urls": { "Homepage": "https://github.com/luphord/nelson_siegel_svensson" }, "release_url": "https://pypi.org/project/nelson-siegel-svensson/0.4.0/", "requires_dist": [ "Click (>=6.0)", "numpy (>=1.14)", "scipy (>=1.2)", "matplotlib (>=3.0)" ], "requires_python": "", "summary": "Implementation of the Nelson-Siegel-Svensson interest rate curve model.", "version": "0.4.0" }, "last_serial": 5501632, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "7ad0271e7b87a30bb42c5ab324bfce36", "sha256": "bade30353cd95d79b23ef74d5e7097898db00c7d79d191212252b88c36c59a5a" }, "downloads": -1, "filename": "nelson_siegel_svensson-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7ad0271e7b87a30bb42c5ab324bfce36", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5741, "upload_time": "2019-02-13T16:24:39", "url": "https://files.pythonhosted.org/packages/97/be/81402968d3ded57370667a4702a7f0a2fe11de10db3785338944ea929f67/nelson_siegel_svensson-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a2e78864a96583b17f8089c71f4956a3", "sha256": "ecd16abd4c6fdab1f25935eda5ea74ee427a12095b617ea8265a3f33cee71327" }, "downloads": -1, "filename": "nelson_siegel_svensson-0.1.0.tar.gz", "has_sig": false, "md5_digest": "a2e78864a96583b17f8089c71f4956a3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 41797, "upload_time": "2019-02-13T16:24:44", "url": "https://files.pythonhosted.org/packages/82/5a/7bd0f94458dc40aacc56f828c7a3463f954cc98c8559d690b13003865e7b/nelson_siegel_svensson-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "2b18dcc40666505d745f56036fa1ad1e", "sha256": "f3e59a3b0834589a3a8ec2c6801b23317df95b7e96bfb214d65cd1f5fce951e0" }, "downloads": -1, "filename": "nelson_siegel_svensson-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2b18dcc40666505d745f56036fa1ad1e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6986, "upload_time": "2019-02-20T06:04:28", "url": "https://files.pythonhosted.org/packages/72/fd/0a76f0733eea2998396b3801f2fc83f09c7b68a76a4ecd135a3a32af261c/nelson_siegel_svensson-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b56e7b21a869364648328e8ac2de70d9", "sha256": "d24911457ee852227f8017e0ac4fa8e2e05b5c27092f7e6bbd9604708dc19e4f" }, "downloads": -1, "filename": "nelson_siegel_svensson-0.2.0.tar.gz", "has_sig": false, "md5_digest": "b56e7b21a869364648328e8ac2de70d9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 87514, "upload_time": "2019-02-20T06:04:30", "url": "https://files.pythonhosted.org/packages/54/6b/928a495b40c3a2360c8dd5f73d8bffd9541e64deb3271caffbea163dc2ea/nelson_siegel_svensson-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "5e720309c1111540b4e4dd9f2d0b59ad", "sha256": "b7a9cce1f7b4e7c252daa7a8c797bf376a80b44cdf226744f181ec378f9193ef" }, "downloads": -1, "filename": "nelson_siegel_svensson-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5e720309c1111540b4e4dd9f2d0b59ad", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7122, "upload_time": "2019-03-17T11:21:27", "url": "https://files.pythonhosted.org/packages/ca/d9/e6041b146351b5d25af3c71becc2f639c08e5deffa50714fbcb00af240d5/nelson_siegel_svensson-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ec8254fa6f6f676f60296019a34d7a19", "sha256": "2f910601a16c32477647d2a6e06d90dd72f509d200382a30af4a9306321a2b6c" }, "downloads": -1, "filename": "nelson_siegel_svensson-0.3.0.tar.gz", "has_sig": false, "md5_digest": "ec8254fa6f6f676f60296019a34d7a19", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 77720, "upload_time": "2019-03-17T11:21:29", "url": "https://files.pythonhosted.org/packages/90/60/071226690a177cbbca00f41c57506764d5267b8621973b53fe0277c99f1a/nelson_siegel_svensson-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "d92243315bff67553e2b2616b9850549", "sha256": "4b4f16fa47120d99cf7388da65f3c7acdbb812ef3fd27ae6fee4ae296ec8afe6" }, "downloads": -1, "filename": "nelson_siegel_svensson-0.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d92243315bff67553e2b2616b9850549", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9509, "upload_time": "2019-07-08T15:12:41", "url": "https://files.pythonhosted.org/packages/61/e1/0281ba0d9586ff79cf6fb0e56832ddc7a525de2cb560f4f8b8e7432d9526/nelson_siegel_svensson-0.4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6e50e3bec07fb902529fd64aa76d656a", "sha256": "90a4fb0d6d3398d77a7b76754a883be036fff4fab82e3764d7ff9505cafa4a1a" }, "downloads": -1, "filename": "nelson_siegel_svensson-0.4.0.tar.gz", "has_sig": false, "md5_digest": "6e50e3bec07fb902529fd64aa76d656a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 143873, "upload_time": "2019-07-08T15:12:47", "url": "https://files.pythonhosted.org/packages/bb/8e/9959bbfe60f299d4343240d0a0b1dc72ec5ae16b6a8f36dd1628f10ff643/nelson_siegel_svensson-0.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d92243315bff67553e2b2616b9850549", "sha256": "4b4f16fa47120d99cf7388da65f3c7acdbb812ef3fd27ae6fee4ae296ec8afe6" }, "downloads": -1, "filename": "nelson_siegel_svensson-0.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d92243315bff67553e2b2616b9850549", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9509, "upload_time": "2019-07-08T15:12:41", "url": "https://files.pythonhosted.org/packages/61/e1/0281ba0d9586ff79cf6fb0e56832ddc7a525de2cb560f4f8b8e7432d9526/nelson_siegel_svensson-0.4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6e50e3bec07fb902529fd64aa76d656a", "sha256": "90a4fb0d6d3398d77a7b76754a883be036fff4fab82e3764d7ff9505cafa4a1a" }, "downloads": -1, "filename": "nelson_siegel_svensson-0.4.0.tar.gz", "has_sig": false, "md5_digest": "6e50e3bec07fb902529fd64aa76d656a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 143873, "upload_time": "2019-07-08T15:12:47", "url": "https://files.pythonhosted.org/packages/bb/8e/9959bbfe60f299d4343240d0a0b1dc72ec5ae16b6a8f36dd1628f10ff643/nelson_siegel_svensson-0.4.0.tar.gz" } ] }