# 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:
``` 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:
```
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](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/d9/de/5bbc8796d1caedf3abedf6360e6c5f58dc486231aff05d0d2a9453639ff5/ajdmom-2.0.tar.gz",
"platform": null,
"description": "# ajdmom\n\n## Description\n\nThe package `ajdmom` is a `Python` package designed for automatically deriving moment formulas \nfor the well-established affine jump diffusion (AJD) processes. `ajdmom` can produce explicit closed-form \nexpressions for moments or conditional moments of any order, significantly enhancing the usability \nof AJD models. Additionally, `ajdmom` can compute partial derivatives of these moments with respect to the \nmodel parameters, offering a valuable tool for sensitivity analysis. The package's modular architecture makes \nit easy for adaptation and extension by researchers. `ajdmom` is open-source and readily available for \ninstallation from GitHub or the `Python` package index (PyPI).\n\nCurrently, `ajdmom` supports computations of moments, central moments, and covariances for the Heston \nStochastic Volatility (SV) model and its three AJD extensions: \n- SVJ (SV with jumps in the price), \n- Two-Factor SV, \n- Two-Factor SV with jumps in the price. \n\nMoreover, the package can compute partial \nderivatives of these quantities with respect to model parameters. \n\nIn addition, the package supports \ncomputations of *conditional* moments and *conditional* central moments for another three AJD extensions:\n- SVVJ (SV with jumps in the variance), \n- SVIJ (SV with independent jumps in the price and variance),\n- SVCJ (SV with contemporaneous jumps in the price and variance). \n\nThe computations of *conditional* moments and *conditional* central moments is also supported for\n- SRJD (Square-Root Jump Diffusion) process.\n\nThe moments and covariances obtained through `ajdmom` have far-reaching implications for multiple domains, \nincluding financial modelling, simulation and parameter estimation. For simulations, these moments can \nestablish the underlying probability distributions, leading to significant reductions in computational \ntime when contrasted with conventional numerical CF inversion techniques. In parameter estimation, \nthe moments serve to formulate explicit moment estimators while the likelihood functions are not analytically \nsolvable. Consequently, `ajdmom` has the potential to become an essential instrument for researchers and \npractitioners demanding comprehensive AJD model analysis.\n\n## Simple Usage\n\nTo get the formula for the first moment $\\mathbb{E}[y_n]$ for the Heston Stochastic Volatility model\n( $y_n$ denotes the return over the nth interval of length $h$ ), run 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``` \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 principal 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 yields the first moment of the One-Factor SV model: \n$\\mathbb{E}[y_n] = (\\mu-\\theta/2)h$. This demonstrates that the `ajdmom` package successfully encapsulates \nthe model's dynamics into a computationally manipulable form, specifically leveraging a custom dictionary \ndata structure, referred to as `Poly`, to encode the moment's expression.\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": "2.0",
"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": "",
"digests": {
"blake2b_256": "b64258557a8f92ce73ce1be04f59fd6fd9fce19e59c9f7db88e815e5eb3f26bf",
"md5": "ba5446a69ce79cc3b6dd4f69d3cb30c2",
"sha256": "5ab89840efc6dd92583fdb0b183c1efb37a1a0883dfd96f436723be964cd1772"
},
"downloads": -1,
"filename": "ajdmom-2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ba5446a69ce79cc3b6dd4f69d3cb30c2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 83236,
"upload_time": "2024-09-12T12:38:42",
"upload_time_iso_8601": "2024-09-12T12:38:42.752479Z",
"url": "https://files.pythonhosted.org/packages/b6/42/58557a8f92ce73ce1be04f59fd6fd9fce19e59c9f7db88e815e5eb3f26bf/ajdmom-2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d9de5bbc8796d1caedf3abedf6360e6c5f58dc486231aff05d0d2a9453639ff5",
"md5": "e4773977ea48bba1ed95a6258421a579",
"sha256": "128e43c982c95ac4813b17a0ff9ee8f75ee0c4211d90400a6cb11a870c7336a9"
},
"downloads": -1,
"filename": "ajdmom-2.0.tar.gz",
"has_sig": false,
"md5_digest": "e4773977ea48bba1ed95a6258421a579",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 2171182,
"upload_time": "2024-09-12T12:38:45",
"upload_time_iso_8601": "2024-09-12T12:38:45.790864Z",
"url": "https://files.pythonhosted.org/packages/d9/de/5bbc8796d1caedf3abedf6360e6c5f58dc486231aff05d0d2a9453639ff5/ajdmom-2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-12 12:38:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "xmlongan",
"github_project": "ajdmom",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ajdmom"
}