Loading repository data…
Loading repository data…
domokane / repository
A Python Finance Library that focuses on the pricing and risk-management of Financial Derivatives, including fixed-income, equity, FX and credit derivatives.
A one-stop library for pricing and risk-managing options, futures and other financial instruments. See below for a comprehensive overview.
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
from financepy.utils import *
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.
👉 See Quick Start Guide to get going in 2 minutes!
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.
The notebooks folder contains over 90 example notebooks on how to use the library.
This software is distributed FREE AND WITHOUT ANY WARRANTY. Report any bugs or concerns here as an issue.
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:
If you are a user and require some additional functionality, then please add it as an issue.
FinancePy is a python-based library that is currently in beta version. It covers the following functionality:
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:
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:
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:
The underlying Python library is split into a number of major modules:
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.
I was a Professor of Finance at the EDHEC Business School in Nice, France. I have 12 years of industry experience and over 18 years of academic experience.
Contact me at dominic.okane at edhec.edu.
FinancePy depends on Numpy, Numba, Scipy and basic python libraries such as os, sys and datetime.
See the changelog for a detailed history of changes.
GPL-3.0 License - See the license file in this folder for details.