Skip to main content

Derivation of moment and covariance formulas for Affine Jump Diffusion processes.

Project description

ajdmom

Description

The package ajdmom is a Python package designed for automatically deriving moment formulas for the well-established affine jump diffusion (AJD) processes. ajdmom can produce explicit closed-form expressions for moments or conditional moments of any order, significantly enhancing the usability of AJD models. Additionally, ajdmom can compute partial derivatives of these moments with respect to the model parameters, offering a valuable tool for sensitivity analysis. The package's modular architecture makes it easy for adaptation and extension by researchers. ajdmom is open-source and readily available for installation from GitHub or the Python package index (PyPI).

Currently, ajdmom supports computations of moments, central moments, and covariances for the Heston Stochastic Volatility (SV) model and its three AJD extensions:

  • SVJ (SV with jumps in the price),
  • Two-Factor SV,
  • Two-Factor SV with jumps in the price.

Moreover, the package can compute partial derivatives of these quantities with respect to model parameters.

In addition, the package supports computations of conditional moments and conditional central moments for another three AJD extensions:

  • SVVJ (SV with jumps in the variance),
  • SVIJ (SV with independent jumps in the price and variance),
  • SVCJ (SV with contemporaneous jumps in the price and variance).

The computations of conditional moments and conditional central moments is also supported for

  • SRJD (Square-Root Jump Diffusion) process.

The moments and covariances obtained through ajdmom have far-reaching implications for multiple domains, including financial modelling, simulation and parameter estimation. For simulations, these moments can establish the underlying probability distributions, leading to significant reductions in computational time when contrasted with conventional numerical CF inversion techniques. In parameter estimation, the moments serve to formulate explicit moment estimators while the likelihood functions are not analytically solvable. Consequently, ajdmom has the potential to become an essential instrument for researchers and practitioners demanding comprehensive AJD model analysis.

Simple Usage

To get the formula for the first moment $\mathbb{E}[y_n]$ for the Heston Stochastic Volatility model ( $y_n$ denotes the return over the nth interval of length $h$ ), run the following code snippet:

from ajdmom import mdl_1fsv # mdl_1fsv -> mdl_1fsvj, mdl_2fsv, mdl_2fsvj
from pprint import pprint

m1 = mdl_1fsv.moment_y(1)   # 1 in moment_y(1) -> 2,3,4...

# moment_y() -> cmoment_y()             : central moment
# dpoly(m1, wrt), wrt = 'k','theta',... : partial derivative

msg = "which is a Poly with attribute keyfor = \n{}"
print("moment_y(1) = "); pprint(m1); print(msg.format(m1.keyfor))

which produces:

moment_y(1) = 
{(0, 1, 0, 0, 1, 0, 0, 0): Fraction(-1, 2),
 (0, 1, 0, 1, 0, 0, 0, 0): Fraction(1, 1)}
which is a Poly with attribute keyfor = 
('e^{-kh}', 'h', 'k^{-}', 'mu', 'theta', 'sigma_v', 'rho', 'sqrt(1-rho^2)')

Within the produced results, the two principal key-value pairs, namely (0,1,0,0,1,0,0,0): Fraction(-1,2) and (0,1,0,1,0,0,0,0): Fraction(1,1), correspond to the following expressions:

$$ -\frac{1}{2}\times e^{-0kh}h^1k^{-0}\mu^0\theta^1\sigma_v^0\rho^0\left(\sqrt{1-\rho^2}\right)^0, $$

$$ 1\times e^{-0kh}h^1k^{-0}\mu^1\theta^0\sigma_v^0\rho^0\left(\sqrt{1-\rho^2}\right)^0, $$

respectively. The summation of these terms yields the first moment of the One-Factor SV model: $\mathbb{E}[y_n] = (\mu-\theta/2)h$. This demonstrates that the ajdmom package successfully encapsulates the model's dynamics into a computationally manipulable form, specifically leveraging a custom dictionary data structure, referred to as Poly, to encode the moment's expression.

Documentation

The documentation is hosted on http://www.yyschools.com/ajdmom/

Ongoing Development

This code is being developed on an on-going basis at the author's Github site.

Support

For support in using this software, submit an issue.

Project details


Download files

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

Source Distribution

ajdmom-2.0.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

ajdmom-2.0-py3-none-any.whl (83.2 kB view details)

Uploaded Python 3

File details

Details for the file ajdmom-2.0.tar.gz.

File metadata

  • Download URL: ajdmom-2.0.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.19

File hashes

Hashes for ajdmom-2.0.tar.gz
Algorithm Hash digest
SHA256 128e43c982c95ac4813b17a0ff9ee8f75ee0c4211d90400a6cb11a870c7336a9
MD5 e4773977ea48bba1ed95a6258421a579
BLAKE2b-256 d9de5bbc8796d1caedf3abedf6360e6c5f58dc486231aff05d0d2a9453639ff5

See more details on using hashes here.

File details

Details for the file ajdmom-2.0-py3-none-any.whl.

File metadata

  • Download URL: ajdmom-2.0-py3-none-any.whl
  • Upload date:
  • Size: 83.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.19

File hashes

Hashes for ajdmom-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ab89840efc6dd92583fdb0b183c1efb37a1a0883dfd96f436723be964cd1772
MD5 ba5446a69ce79cc3b6dd4f69d3cb30c2
BLAKE2b-256 b64258557a8f92ce73ce1be04f59fd6fd9fce19e59c9f7db88e815e5eb3f26bf

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