r/quant • u/Objective_Chair_8271 • 3d ago
Technical Infrastructure I built a Python library for composing stochastic processes like algebraic objects
Hi all,
I've been working on an open-source Python library called spxa and wanted to share it in case it's useful to anyone here.
The core idea is treating continuous-time stochastic processes as first-class algebraic objects. You can compose them with regular operator:X + 0.5 * Y, X @ Y for subordination. The Lévy-Khintchine triplets compose in closed form. It also has a computational graph engine that compiles pricing pipelines and does reverse-mode autodiff for Greeks (Delta, Gamma, Vega, etc.) without finite-difference stepping.
It covers about 69 processes (Brownian, Poisson, Heston, SABR, rough Bergoni, CIR, Hull-White, etc.) plus PDE solvers, calibration tools, volatility surfaces, and rates models. Everything is unit-tested against closed-form theory where it exists.
Quick example:
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 It's on PyPI (pip install spxa) and the source is on GitHub.
1
u/BinaryAlchemist42 2d ago
Neat idea treating the processes as algebraic objects. Curious how the reverse-mode Greeks hold up with barriers or digitals under MC. Pathwise AD usually gives you a zero delta there unless the payoff is smoothed. Is that handled somewhere, or out of scope for now?
1
u/AutoModerator 3d ago
This post will be manually reviewed by a moderator due to the submitting account being less than 7 days old or having less than 20 karma. Please be patient and do not try to resubmit it - a mod will review the post soon.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.