Derivation of moment and covariance formulas for Affine Jump Diffusion processes.
Project description
Unlocking Explicit Moments for Affine Jump Diffusions
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 (
), and autocovariances (
).
- 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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ajdmom-3.1.tar.gz.
File metadata
- Download URL: ajdmom-3.1.tar.gz
- Upload date:
- Size: 1.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e348e6e3edf6c1974fa3d68db3a71d90501b136fb81fa5df76d01d7b7c19b9f0
|
|
| MD5 |
5664427d3c48d5716c1126c832e73b94
|
|
| BLAKE2b-256 |
9df6d50bebc94a749a301a89618b965c2a5eba5465869b826b6e33ea8a41dca8
|
File details
Details for the file ajdmom-3.1-py3-none-any.whl.
File metadata
- Download URL: ajdmom-3.1-py3-none-any.whl
- Upload date:
- Size: 128.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1da386c4d5398a1decdeaae5ea0f1f0cb25865506f9afa293ea0eff0ea6f9b6c
|
|
| MD5 |
9ad66b413ae1a995328abf3914d1f81a
|
|
| BLAKE2b-256 |
97ebb2ca911d5114105234704859d34af1fb149dc24d4991b70d90317bee50c8
|