Skip to main content

High-performance TensorFlow library for quantitative finance.

Project description

TF Quant Finance: TensorFlow based Quant Finance Library

Build Status

Table of contents

  1. Introduction
  2. Installation
  3. TensorFlow training
  4. Development roadmap
  5. Examples
  6. Contributing
  7. Development
  8. Community
  9. Disclaimers
  10. License

Introduction

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 expanded over the next few months.

The library is structured along three tiers:

  1. Foundational methods. Core mathematical methods - optimisation, interpolation, root finders, linear algebra, random and quasi-random number generation, etc.

  2. Mid-level methods. ODE & PDE solvers, Ito process framework, Diffusion Path Generators, Copula samplers etc.

  3. 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, payoff descriptions and schedule generation.

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.

Installation

The easiest way to get started with the library is via the pip package.

Note that library requires Python 3 and Tensorflow >= 2.1.

First please install the most recent version of TensorFlow by following the TensorFlow installation instructions. For example, you could install TensorFlow using

pip3 install --upgrade tensorflow

Then run

pip3 install --upgrade tf-quant-finance

You maybe also have to use the option --user.

TensorFlow training

If you are not familiar with TensorFlow, a good place to get started is with the following self-study introduction to TensorFlow notebooks:

Development roadmap

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
  • 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.
  • Support for dates, day-count conventions, holidays, etc.

Examples

See tf_quant_finance/examples/ for end-to-end examples. It includes tutorial notebooks such as:

The above links will open Jupyter Notebooks in Colab.

Contributing

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.

Development

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.

Development dependencies

This library has the following dependencies:

  1. Bazel
  2. Python 3 (Bazel uses Python 3 by default)
  3. TensorFlow nightly build (most functions should work with TensorFLow 2.1)
  4. TensorFlow Probability nightly build
  5. Numpy version 1.16 or higher
  6. 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 tf-nightly tfp-nightly numpy==1.16.0 attrs

Commonly used commands

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_ops/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.

Docker images

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

Building a custom pip package

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

Community

  1. GitHub repository: Report bugs or make feature requests.

  2. TensorFlow Blog: Stay up to date on content from the TensorFlow team and best articles from the community.

  3. tf-quant-finance@google.com: Open mailing list for discussion and questions of this library.

  4. TensorFlow Probability: This library will leverage methods from TensorFlow Probability (TFP).

Disclaimers

This is not an officially supported Google product. This library is under active development. Interfaces may change at any time.

License

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

tff_nightly-0.0.1.dev20200409-py2.py3-none-any.whl (1.0 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file tff_nightly-0.0.1.dev20200409-py2.py3-none-any.whl.

File metadata

  • Download URL: tff_nightly-0.0.1.dev20200409-py2.py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for tff_nightly-0.0.1.dev20200409-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7ad9de51bdbe46d64bd8584b6ddf0824a12d3934eb5692e10ec37bd651fdb06f
MD5 c07413a7db9564d0657c17f02e386a45
BLAKE2b-256 a7b497641142b190c3ed418e94ac7ee80433a0a118c7bdfcf67f9608ec274cfa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page