financepy


Namefinancepy JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/domokane/FinancePy
SummaryA Finance Securities Valuation Library
upload_time2025-08-31 10:57:35
maintainerNone
docs_urlNone
authorDominic O'Kane
requires_python>=3.8
licenseGPL-3.0-or-later
keywords finance options bonds valuation derivatives
VCS
bugtrack_url
requirements numba numpy scipy llvmlite ipython pandas matplotlib
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # FinancePy
A one-stop library for pricing and risk-managing options, futures and other financial instruments. See below for a comprehensive overview.

## First Installation
FinancePy can be installed from pip using the following command:

`pip install financepy`

To upgrade an existing installation type:

`pip install --upgrade financepy`

Then start a Python terminal and type

`import financepy`

Here is a quick check to make sure it all loaded. Type

```>>> Date(19,2,2026).add_days(2)```

You should see

```21-FEB-2026```

Warning: You may notice that the library can take several seconds to import after the first install if you do a wildcard import of classes which rely on certain models. This is because financepy relies upon Numba to compile a lot of the models - resulting in calculation speeds similar to C/C++. This compile only takes place on the first import of the model and the compiled code is then cached on your machine. No further compilation will be required. As a consequence subsequent imports will be almost instant.

## Quickstart Guide

👉 See [Quick Start Guide](./docs/QUICKSTART.md) to get going in 2 minutes!


## Structure of Financepy

The structure of financepy is as follows
```
├── market/
├── models/
├── products/
├── utils/
```

