Skip to main content

Unlocking Explicit Moments for Affine Jump Diffusions

Documentation Status PyPI License: MIT

Description

ajdmom is a Python library for automatically deriving explicit, closed-form moment formulas for well-established Affine Jump Diffusion (AJD) processes. It significantly enhances the usability of AJD models by providing both unconditional moments and conditional moments, up to any positive integer order.

It also serves as a valuable tool for sensitivity analysis, providing partial derivatives of these moments with respect to model parameters. The package features a modular architecture, facilitating easy adaptation and extension by researchers. ajdmom is open-source and readily available for installation from the Python Package Index (PyPI):

pip install ajdmom

or GitHub:

pip install git+https://github.com/xmlongan/ajdmom

The moments derived by ajdmom have broad applications in quantitative finance and stochastic modeling, including:

  • Density Approximation: Accurately approximating unknown probability densities (e.g., through Pearson distributions) by matching derived moments. This enables efficient European option pricing under the concerned models.

  • Exact Simulation: Facilitating the exact simulation of AJD models in an efficient way when compared to characteristic function inversion methods.

  • Parameter Estimation: Formulating explicit moment estimators for AJD models whose 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.

Supported Models & Moment Types

Model Unconditional Moments Conditional Moments - I Conditional Moments - II
Heston ✔️ N/A
1FSVJ ✔️ N/A
2FSV ✔️ N/A
2FSVJ ✔️ N/A
SRJD
SVVJ
SVCJ
SVIJ ✔️ ✔️

Notes:

  • Implemented: The feature is fully implemented.
  • ✔️ Applicable: The feature is applicable to this model but not yet implemented.
  • N/A Not Applicable: The feature is not relevant or applicable for this model.
  • Unconditional Moments: Include raw moments ($\mathbb{E}[y_n^l]$), central moments (central moments), and autocovariances (autocovariance).
    • Note: Autocovariances are not yet available for SRJD and SVCJ.
  • Conditional Moments - I: Derivation where the initial state of the variance process ($v_0$) is given.
  • Conditional moments - II: Derivation where both the initial state ($v_0$) and the realized jump times and jump sizes in the variance process over the concerned interval are given beforehand.

Simple Usage

To get the formula for the first moment $\mathbb{E}[y_n]$ for the Heston Stochastic Volatility (SV) 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 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 reproduces the first moment of the Heston 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. This structure allows ajdmom to perform symbolic differentiation and other advanced operations directly on the moment formulas.

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.

Release files for ajdmom 3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ajdmom 3.1
File Size Uploaded
ajdmom-3.1.tar.gz 1.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for ajdmom 3.1
File Interpreter ABI Platform
ajdmom-3.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.7 MB

Release files / ajdmom-3.1.tar.gz

Download URL ajdmom-3.1.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
e348e6e3edf6c1974fa3d68db3a71d90501b136fb81fa5df76d01d7b7c19b9f0
BLAKE2b-256 checksum
How to use checksums
9df6d50bebc94a749a301a89618b965c2a5eba5465869b826b6e33ea8a41dca8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / ajdmom-3.1-py3-none-any.whl

Download URL ajdmom-3.1-py3-none-any.whl
Size 128.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1da386c4d5398a1decdeaae5ea0f1f0cb25865506f9afa293ea0eff0ea6f9b6c
BLAKE2b-256 checksum
How to use checksums
97ebb2ca911d5114105234704859d34af1fb149dc24d4991b70d90317bee50c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

3.1 This release

2 release files

3.0

2 release files

2.0

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page