A Finance Library
Quick Start Guide
FinancePy can be installed from pip using the following command:
pip install financepy
To upgrade an existing installation type:
pip install --upgrade financepy
I have encountered problems using Anaconda3-2020.07 due to some Numba and LLVMLite problems. However Anaconda3-2020.02 works.
Using FinancePy in a Jupyter Notebook
Once financepy has been installed, it is easy to get started.
Just download the project and examine the set of Jupyter Notebooks in the notebooks folder.
A pdf manual describing all of the functions can be found in the project directory.
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 wishing to learn derivative pricing and Python.
- Professors wishing to teach derivative pricing and Python.
- 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 a price.
- Portfolio managers wishing to check prices or calculate risk measures.
- Fund managers wanting to value a portfolio or examine a trading strategy.
- Structurers or financial engineers seeking to examine the pricing of a derivative structure.
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:
- To make the code as simple as possible so that those with a basic Python fluency can understand and check the code.
- To keep all the code in Python so users can look through the code to the lowest level.
- To offset the performance impact of (2) by leveraging Numba to make the code as fast as possible without resorting to Cython.
- 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.
- 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.
- To avoid complex designs. Limited inheritance unless it allows for significant code reuse. Some code duplication is OK, at least temporarily.
- To have good documentation and easy-to-follow examples.
- 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.
- 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.
Contact me at email@example.com.
The Library Design
The underlying Python library is split into a number of major modules:
- Finutils - These are utility functions used to assist you with modelling a security. These include dates (FinDate), 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.
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 10 years of academic experience.
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.
Contributions are very welcome. There are a number of requirements:
- You should use CamelCase i.e. variables of the form optionPrice.
- Comments are required for every class and function and they should be clear.
- At least one test case must be provided for every function.
- Follow the style of the code as currently written. This may change over time but please use the current style as your guide.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size financepy-0.186-py3-none-any.whl (496.7 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size financepy-0.186.tar.gz (337.9 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for financepy-0.186-py3-none-any.whl