The market folder contains objects linked to structured market data such as interest rate term structures, i.e `curves' and volatility term structures and surfaces.

```
├── market/
│   ├── curves
│       ├── composite_discount_curve.py
│       ├── discount_curve_flat.py
│       ├── ...
│       ├── discount_curve.py
│   ├── prices
│   ├── volatility
│       ├── equity_vol_curve.py
│       ├── ...
│       ├── fx_vol_surface.py
│       ├── swaption_vol_surface.py
```
The models folder contains mathematical pricing models.
```
├── models/
│   ├── bachelier.py
│   ├── bdt_tree.py
│   ├── black_scholes.py
│   ├── ...
│   ├── vasicek_mc.py
```
These model pricing functions are not usually called directly but are called from the products objects in the products folder. There is a module for each of the covered product types which are grouped into bonds, credit, equiy, fx and rates as follows:
```
├── products/
│   ├── Bonds
│       ├── bond_convertible.py
│       ├── bond_future.py
│       ├── ...
│       ├── bond.py
│   ├── Credit
│       ├── cds_basket.py
│       ├── ...
│       ├── cds.py
│   ├── Equity
│       ├── equity_american_option.py
│       ├── ...
│       ├── equity_variance_swap.py
│   ├── FX
│       ├── fx_barrier_option.py
│       ├── ...
│       ├── fx_variance_swap.py
│   ├── Rates
│       ├── callable_swap.py
│       ├── ...
│       ├── ibor_swaption.py
```
Finally, we have the utils folder that contains useful classes such as dates, day counts and schedule generation
```
├── utils/
│   ├── calendar.py
│   ├── day_count.py
│   ├── date
│   ├── schedule
```
and many more.

## Notebooks
The notebooks folder contains over 90 example notebooks on how to use the library.

## Disclaimer
This software is distributed FREE AND WITHOUT ANY WARRANTY. Report any bugs or concerns here as an issue.

## Contributing
If you have a knowledge of Quantitative Finance and Python, then please consider contributing to this project. There are small tasks and big tasks to be done. Just look in the list of Issues and you may find something you can do. Before you begin, please comment in the issue thread in case someone else may be working on that issue. Or you can contact me directly at dominic.okane at edhec.edu. There are a number of requirements:

* The code should be Pep8 compliant.
* Comments are required for every class and function, and they should give a clear description.
* At least one broad test case and a set of unit tests must be provided for every function.
* Avoid very pythonic constructions. For example a loop is as good as a list comprehension. And with numba it can be faster. Readability and speed are the priorities.

## Users
If you are a user and require some additional functionality, then please add it as an issue.

## Overview

FinancePy is a python-based library that is currently in beta version. It covers the following functionality:

* Valuation and risk models for a wide range of equity, FX, interest rate and credit derivatives.

Although it is written entirely in Python, it can achieve speeds comparable to C++ by using Numba. As a result the user has both the ability to examine the underlying code and the ability to perform pricing and risk at speeds which compare to a library written in C++.

The target audience for this library includes:

* Students of finance and students of python
* Academics teaching finance or conducting research into finance
* Traders wishing to price or risk-manage a derivative.
* Quantitative analysts seeking to price or reverse engineer a price.
* Risk managers wishing to replicate and understand price sensitivity.
* Portfolio managers wishing to check prices or calculate risk measures.
* Fund managers wanting to value a portfolio or examine a trading strategy.

Users should have a good, but not advanced, understanding of Python. In terms of Python, the style of the library has been determined subject to the following criteria:

1. To make the code as simple as possible so that those with a basic Python fluency can understand and check the code.
2. To keep all the code in Python so users can look through the code to the lowest level.
3. To offset the performance impact of (2) by leveraging Numba to make the code as fast as possible without resorting to Cython.
4. To make the design product-based rather than model-based so someone wanting to price a specific product can easily find that without having to worry too much about the model – just use the default – unless they want to. For most products, a Monte-Carlo implementation has been provided both as a reference for testing and as a way to better understand how the product functions in terms of payments, their timings and conditions.
5. To make the library as complete as possible so a user can find all their required finance-related functionality in one place. This is better for the user as they only have to learn one interface.
6. To avoid complex designs. Limited inheritance unless it allows for significant code reuse. Some code duplication is OK, at least temporarily.
7. To have good documentation and easy-to-follow examples.
8. To make it easy for interested parties to contribute.

In many cases the valuations should be close to if not identical to those produced by financial systems such as Bloomberg. However for some products, larger value differences may arise due to differences in date generation and interpolation schemes. Over time it is hoped to reduce the size of such differences.

Important Note:

* IF YOU HAVE ANY PRICING OR RISK EXAMPLES YOU WOULD LIKE REPLICATED, SEND SCREENSHOTS OF ALL THE UNDERLYING DATA, MODEL DETAILS AND VALUATION.
* IF THERE IS A PRODUCT YOU WOULD LIKE TO HAVE ADDED, SEND ME THE REQUEST.
* IF THERE IS FUNCTIONALITY YOU WOULD LIKE ADDED, SEND ME A REQUEST.

The underlying Python library is split into a number of major modules:

* Utils - These are utility functions used to assist you with modelling a security. These include dates (Date), calendars, schedule generation, some finance-related mathematics functions and some helper functions.
* Market - These are modules that capture the market information used to value a security. These include interest rate and credit curves, volatility surfaces and prices.
* Models - These are the low-level models used to value derivative securities ranging from Black-Scholes to complex stochastic volatility models.
* Products - These are the actual securities and range from Government bonds to Bermudan swaptions.

Any product valuation is the result of the following data design:

**VALUATION** = **PRODUCT** + **MODEL** + **MARKET**

The interface to each product has a value() function that will take a model and market to produce a price.

## Author

Dominic O'Kane. I am a Professor of Finance at the EDHEC Business School in Nice, France. I have 12 years of industry experience and over 15 years of academic experience.

Contact me at dominic.okane at edhec.edu.

## Dependencies

FinancePy depends on Numpy, Numba, Scipy and basic python libraries such as os, sys and datetime.

## Changelog

See the changelog for a detailed history of changes.

## License

 GPL-3.0 License - See the license file in this folder for details.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/domokane/FinancePy",
    "name": "financepy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "FINANCE, OPTIONS, BONDS, VALUATION, DERIVATIVES",
    "author": "Dominic O'Kane",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/a0/83/544eebad0738f6b601cc81ade63ba829746681e01cad80a680cd6f193045/financepy-1.0.1.tar.gz",
    "platform": null,
    "description": "# FinancePy\r\nA one-stop library for pricing and risk-managing options, futures and other financial instruments. See below for a comprehensive overview.\r\n\r\n## First Installation\r\nFinancePy can be installed from pip using the following command:\r\n\r\n`pip install financepy`\r\n\r\nTo upgrade an existing installation type:\r\n\r\n`pip install --upgrade financepy`\r\n\r\nThen start a Python terminal and type\r\n\r\n`import financepy`\r\n\r\nHere is a quick check to make sure it all loaded. Type\r\n\r\n```>>> Date(19,2,2026).add_days(2)```\r\n\r\nYou should see\r\n\r\n```21-FEB-2026```\r\n\r\nWarning: You may notice that the library can take several seconds to import after the first install if you do a wildcard import of classes which rely on certain models. This is because financepy relies upon Numba to compile a lot of the models - resulting in calculation speeds similar to C/C++. This compile only takes place on the first import of the model and the compiled code is then cached on your machine. No further compilation will be required. As a consequence subsequent imports will be almost instant.\r\n\r\n## Quickstart Guide\r\n\r\n\ud83d\udc49 See [Quick Start Guide](./docs/QUICKSTART.md) to get going in 2 minutes!\r\n\r\n\r\n## Structure of Financepy\r\n\r\nThe structure of financepy is as follows\r\n```\r\n\u251c\u2500\u2500 market/\r\n\u251c\u2500\u2500 models/\r\n\u251c\u2500\u2500 products/\r\n\u251c\u2500\u2500 utils/\r\n```\r\n\r\nThe market folder contains objects linked to structured market data such as interest rate term structures, i.e `curves' and volatility term structures and surfaces.\r\n\r\n```\r\n\u251c\u2500\u2500 market/\r\n\u2502   \u251c\u2500\u2500 curves\r\n\u2502       \u251c\u2500\u2500 composite_discount_curve.py\r\n\u2502       \u251c\u2500\u2500 discount_curve_flat.py\r\n\u2502       \u251c\u2500\u2500 ...\r\n\u2502       \u251c\u2500\u2500 discount_curve.py\r\n\u2502   \u251c\u2500\u2500 prices\r\n\u2502   \u251c\u2500\u2500 volatility\r\n\u2502       \u251c\u2500\u2500 equity_vol_curve.py\r\n\u2502       \u251c\u2500\u2500 ...\r\n\u2502       \u251c\u2500\u2500 fx_vol_surface.py\r\n\u2502       \u251c\u2500\u2500 swaption_vol_surface.py\r\n```\r\nThe models folder contains mathematical pricing models.\r\n```\r\n\u251c\u2500\u2500 models/\r\n\u2502   \u251c\u2500\u2500 bachelier.py\r\n\u2502   \u251c\u2500\u2500 bdt_tree.py\r\n\u2502   \u251c\u2500\u2500 black_scholes.py\r\n\u2502   \u251c\u2500\u2500 ...\r\n\u2502   \u251c\u2500\u2500 vasicek_mc.py\r\n```\r\nThese model pricing functions are not usually called directly but are called from the products objects in the products folder. There is a module for each of the covered product types which are grouped into bonds, credit, equiy, fx and rates as follows:\r\n```\r\n\u251c\u2500\u2500 products/\r\n\u2502   \u251c\u2500\u2500 Bonds\r\n\u2502       \u251c\u2500\u2500 bond_convertible.py\r\n\u2502       \u251c\u2500\u2500 bond_future.py\r\n\u2502       \u251c\u2500\u2500 ...\r\n\u2502       \u251c\u2500\u2500 bond.py\r\n\u2502   \u251c\u2500\u2500 Credit\r\n\u2502       \u251c\u2500\u2500 cds_basket.py\r\n\u2502       \u251c\u2500\u2500 ...\r\n\u2502       \u251c\u2500\u2500 cds.py\r\n\u2502   \u251c\u2500\u2500 Equity\r\n\u2502       \u251c\u2500\u2500 equity_american_option.py\r\n\u2502       \u251c\u2500\u2500 ...\r\n\u2502       \u251c\u2500\u2500 equity_variance_swap.py\r\n\u2502   \u251c\u2500\u2500 FX\r\n\u2502       \u251c\u2500\u2500 fx_barrier_option.py\r\n\u2502       \u251c\u2500\u2500 ...\r\n\u2502       \u251c\u2500\u2500 fx_variance_swap.py\r\n\u2502   \u251c\u2500\u2500 Rates\r\n\u2502       \u251c\u2500\u2500 callable_swap.py\r\n\u2502       \u251c\u2500\u2500 ...\r\n\u2502       \u251c\u2500\u2500 ibor_swaption.py\r\n```\r\nFinally, we have the utils folder that contains useful classes such as dates, day counts and schedule generation\r\n```\r\n\u251c\u2500\u2500 utils/\r\n\u2502   \u251c\u2500\u2500 calendar.py\r\n\u2502   \u251c\u2500\u2500 day_count.py\r\n\u2502   \u251c\u2500\u2500 date\r\n\u2502   \u251c\u2500\u2500 schedule\r\n```\r\nand many more.\r\n\r\n## Notebooks\r\nThe notebooks folder contains over 90 example notebooks on how to use the library.\r\n\r\n## Disclaimer\r\nThis software is distributed FREE AND WITHOUT ANY WARRANTY. Report any bugs or concerns here as an issue.\r\n\r\n## Contributing\r\nIf you have a knowledge of Quantitative Finance and Python, then please consider contributing to this project. There are small tasks and big tasks to be done. Just look in the list of Issues and you may find something you can do. Before you begin, please comment in the issue thread in case someone else may be working on that issue. Or you can contact me directly at dominic.okane at edhec.edu. There are a number of requirements:\r\n\r\n* The code should be Pep8 compliant.\r\n* Comments are required for every class and function, and they should give a clear description.\r\n* At least one broad test case and a set of unit tests must be provided for every function.\r\n* Avoid very pythonic constructions. For example a loop is as good as a list comprehension. And with numba it can be faster. Readability and speed are the priorities.\r\n\r\n## Users\r\nIf you are a user and require some additional functionality, then please add it as an issue.\r\n\r\n## Overview\r\n\r\nFinancePy is a python-based library that is currently in beta version. It covers the following functionality:\r\n\r\n* Valuation and risk models for a wide range of equity, FX, interest rate and credit derivatives.\r\n\r\nAlthough it is written entirely in Python, it can achieve speeds comparable to C++ by using Numba. As a result the user has both the ability to examine the underlying code and the ability to perform pricing and risk at speeds which compare to a library written in C++.\r\n\r\nThe target audience for this library includes:\r\n\r\n* Students of finance and students of python\r\n* Academics teaching finance or conducting research into finance\r\n* Traders wishing to price or risk-manage a derivative.\r\n* Quantitative analysts seeking to price or reverse engineer a price.\r\n* Risk managers wishing to replicate and understand price sensitivity.\r\n* Portfolio managers wishing to check prices or calculate risk measures.\r\n* Fund managers wanting to value a portfolio or examine a trading strategy.\r\n\r\nUsers should have a good, but not advanced, understanding of Python. In terms of Python, the style of the library has been determined subject to the following criteria:\r\n\r\n1. To make the code as simple as possible so that those with a basic Python fluency can understand and check the code.\r\n2. To keep all the code in Python so users can look through the code to the lowest level.\r\n3. To offset the performance impact of (2) by leveraging Numba to make the code as fast as possible without resorting to Cython.\r\n4. To make the design product-based rather than model-based so someone wanting to price a specific product can easily find that without having to worry too much about the model \u2013 just use the default \u2013 unless they want to. For most products, a Monte-Carlo implementation has been provided both as a reference for testing and as a way to better understand how the product functions in terms of payments, their timings and conditions.\r\n5. To make the library as complete as possible so a user can find all their required finance-related functionality in one place. This is better for the user as they only have to learn one interface.\r\n6. To avoid complex designs. Limited inheritance unless it allows for significant code reuse. Some code duplication is OK, at least temporarily.\r\n7. To have good documentation and easy-to-follow examples.\r\n8. To make it easy for interested parties to contribute.\r\n\r\nIn many cases the valuations should be close to if not identical to those produced by financial systems such as Bloomberg. However for some products, larger value differences may arise due to differences in date generation and interpolation schemes. Over time it is hoped to reduce the size of such differences.\r\n\r\nImportant Note:\r\n\r\n* IF YOU HAVE ANY PRICING OR RISK EXAMPLES YOU WOULD LIKE REPLICATED, SEND SCREENSHOTS OF ALL THE UNDERLYING DATA, MODEL DETAILS AND VALUATION.\r\n* IF THERE IS A PRODUCT YOU WOULD LIKE TO HAVE ADDED, SEND ME THE REQUEST.\r\n* IF THERE IS FUNCTIONALITY YOU WOULD LIKE ADDED, SEND ME A REQUEST.\r\n\r\nThe underlying Python library is split into a number of major modules:\r\n\r\n* Utils - These are utility functions used to assist you with modelling a security. These include dates (Date), calendars, schedule generation, some finance-related mathematics functions and some helper functions.\r\n* Market - These are modules that capture the market information used to value a security. These include interest rate and credit curves, volatility surfaces and prices.\r\n* Models - These are the low-level models used to value derivative securities ranging from Black-Scholes to complex stochastic volatility models.\r\n* Products - These are the actual securities and range from Government bonds to Bermudan swaptions.\r\n\r\nAny product valuation is the result of the following data design:\r\n\r\n**VALUATION** = **PRODUCT** + **MODEL** + **MARKET**\r\n\r\nThe interface to each product has a value() function that will take a model and market to produce a price.\r\n\r\n## Author\r\n\r\nDominic O'Kane. I am a Professor of Finance at the EDHEC Business School in Nice, France. I have 12 years of industry experience and over 15 years of academic experience.\r\n\r\nContact me at dominic.okane at edhec.edu.\r\n\r\n## Dependencies\r\n\r\nFinancePy depends on Numpy, Numba, Scipy and basic python libraries such as os, sys and datetime.\r\n\r\n## Changelog\r\n\r\nSee the changelog for a detailed history of changes.\r\n\r\n## License\r\n\r\n GPL-3.0 License - See the license file in this folder for details.\r\n\r\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "A Finance Securities Valuation Library",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/domokane/FinancePy",
        "Source": "https://github.com/domokane/FinancePy",
        "Tracker": "https://github.com/domokane/FinancePy/issues"
    },
    "split_keywords": [
        "finance",
        " options",
        " bonds",
        " valuation",
        " derivatives"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a17e8c458dcbf2f31e661f30d2783717ddf64a739e9c61e9c9d937efeb5e2c24",
                "md5": "320e0d3cf457f8abb42881a0fd24790e",
                "sha256": "110e784122f485ae207239f44af473334f418d81bcbb958f5eda4e76956feca5"
            },
            "downloads": -1,
            "filename": "financepy-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "320e0d3cf457f8abb42881a0fd24790e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 793860,
            "upload_time": "2025-08-31T10:57:27",
            "upload_time_iso_8601": "2025-08-31T10:57:27.417909Z",
            "url": "https://files.pythonhosted.org/packages/a1/7e/8c458dcbf2f31e661f30d2783717ddf64a739e9c61e9c9d937efeb5e2c24/financepy-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a083544eebad0738f6b601cc81ade63ba829746681e01cad80a680cd6f193045",
                "md5": "e430222d792e29bc1e643a0d404901d6",
                "sha256": "ba13d6bc047a888bc66b86712e0e3c72ca91913904e6f18edbf027fb5a2fde6f"
            },
            "downloads": -1,
            "filename": "financepy-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "e430222d792e29bc1e643a0d404901d6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 11079251,
            "upload_time": "2025-08-31T10:57:35",
            "upload_time_iso_8601": "2025-08-31T10:57:35.173543Z",
            "url": "https://files.pythonhosted.org/packages/a0/83/544eebad0738f6b601cc81ade63ba829746681e01cad80a680cd6f193045/financepy-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-31 10:57:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "domokane",
    "github_project": "FinancePy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "numba",
            "specs": [
                [
                    "==",
                    "0.60.0"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "1.26.4"
                ]
            ]
        },
        {
            "name": "scipy",
            "specs": [
                [
                    "==",
                    "1.13.1"
                ]
            ]
        },
        {
            "name": "llvmlite",
            "specs": [
                [
                    "==",
                    "0.43.0"
                ]
            ]
        },
        {
            "name": "ipython",
            "specs": [
                [
                    "==",
                    "8.25.0"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    "==",
                    "2.3.1"
                ]
            ]
        },
        {
            "name": "matplotlib",
            "specs": [
                [
                    "==",
                    "3.10.5"
                ]
            ]
        }
    ],
    "lcname": "financepy"
}
        
Elapsed time: 0.76444s