ajdmom


Nameajdmom JSON
Version 3.1 PyPI version JSON
download
home_pageNone
SummaryDerivation of moment and covariance formulas for Affine Jump Diffusion processes.
upload_time2025-07-22 04:44:37
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords heston model affine jump diffusion moment computation stochastic volatility
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Unlocking Explicit Moments for Affine Jump Diffusions

[![Documentation Status](https://img.shields.io/badge/docs-available-blue.svg?style=flat)](http://yyschools.com/ajdmom/)
[![PyPI](https://img.shields.io/pypi/v/ajdmom)](https://pypi.org/project/ajdmom/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/xmlongan/ajdmom/blob/main/LICENSE)


## 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](https://latex.codecogs.com/svg.image?\inline&space;\mathbb{E}[\bar{y}_n^l])), 
  and autocovariances
  (![autocovariance](https://latex.codecogs.com/svg.image?\inline&space;cov(y_n^{l_1},y_{n+1}^{l_2}))). 
  - *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:

```python
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:

```python
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](https://github.com/xmlongan/ajdmom).

## Support

For support in using this software, submit an [issue](https://github.com/xmlongan/ajdmom/issues/new).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ajdmom",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "Heston model, affine jump diffusion, moment computation, stochastic volatility",
    "author": null,
    "author_email": "Yan-Feng Wu <wuyf@fudan.edu.cn>",
    "download_url": "https://files.pythonhosted.org/packages/9d/f6/d50bebc94a749a301a89618b965c2a5eba5465869b826b6e33ea8a41dca8/ajdmom-3.1.tar.gz",
    "platform": null,
    "description": "# Unlocking Explicit Moments for Affine Jump Diffusions\n\n[![Documentation Status](https://img.shields.io/badge/docs-available-blue.svg?style=flat)](http://yyschools.com/ajdmom/)\n[![PyPI](https://img.shields.io/pypi/v/ajdmom)](https://pypi.org/project/ajdmom/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/xmlongan/ajdmom/blob/main/LICENSE)\n\n\n## Description\n\n`ajdmom` is a Python library for **automatically deriving explicit, closed-form\nmoment formulas** for well-established Affine Jump Diffusion (AJD) processes. \nIt significantly enhances the usability of AJD models by providing both \n**unconditional moments** and **conditional moments**, up to any positive integer\norder.\n\nIt also serves as a valuable tool for sensitivity analysis, **providing partial\nderivatives** of these moments with respect to model parameters. The package \nfeatures a **modular architecture**, facilitating easy adaptation and extension \nby researchers. `ajdmom` is open-source and readily available for installation \nfrom the Python Package Index (PyPI):\n```\npip install ajdmom\n```\nor GitHub:\n```\npip install git+https://github.com/xmlongan/ajdmom\n```\n\nThe moments derived by `ajdmom` have **broad applications** in quantitative finance \nand stochastic modeling, including:\n\n- **Density Approximation**: Accurately approximating unknown probability densities \n  (e.g., through Pearson distributions) by matching derived moments. This enables \n  efficient European option pricing under the concerned models.\n\n- **Exact Simulation**: Facilitating the exact simulation of AJD models in an \n  efficient way when compared to characteristic function inversion methods.\n\n- **Parameter Estimation**: Formulating explicit moment estimators for AJD models \n  whose likelihood functions are not analytically solvable.\n\nConsequently, `ajdmom` has the potential to become an essential instrument for \nresearchers and practitioners demanding comprehensive AJD model analysis.\n\n### Supported Models & Moment Types\n\n| Model | Unconditional Moments | Conditional Moments - I | Conditional Moments - II |\n|:-----:|:---------------------:|:-----------------------:|:------------------------:|\n| Heston|           \u2705          |           \u2714\ufe0f            |           N/A           |\n| 1FSVJ |           \u2705          |           \u2714\ufe0f            |           N/A           |\n| 2FSV  |           \u2705          |           \u2714\ufe0f            |           N/A           |\n| 2FSVJ |           \u2705          |           \u2714\ufe0f            |           N/A           |\n| SRJD  |           \u2705          |            \u2705           |            \u2705           |\n| SVVJ  |           \u2705          |            \u2705           |            \u2705           |\n| SVCJ  |           \u2705          |            \u2705           |            \u2705           |\n| SVIJ  |          \u2714\ufe0f           |           \u2714\ufe0f            |            \u2705           |\n\nNotes: \n\n- \u2705 **Implemented:** The feature is fully implemented.\n- \u2714\ufe0f **Applicable:** The feature is applicable to this model but not yet implemented. \n- **N/A Not Applicable:** The feature is not relevant or applicable for this model. \n- **Unconditional Moments:** Include raw moments ($\\mathbb{E}[y_n^l]$), \n  central moments (![central moments](https://latex.codecogs.com/svg.image?\\inline&space;\\mathbb{E}[\\bar{y}_n^l])), \n  and autocovariances\n  (![autocovariance](https://latex.codecogs.com/svg.image?\\inline&space;cov(y_n^{l_1},y_{n&plus;1}^{l_2}))). \n  - *Note: Autocovariances are not yet available for SRJD and SVCJ.*\n- **Conditional Moments - I:** Derivation where the initial state of the variance \n  process ($v_0$) is given.\n- **Conditional moments - II:** Derivation where both the initial state ($v_0$) and \n  the realized jump times and jump sizes in the variance process over the concerned\n  interval are given beforehand.\n\n## Simple Usage\n\nTo get the formula for the first moment $\\mathbb{E}[y_n]$ for the Heston Stochastic\nVolatility (SV) model ( $y_n$ denotes the return over the nth interval of length $h$ ), \nrun the following code snippet:\n\n```python\nfrom ajdmom import mdl_1fsv # mdl_1fsv -> mdl_1fsvj, mdl_2fsv, mdl_2fsvj\nfrom pprint import pprint\n\nm1 = mdl_1fsv.moment_y(1)   # 1 in moment_y(1) -> 2,3,4...\n\n# moment_y() -> cmoment_y()             : central moment\n# dpoly(m1, wrt), wrt = 'k','theta',... : partial derivative\n\nmsg = \"which is a Poly with attribute keyfor = \\n{}\"\nprint(\"moment_y(1) = \"); pprint(m1); print(msg.format(m1.keyfor))\n```\n\nwhich produces:\n\n```python\nmoment_y(1) = \n{(0, 1, 0, 0, 1, 0, 0, 0): Fraction(-1, 2),\n (0, 1, 0, 1, 0, 0, 0, 0): Fraction(1, 1)}\nwhich is a Poly with attribute keyfor = \n('e^{-kh}', 'h', 'k^{-}', 'mu', 'theta', 'sigma_v', 'rho', 'sqrt(1-rho^2)')\n```\n\nWithin the produced results, the two key-value pairs, namely (0,1,0,0,1,0,0,0): Fraction(-1,2) and \n(0,1,0,1,0,0,0,0): Fraction(1,1), correspond to the following expressions:\n\n$$\n-\\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,\n$$\n\n$$\n1\\times e^{-0kh}h^1k^{-0}\\mu^1\\theta^0\\sigma_v^0\\rho^0\\left(\\sqrt{1-\\rho^2}\\right)^0,\n$$\n\nrespectively. The summation of these terms reproduces the first moment of the Heston\nSV model: $\\mathbb{E}[y_n] = (\\mu-\\theta/2)h$. This demonstrates that the `ajdmom` \npackage successfully encapsulates the model's dynamics into a computationally \nmanipulable form, specifically leveraging a custom dictionary data structure, \nreferred to as `Poly`, to encode the moment's expression. This structure allows \n`ajdmom` to perform symbolic differentiation and other advanced operations directly \non the moment formulas.\n\n## Documentation\n\nThe documentation is hosted on <http://www.yyschools.com/ajdmom/>\n\n## Ongoing Development\n\nThis code is being developed on an on-going basis at the author's [Github site](https://github.com/xmlongan/ajdmom).\n\n## Support\n\nFor support in using this software, submit an [issue](https://github.com/xmlongan/ajdmom/issues/new).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Derivation of moment and covariance formulas for Affine Jump Diffusion processes.",
    "version": "3.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/xmlongan/ajdmom/issues",
        "Homepage": "https://github.com/xmlongan/ajdmom"
    },
    "split_keywords": [
        "heston model",
        " affine jump diffusion",
        " moment computation",
        " stochastic volatility"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "97ebb2ca911d5114105234704859d34af1fb149dc24d4991b70d90317bee50c8",
                "md5": "9ad66b413ae1a995328abf3914d1f81a",
                "sha256": "1da386c4d5398a1decdeaae5ea0f1f0cb25865506f9afa293ea0eff0ea6f9b6c"
            },
            "downloads": -1,
            "filename": "ajdmom-3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9ad66b413ae1a995328abf3914d1f81a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 128260,
            "upload_time": "2025-07-22T04:44:35",
            "upload_time_iso_8601": "2025-07-22T04:44:35.620151Z",
            "url": "https://files.pythonhosted.org/packages/97/eb/b2ca911d5114105234704859d34af1fb149dc24d4991b70d90317bee50c8/ajdmom-3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "9df6d50bebc94a749a301a89618b965c2a5eba5465869b826b6e33ea8a41dca8",
                "md5": "5664427d3c48d5716c1126c832e73b94",
                "sha256": "e348e6e3edf6c1974fa3d68db3a71d90501b136fb81fa5df76d01d7b7c19b9f0"
            },
            "downloads": -1,
            "filename": "ajdmom-3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5664427d3c48d5716c1126c832e73b94",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 1562089,
            "upload_time": "2025-07-22T04:44:37",
            "upload_time_iso_8601": "2025-07-22T04:44:37.696665Z",
            "url": "https://files.pythonhosted.org/packages/9d/f6/d50bebc94a749a301a89618b965c2a5eba5465869b826b6e33ea8a41dca8/ajdmom-3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-22 04:44:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xmlongan",
    "github_project": "ajdmom",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ajdmom"
}
        
Elapsed time: 1.24505s