- Introduction
- Installation
- TensorFlow training
- Development roadmap
- Examples
- Contributing
- Development
- Community
- Disclaimers
- License
This library provides high-performance components leveraging the hardware acceleration support and automatic differentiation of TensorFlow. The library will provide TensorFlow support for foundational mathematical methods, mid-level methods, and specific pricing models. The coverage is being rapidly expanded over the next few months.
The library is structured along three tiers:
-
Foundational methods. Core mathematical methods - optimisation, interpolation, root finders, linear algebra, random and quasi-random number generation, etc.
-
Mid-level methods. ODE & PDE solvers, Ito process framework, Diffusion Path Generators, Copula samplers etc.
-
Pricing methods and other quant finance specific utilities. Specific Pricing models (e.g Local Vol (LV), Stochastic Vol (SV), Stochastic Local Vol (SLV), Hull-White (HW)) and their calibration. Rate curve building and payoff descriptions.
We aim for the library components to be easily accessible at each level. Each layer will be accompanied by many examples which can be run independently of higher level components.
The easiest way to get started with the library is via the pip package.
First please install the most recent version of TensorFlow by following the TensorFlow installation instructions. For example, you could install TensorFlow using
pip install --upgrade tensorflow
or
pip install --upgrade tensorflow-gpu
if you want to use GPUs.
Then run
pip install --upgrade tf-quant-finance
If you use Python 3, you might need to use pip3 install
. You'll
maybe also have to use option --user
.
If you are not familiar with TensorFlow, a good place to get started is with the following self-study introduction to TensorFlow notebooks:
- Introduction to TensorFlow Part 1 - Basics.
- Introduction to TensorFlow Part 2 - Debugging and Control Flow.
- Introduction to TensorFlow Part 3 - Advanced Tensor Manipulation.
We are working on expanding the coverage of the library. Areas under active development are:
- Ito Processes: Framework for defining Ito processes. Includes methods for sampling paths from a process and for solving the associated backward Kolmogorov equation.
- Implementation of the following specific processes/models:
- Brownian Motion
- Geometric Brownian Motion
- Ornstein-Uhlenbeck
- Single factor Hull White model
- Heston model
- Local volatility model.
- Quadratic Local Vol model.
- SABR model
- ADI method for solving multi dimensional PDEs.
- Copulas: Support for defining and sampling from copulas.
- Model Calibration:
- Dupire local vol calibration.
- SABR model calibration.
- Rate curve fitting: Hagan-West algorithm for yield curve bootstrapping and the Monotone Convex interpolation scheme.
- Optimization:
- Conjugate gradient optimizer.
See tf_quant_finance/examples/
for end-to-end examples. It includes tutorial notebooks such as:
- American Option pricing under the Black-Scholes model
- Monte Carlo via Euler Scheme
- Black Scholes: Price and Implied Vol.
- Root search using Brent's method
- Optimization
The above links will open Jupyter Notebooks in Colab.
We're eager to collaborate with you! See CONTRIBUTING.md for a guide on how to contribute. This project adheres to TensorFlow's code of conduct. By participating, you are expected to uphold this code.
This section is meant for developers who want to contribute code to the library. If you are only interested in using the library, please follow the instructions in the Installation section.
This library has the following dependencies:
- Bazel
- Python 3 (Bazel uses Python 3 by default)
- TensorFlow
- TensorFlow Probability
- Numpy
- Scipy (used only in tests)
- Attrs
This library requires the Bazel build system. Please follow the Bazel installation instructions for your platform.
You can install TensorFlow and related dependencies using the pip3 install
command:
pip3 install --upgrade tensorflow tensorflow-probability numpy attrs scipy
Clone the GitHub repository:
git clone https://github.com/google/tf-quant-finance.git
After you run
cd tf_quant_finance
you can execute tests using the bazel test
command. For example,
bazel test tf_quant_finance/math/random/sobol:sobol_test
will run tests in sobol_test.py .
Tests will be run using the Python version 3. Please make sure that you can
run import tensorflow
in the Python 3 shell, otherwise tests might fail.
The official TF Quant Finance Docker images are located in the gcr.io container repository.
Images are tagged using the GitHub release version. Images contain all development dependencies. See Dockerfile for details.
You can pull the latest Docker image using
sudo docker pull gcr.io/tf-quant-finance-images/tf-quant-finance
To start a TF Quant Finance container, use the following command:
sudo docker run -it gcr.io/tf-quant-finance-images/tf-quant-finance
The following commands will build custom pip package from source and install it:
# sudo apt-get install bazel git python python-pip rsync # For Ubuntu.
git clone https://github.com/google/tf-quant-finance.git
cd tf-quant-finance
bazel build :build_pip_pkg
./bazel-bin/build_pip_pkg artifacts
pip install --user --upgrade artifacts/*.whl
-
GitHub repository: Report bugs or make feature requests.
-
TensorFlow Blog: Stay up to date on content from the TensorFlow team and best articles from the community.
-
[email protected]: Open mailing list for discussion and questions of this library.
-
TensorFlow Probability: This library will leverage methods from TensorFlow Probability (TFP).
This is not an officially supported Google product. This library is under active development. Interfaces may change at any time.
This library is licensed under the Apache 2 license (see LICENSE). This library uses Sobol primitive polynomials and initial direction numbers which are licensed under the BSD license.