spxa
Stochastic processes as first-class algebraic objects. Exact Lévy–Khintchine arithmetic, a differentiable computational graph, and reverse-mode Greeks.
spxa is a Python library for quantitative research. It treats continuous-time
stochastic processes as first-class algebraic objects: compose them with +,
*, @, and their Lévy–Khintchine triplets add in closed form. A computational
graph engine compiles pricing pipelines and routes to analytical, Fourier, batch,
or Monte Carlo backends, with reverse-mode autodiff for machine-precision Greeks.
Install
pip install spxa
Dev install:
git clone https://github.com/Nityahapani/spxa.git
cd spxa
pip install -e ".[dev]"
Quickstart
import spxa
from spxa import VarianceGamma, GammaProcess
X = VarianceGamma(sigma=0.2, nu=0.1, theta=-0.1)
Y = GammaProcess(a=1.0, b=2.0)
Z = X + 0.5 * Y # exact triplet arithmetic
print(Z.exactness) # ExactnessLevel.EXACT
print(Z.triplet.sigma_sq) # 0.0
print(float(Z.triplet.b)) # 0.14542109130283806
print(Z.exactness == spxa.ExactnessLevel.EXACT) # True
Discovery and laws
spxa.discovery runs the algebra backwards. It searches compositions of
primitives for the one that explains a return series, its summary
statistics, or option prices. spxa.laws turns the axioms into executable
tests: declare a law, and spxa searches random processes for a shrunk
counterexample.
import numpy as np
from spxa import VarianceGamma
from spxa.discovery import discover, grammar_from_names
from spxa.laws import compositions, expect_close, law
from spxa.laws.quantities import mean
paths = VarianceGamma(sigma=0.2, nu=0.3, theta=-0.1).simulate(2000, 1, 2000 / 52, np.random.default_rng(0))
report = discover(np.diff(paths[0]), dt=1 / 52, grammar=grammar_from_names(["BM", "VG", "NIG"], max_terms=1))
print(report.best.model.structure.key()) # VG + Drift
@law(X=compositions(max_depth=1), Y=compositions(max_depth=1))
def mean_is_additive(X, Y):
expect_close(mean(X + Y), mean(X) + mean(Y))
print(mean_is_additive.check(n_examples=100).status) # verified
spxa-discover returns prices.csv and spxa-laws run both from the shell.
See the discovery and laws
guides.
| Module | Purpose |
|---|---|
spxa.core |
Process algebra, Lévy–Khintchine triplets, exactness lattice |
spxa.zoo |
69 stochastic processes |
spxa.graph |
Differentiable computational graph & autodiff tape |
spxa.diff |
Greeks, pricers, neural SDEs |
spxa.calibration |
MLE, GMM, Kalman/particle filters, surface calibration |
spxa.copula |
Archimedean, elliptical, extreme-value copulas |
spxa.control |
Merton portfolio, market making, HJB solvers |
spxa.pde |
Finite-difference PDE/PIDE solvers |
spxa.rates / spxa.market |
Curves, swaps, bonds, bootstrapping |
spxa.vol |
SVI/SSVI surfaces, local vol, rough vol |
spxa.rough |
Fractional volatility, rBergomi |
spxa.morph |
Model morphing & barycenters |
spxa.geom |
Information geometry |
spxa.signature |
Rough path signatures |
spxa.discovery |
Process discovery: structures from returns or option prices |
spxa.laws |
Property-based testing of process laws |
Docs
Citation
@software{spxa,
author = {Nityahapani},
title = {spxa: Stochastic Process Algebra \& Computational Graph Engine},
url = {https://github.com/Nityahapani/spxa},
version = {1.4.0},
year = {2026},
}
Contributing
See CONTRIBUTING.md. Tests and the full audit suite must pass:
python -m pytest tests/ -q
python audits/run_master_audit.py
License
Metadata
Release files for spxa 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spxa-1.4.0.tar.gz | 3.0 MB | With provenance | Details for spxa-1.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spxa-1.4.0-py3-none-any.whl | Python 3 | none | any | Details for spxa-1.4.0-py3-none-any.whl |
Total release size: 4.6 MB
Release files / spxa-1.4.0.tar.gz
| Download URL | spxa-1.4.0.tar.gz |
|---|---|
| Size | 3.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0975dbd2a936a14c46b63c182ae888e068e865dccd33b0a30e1c47f071fa323e
|
|
BLAKE2b-256 checksum How to use checksums |
7fb394bca6ae19fa1e7e151198286ae9c6674313c0cacc640cee7b8583ea0d4a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / spxa-1.4.0-py3-none-any.whl
| Download URL | spxa-1.4.0-py3-none-any.whl |
|---|---|
| Size | 1.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c0e55855a84fecf79e58831591e977f017b3790060bed1cb242b4f215a60b68
|
|
BLAKE2b-256 checksum How to use checksums |
25d1744efbbba789e940c84c186eb6e4a142716c81290387e99b65c1af67323d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for spxa 1.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for spxa-1.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.