Package: tff-nightly
TF Quant Finance: TensorFlow based Quant Finance LibraryTable of contentsIntroductionInstallationTensorFlow trainingDevelopment roadmapExamplesContributingDevelopmentCommunityDisclaimersLicenseIntroductionThis 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: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, 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.InstallationThe easiest way to get started with the library is via the pip package.Note that the library requires Python 3.7 and Tensorflow >= 2.7.First, please install the most recent version of TensorFlow by following
theTensorFlow installation instructions.
For example, you could install TensorFlowpip3install--upgradetensorflowThen runpip3install--upgradetf-quant-financeYou maybe also have to use the option--user.TensorFlow trainingIf 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.Introduction to TensorFlow Part 2 - Debugging and Control Flow.Introduction to TensorFlow Part 3 - Advanced Tensor Manipulation.Development roadmapWe are working on expanding the coverage of the library. Areas under active development are:Ito Processes: Framework for definingIto 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 MotionGeometric Brownian MotionOrnstein-UhlenbeckOne-Factor Hull-White modelHeston modelLocal volatility model.Quadratic Local Vol model.SABR modelCopulas: 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.ExamplesSeetf_quant_finance/examples/for end-to-end examples. It includes tutorial notebooks such as:American Option pricing under the Black-Scholes modelMonte Carlo via Euler SchemeBlack Scholes: Price and Implied VolForward and Backward mode gradients in TFFRoot search using Brent's methodOptimizationSwap Curve FittingVectorization and XLA compilationThe above links will open Jupyter Notebooks in Colab.ContributingWe're eager to collaborate with you! SeeCONTRIBUTING.mdfor a guide on how to contribute. This project adheres to TensorFlow's code of conduct. By participating, you are expected to uphold this code.DevelopmentThis 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 theInstallationsection.Development dependenciesThis library has the following dependencies:BazelPython 3 (Bazel uses Python 3 by default)TensorFlow version >= 2.7TensorFlow Probability version between v0.11.0 and v0.12.1Numpy version 1.21 or higherAttrsDataclasses (not needed if your Python version >= 3.7)This library requires theBazelbuild system. Please follow theBazel installation instructionsfor your platform.You can install TensorFlow and related dependencies using thepip3 installcommand:pip3install--upgradetf-nightlytensorflow-probability==0.12.1numpy==1.21attrsdataclassesCommonly used commandsClone the GitHub repository:gitclonehttps://github.com/google/tf-quant-finance.gitAfter you runcdtf_quant_financeyou can execute tests using thebazel testcommand. For example,bazeltesttf_quant_finance/math/random_ops/sobol:sobol_testwill run tests insobol_test.py.Tests run using Python version 3. Please make sure that you can
runimport tensorflowin the Python 3 shell. Otherwise, tests might fail.Building a custom pip packageThe following commands will build custom pip package from source and install it:# sudo apt-get install bazel git python python-pip rsync # For Ubuntu.gitclonehttps://github.com/google/tf-quant-finance.gitcdtf-quant-finance
bazelbuild:build_pip_pkg
./bazel-bin/build_pip_pkgartifacts
pipinstall--user--upgradeartifacts/*.whlCommunityGitHub 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.tf-quant-finance@googlegroups.com: Open mailing list for discussion and questions of this library.TensorFlow Probability: This library will leverage methods fromTensorFlow Probability(TFP).DisclaimersGoogle does not officially support this product. This library is under active development, and interfaces may change at any time.LicenseThis library is licensed under the Apache 2 license (seeLICENSE). This library uses Sobol primitive polynomials and initial direction numbers
which are licensed under the BSD license.