tf-q-finance


Nametf-q-finance JSON
Version 0.0.1.dev35 PyPI version JSON
download
home_pagehttps://github.com/paolodelia99/tf-quant-finance
SummaryHigh-performance TensorFlow library for quantitative finance.
upload_time2025-07-11 10:38:41
maintainerNone
docs_urlNone
authorGoogle Inc.
requires_python>=3.9
licenseNone
keywords tensorflow quantitative finance hpc gpu option pricing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TF Quant Finance: TensorFlow based Quant Finance Library

**Making [TF Quant Finance](https://github.com/google/tf-quant-finance) working again**: since the official repo has not been mantained for year and achieved, the following fork is making this library alive again. Feel free to contribute to the library fixing bugs and implementing new features.

## Table of contents
1. [Introduction](#introduction)
2. [Installation](#installation)
3. [TensorFlow training](#tensorflow-training)
4. [Development roadmap](#development-roadmap)
5. [Examples](#examples)
6. [Contributing](#contributing)
7. [Development](#development)
8. [Community](#community)
9. [Disclaimers](#disclaimers)
10. [License](#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 that can run independently of
higher-level components.

## Installation

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

Note that the library requires Python 3.10 and Tensorflow >= 2.18.

First, please install the most recent version of TensorFlow by following
the [TensorFlow installation instructions](https://tensorflow.org/install).
For example, you could install TensorFlow

```sh
pip3 install --upgrade tensorflow tf_keras
```

Then run

```sh
pip3 install --upgrade tf-q-finance
```

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

## TensorFlow training

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

   * [Introduction to TensorFlow Part 1 - Basics](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Introduction_to_TensorFlow_Part_1_-_Basics.ipynb).
   * [Introduction to TensorFlow Part 2 - Debugging and Control Flow](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Introduction_to_TensorFlow_Part_2_-_Debugging_and_Control_Flow.ipynb).
   * [Introduction to TensorFlow Part 3 - Advanced Tensor Manipulation](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Introduction_to_TensorFlow_Part_3_-_Advanced_Tensor_Manipulation.ipynb).

## Development roadmap

We are working on expanding the coverage of the library. Areas under active development are:

  * Ito Processes: Framework for defining [Ito processes](https://en.wikipedia.org/wiki/It%C3%B4_calculus#It%C3%B4_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
      * One-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/`](https://github.com/paolodelia99/tf-quant-finance/tree/master/tf_quant_finance/examples)
for end-to-end examples. It includes tutorial notebooks such as:

  *   [American Option pricing under the Black-Scholes model](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/American_Option_Black_Scholes.ipynb)
  *   [Monte Carlo via Euler Scheme](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Monte_Carlo_Euler_Scheme.ipynb)
  *   [Black Scholes: Price and Implied Vol](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Black_Scholes_Price_and_Implied_Vol.ipynb)
  *   [Forward and Backward mode gradients in TFF](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Forward_Backward_Diff.ipynb)
  *   [Root search using Brent's method](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Root_Search.ipynb)
  *   [Optimization](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Optimization.ipynb)
  *   [Swap Curve Fitting](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Swap_Curve_Fitting.ipynb)
  *   [Vectorization and XLA compilation](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Vectorization_and_XLA_compilation.ipynb)

The above links will open Jupyter Notebooks in Colab.

## Contributing

We're eager to collaborate with you! See [CONTRIBUTING.md](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 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](#installation) section.

### Development dependencies

This library has the following dependencies:

1.  Python 3 (Bazel uses Python 3 by default)
3.  TensorFlow version >= 2.19
4.  TensorFlow Probability version >= 0.25.0
5.  Numpy version 2.1.3
6.  Attrs
7.  Dataclasses (not needed if your Python version >= 3.7)


You can install TensorFlow and related dependencies using the ```pip3 install```
command:

```sh
pip3 install --upgrade tf-nightly tensorflow-probability==0.12.1 numpy==1.21 attrs dataclasses
```

### Commonly used commands

Clone the GitHub repository:

```sh
git clone https://github.com/paolodelia99/tf-quant-finance.git
```

After you run

```sh
cd tf_quant_finance
```

you can execute tests using the ```run_tests``` script in the scripts folder. For example,

```sh
source scripts/run_tests.sh
```

will run tests in
[sobol_test.py](https://github.com/paolodelia99/tf-quant-finance/blob/master/tf_quant_finance/math/random_ops/sobol/sobol_test.py)
.

Tests run using Python version 3. Please make sure that you can
run ```import tensorflow``` in the Python 3 shell. Otherwise, tests might fail.

### Building a custom pip package

The following commands will build custom pip package from source and install it:

```sh
# sudo apt-get install bazel git python python-pip rsync # For Ubuntu.
git clone https://github.com/paolodelia99/tf-quant-finance.git
cd tf-quant-finance
source scripts/build_wheel.sh # scripts/build_wheel.ps1 if you are on windows
pip install --user --upgrade dist/*.whl
```

## Community

1. [GitHub repository](https://github.com/paolodelia99/tf-quant-finance): Report bugs or make feature requests.

2. [TensorFlow Blog](https://blog.tensorflow.org/): Stay up to date on content from the TensorFlow team and best articles from the community.

3. TensorFlow Probability: This library will leverage methods from [TensorFlow Probability](https://www.tensorflow.org/probability) (TFP).

## License

This library is licensed under the Apache 2 license (see [LICENSE](LICENSE)). This library uses Sobol primitive polynomials and initial direction numbers
which are licensed under the BSD license.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/paolodelia99/tf-quant-finance",
    "name": "tf-q-finance",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "tensorflow, quantitative, finance, hpc, gpu, option, pricing",
    "author": "Google Inc.",
    "author_email": "\"Google Inc.\" <tf-quant-finance@google.com>, Paolo D'Elia <paolo.delia99@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/3d/16/1d83c2e03a176a636136f911067daeac412e6841d0ba6f9667d72761e481/tf_q_finance-0.0.1.dev35.tar.gz",
    "platform": null,
    "description": "# TF Quant Finance: TensorFlow based Quant Finance Library\n\n**Making [TF Quant Finance](https://github.com/google/tf-quant-finance) working again**: since the official repo has not been mantained for year and achieved, the following fork is making this library alive again. Feel free to contribute to the library fixing bugs and implementing new features.\n\n## Table of contents\n1. [Introduction](#introduction)\n2. [Installation](#installation)\n3. [TensorFlow training](#tensorflow-training)\n4. [Development roadmap](#development-roadmap)\n5. [Examples](#examples)\n6. [Contributing](#contributing)\n7. [Development](#development)\n8. [Community](#community)\n9. [Disclaimers](#disclaimers)\n10. [License](#license)\n\n## Introduction\n\nThis library provides high-performance components leveraging the hardware\nacceleration support and automatic differentiation of TensorFlow. The\nlibrary will provide TensorFlow support for foundational mathematical methods,\nmid-level methods, and specific pricing models. The coverage is being\nexpanded over the next few months.\n\nThe library is structured along three tiers:\n\n1. **Foundational methods**.\nCore mathematical methods - optimisation, interpolation, root finders,\nlinear algebra, random and quasi-random number generation, etc.\n\n2. **Mid-level methods**.\nODE & PDE solvers, Ito process framework, Diffusion Path Generators,\nCopula samplers etc.\n\n3. **Pricing methods and other quant finance specific utilities**.\nSpecific Pricing models (e.g., Local Vol (LV), Stochastic Vol (SV),\nStochastic Local Vol (SLV), Hull-White (HW)) and their calibration.\nRate curve building, payoff descriptions, and schedule generation.\n\nWe aim for the library components to be easily accessible at each level. Each layer will be accompanied by many examples that can run independently of\nhigher-level components.\n\n## Installation\n\nThe easiest way to get started with the library is via the pip package.\n\nNote that the library requires Python 3.10 and Tensorflow >= 2.18.\n\nFirst, please install the most recent version of TensorFlow by following\nthe [TensorFlow installation instructions](https://tensorflow.org/install).\nFor example, you could install TensorFlow\n\n```sh\npip3 install --upgrade tensorflow tf_keras\n```\n\nThen run\n\n```sh\npip3 install --upgrade tf-q-finance\n```\n\nYou maybe also have to use the option ```--user```.\n\n## TensorFlow training\n\nIf you are not familiar with TensorFlow, an excellent place to get started is with the\nfollowing self-study introduction to TensorFlow notebooks:\n\n   * [Introduction to TensorFlow Part 1 - Basics](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Introduction_to_TensorFlow_Part_1_-_Basics.ipynb).\n   * [Introduction to TensorFlow Part 2 - Debugging and Control Flow](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Introduction_to_TensorFlow_Part_2_-_Debugging_and_Control_Flow.ipynb).\n   * [Introduction to TensorFlow Part 3 - Advanced Tensor Manipulation](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Introduction_to_TensorFlow_Part_3_-_Advanced_Tensor_Manipulation.ipynb).\n\n## Development roadmap\n\nWe are working on expanding the coverage of the library. Areas under active development are:\n\n  * Ito Processes: Framework for defining [Ito processes](https://en.wikipedia.org/wiki/It%C3%B4_calculus#It%C3%B4_processes).\n  Includes methods for sampling paths from a process and for solving the\n  associated backward Kolmogorov equation.\n  * Implementation of the following specific processes/models:\n      * Brownian Motion\n      * Geometric Brownian Motion\n      * Ornstein-Uhlenbeck\n      * One-Factor Hull-White model\n      * Heston model\n      * Local volatility model.\n      * Quadratic Local Vol model.\n      * SABR model\n  * Copulas: Support for defining and sampling from copulas.\n  * Model Calibration:\n      * Dupire local vol calibration.\n      * SABR model calibration.\n  * Rate curve fitting: Hagan-West algorithm for yield curve bootstrapping and the Monotone Convex interpolation scheme.\n  * Support for dates, day-count conventions, holidays, etc.\n\n\n## Examples\n\nSee [`tf_quant_finance/examples/`](https://github.com/paolodelia99/tf-quant-finance/tree/master/tf_quant_finance/examples)\nfor end-to-end examples. It includes tutorial notebooks such as:\n\n  *   [American Option pricing under the Black-Scholes model](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/American_Option_Black_Scholes.ipynb)\n  *   [Monte Carlo via Euler Scheme](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Monte_Carlo_Euler_Scheme.ipynb)\n  *   [Black Scholes: Price and Implied Vol](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Black_Scholes_Price_and_Implied_Vol.ipynb)\n  *   [Forward and Backward mode gradients in TFF](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Forward_Backward_Diff.ipynb)\n  *   [Root search using Brent's method](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Root_Search.ipynb)\n  *   [Optimization](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Optimization.ipynb)\n  *   [Swap Curve Fitting](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Swap_Curve_Fitting.ipynb)\n  *   [Vectorization and XLA compilation](https://colab.research.google.com/github/google/tf-quant-finance/blob/master/tf_quant_finance/examples/jupyter_notebooks/Vectorization_and_XLA_compilation.ipynb)\n\nThe above links will open Jupyter Notebooks in Colab.\n\n## Contributing\n\nWe're eager to collaborate with you! See [CONTRIBUTING.md](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.\n\n## Development\n\nThis section is for developers who want to contribute code to the\nlibrary. If you are only interested in using the library, please follow the\ninstructions in the [Installation](#installation) section.\n\n### Development dependencies\n\nThis library has the following dependencies:\n\n1.  Python 3 (Bazel uses Python 3 by default)\n3.  TensorFlow version >= 2.19\n4.  TensorFlow Probability version >= 0.25.0\n5.  Numpy version 2.1.3\n6.  Attrs\n7.  Dataclasses (not needed if your Python version >= 3.7)\n\n\nYou can install TensorFlow and related dependencies using the ```pip3 install```\ncommand:\n\n```sh\npip3 install --upgrade tf-nightly tensorflow-probability==0.12.1 numpy==1.21 attrs dataclasses\n```\n\n### Commonly used commands\n\nClone the GitHub repository:\n\n```sh\ngit clone https://github.com/paolodelia99/tf-quant-finance.git\n```\n\nAfter you run\n\n```sh\ncd tf_quant_finance\n```\n\nyou can execute tests using the ```run_tests``` script in the scripts folder. For example,\n\n```sh\nsource scripts/run_tests.sh\n```\n\nwill run tests in\n[sobol_test.py](https://github.com/paolodelia99/tf-quant-finance/blob/master/tf_quant_finance/math/random_ops/sobol/sobol_test.py)\n.\n\nTests run using Python version 3. Please make sure that you can\nrun ```import tensorflow``` in the Python 3 shell. Otherwise, tests might fail.\n\n### Building a custom pip package\n\nThe following commands will build custom pip package from source and install it:\n\n```sh\n# sudo apt-get install bazel git python python-pip rsync # For Ubuntu.\ngit clone https://github.com/paolodelia99/tf-quant-finance.git\ncd tf-quant-finance\nsource scripts/build_wheel.sh # scripts/build_wheel.ps1 if you are on windows\npip install --user --upgrade dist/*.whl\n```\n\n## Community\n\n1. [GitHub repository](https://github.com/paolodelia99/tf-quant-finance): Report bugs or make feature requests.\n\n2. [TensorFlow Blog](https://blog.tensorflow.org/): Stay up to date on content from the TensorFlow team and best articles from the community.\n\n3. TensorFlow Probability: This library will leverage methods from [TensorFlow Probability](https://www.tensorflow.org/probability) (TFP).\n\n## License\n\nThis library is licensed under the Apache 2 license (see [LICENSE](LICENSE)). This library uses Sobol primitive polynomials and initial direction numbers\nwhich are licensed under the BSD license.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "High-performance TensorFlow library for quantitative finance.",
    "version": "0.0.1.dev35",
    "project_urls": {
        "Homepage": "https://github.com/paolodelia99/tf-quant-finance",
        "Repository": "https://github.com/paolodelia99/tf-quant-finance"
    },
    "split_keywords": [
        "tensorflow",
        " quantitative",
        " finance",
        " hpc",
        " gpu",
        " option",
        " pricing"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2bb1bfbb0498e7a25fbacfdaf211c9aeb33836ad8968a411982f7026bb476011",
                "md5": "2cb97669f9f5367a6ee5b302f6985aad",
                "sha256": "2714919942da3e779ff2e3a876617d3f79be2e42631382c6c9d6fb23da44f93f"
            },
            "downloads": -1,
            "filename": "tf_q_finance-0.0.1.dev35-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2cb97669f9f5367a6ee5b302f6985aad",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 769561,
            "upload_time": "2025-07-11T10:38:37",
            "upload_time_iso_8601": "2025-07-11T10:38:37.287115Z",
            "url": "https://files.pythonhosted.org/packages/2b/b1/bfbb0498e7a25fbacfdaf211c9aeb33836ad8968a411982f7026bb476011/tf_q_finance-0.0.1.dev35-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3d161d83c2e03a176a636136f911067daeac412e6841d0ba6f9667d72761e481",
                "md5": "f713c983ffd2ed6011debd397cdb79e2",
                "sha256": "9230f5a29a6c69b25ca60b476a4079d0ed61bcf27f1d5004817e5eff3fe793d8"
            },
            "downloads": -1,
            "filename": "tf_q_finance-0.0.1.dev35.tar.gz",
            "has_sig": false,
            "md5_digest": "f713c983ffd2ed6011debd397cdb79e2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 538410,
            "upload_time": "2025-07-11T10:38:41",
            "upload_time_iso_8601": "2025-07-11T10:38:41.585410Z",
            "url": "https://files.pythonhosted.org/packages/3d/16/1d83c2e03a176a636136f911067daeac412e6841d0ba6f9667d72761e481/tf_q_finance-0.0.1.dev35.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-11 10:38:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "paolodelia99",
    "github_project": "tf-quant-finance",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tf-q-finance"
}
        
Elapsed time: 0.58201s