Mathematical Foundations¶
This document establishes the mathematical framework underlying quantitative finance and the Neutryx implementation.
Table of Contents¶
- Probability Theory Foundations
- Stochastic Processes
- Stochastic Calculus
- Risk-Neutral Pricing
- Martingale Theory
- Change of Measure
Probability Theory Foundations¶
Probability Space¶
All financial models are defined on a filtered probability space \((\Omega, \mathcal{F}, \{\mathcal{F}_t\}_{t \geq 0}, \mathbb{P})\), where:
- \(\Omega\) is the sample space (set of all possible outcomes)
- \(\mathcal{F}\) is a \(\sigma\)-algebra of events
- \(\{\mathcal{F}_t\}_{t \geq 0}\) is a filtration (increasing family of \(\sigma\)-algebras representing information flow)
- \(\mathbb{P}\) is a probability measure
Reference: [Shreve, 2004], Chapter 1
Conditional Expectation¶
For a random variable \(X\) and \(\sigma\)-algebra \(\mathcal{G} \subseteq \mathcal{F}\), the conditional expectation \(\mathbb{E}[X | \mathcal{G}]\) is characterized by:
- \(\mathbb{E}[X | \mathcal{G}]\) is \(\mathcal{G}\)-measurable
- For all \(A \in \mathcal{G}\): \(\int_A \mathbb{E}[X | \mathcal{G}] \, d\mathbb{P} = \int_A X \, d\mathbb{P}\)
Properties: - Tower property: \(\mathbb{E}[\mathbb{E}[X | \mathcal{G}]] = \mathbb{E}[X]\) - Taking out what is known: \(\mathbb{E}[Y X | \mathcal{G}] = Y \mathbb{E}[X | \mathcal{G}]\) if \(Y\) is \(\mathcal{G}\)-measurable
Stochastic Processes¶
Brownian Motion¶
A Brownian motion (or Wiener process) \(\{W_t\}_{t \geq 0}\) is a continuous-time stochastic process with:
- \(W_0 = 0\) almost surely
- Independent increments: For \(0 \leq s < t\), \(W_t - W_s\) is independent of \(\mathcal{F}_s\)
- Stationary increments: \(W_t - W_s \sim \mathcal{N}(0, t-s)\)
- Continuous paths: \(t \mapsto W_t\) is continuous almost surely
Properties: - \(\mathbb{E}[W_t] = 0\), \(\text{Var}(W_t) = t\) - \(\text{Cov}(W_s, W_t) = \min(s, t)\) - Quadratic variation: \([W]_t = t\) (a.s.) - Non-differentiable: Paths are continuous but nowhere differentiable
Reference: [Shreve, 2004], Chapter 3; [Björk, 2009], Chapter 4
Implementation: All diffusion models in src/neutryx/models/ use Brownian motion as the fundamental noise source.
Geometric Brownian Motion¶
The geometric Brownian motion (GBM) is the classical model for stock prices:
Solution (via Itô's lemma):
Properties: - \(S_t > 0\) always (lognormal distribution) - \(\mathbb{E}[S_t] = S_0 e^{\mu t}\) - \(\text{Var}(S_t) = S_0^2 e^{2\mu t}(e^{\sigma^2 t} - 1)\) - Log-returns are normally distributed: \(\log(S_t/S_0) \sim \mathcal{N}((\mu - \sigma^2/2)t, \sigma^2 t)\)
Reference: [Shreve, 2004], Chapter 4; [Hull, 2022], Chapter 15
Implementation: Black-Scholes model in src/neutryx/models/bs.py
Poisson Process¶
A Poisson process \(\{N_t\}_{t \geq 0}\) with intensity \(\lambda > 0\) satisfies:
- \(N_0 = 0\)
- Independent increments
- \(N_t - N_s \sim \text{Poisson}(\lambda(t-s))\) for \(s < t\)
Properties: - \(\mathbb{E}[N_t] = \text{Var}(N_t) = \lambda t\) - Inter-arrival times are exponentially distributed: \(\text{Exp}(\lambda)\) - Compensated Poisson process: \(\tilde{N}_t = N_t - \lambda t\) is a martingale
Application: Jump models (Merton, Kou, Variance Gamma)
Reference: [Cont & Tankov, 2004], Chapter 2
Implementation: Jump-diffusion models in src/neutryx/models/jump_diffusion.py, kou.py, variance_gamma.py
Lévy Processes¶
A Lévy process \(\{X_t\}_{t \geq 0}\) is a càdlàg process with:
- \(X_0 = 0\)
- Independent increments
- Stationary increments
- Stochastic continuity
Lévy-Khintchine representation: The characteristic function has the form:
where \(\psi(u)\) is the characteristic exponent:
- \(\gamma \in \mathbb{R}\): drift
- \(\sigma \geq 0\): Gaussian component
- \(\nu\): Lévy measure (jump intensity)
Examples: - Brownian motion: \(\nu = 0\) - Poisson process: \(\nu = \lambda \delta_1\) (point mass at 1) - Variance Gamma: \(\nu(dx) = \frac{C}{|x|} e^{-M|x|} dx\) (infinite activity)
Reference: [Cont & Tankov, 2004], Chapters 3-4
Stochastic Calculus¶
Itô Integral¶
For a progressively measurable process \(\{X_t\}\) and Brownian motion \(\{W_t\}\), the Itô integral is:
Properties: - Martingale property: \(\mathbb{E}\left[\int_0^t X_s \, dW_s\right] = 0\) - Isometry: \(\mathbb{E}\left[\left(\int_0^t X_s \, dW_s\right)^2\right] = \mathbb{E}\left[\int_0^t X_s^2 \, ds\right]\) - Not path-by-path: Defined as a limit in \(L^2(\mathbb{P})\)
Reference: [Shreve, 2004], Chapter 4; [Björk, 2009], Chapter 5
Itô's Lemma¶
Itô's Lemma is the chain rule for stochastic calculus. If \(X_t\) satisfies:
and \(f(x, t) \in C^{2,1}\), then:
Shorthand: \(dW_t^2 = dt\), \(dt \cdot dW_t = 0\), \(dt^2 = 0\)
Example: Deriving GBM solution
Given \(dS_t = \mu S_t dt + \sigma S_t dW_t\), let \(f(S, t) = \log S\):
Integrating: \(\log S_t = \log S_0 + (\mu - \sigma^2/2)t + \sigma W_t\)
Reference: [Shreve, 2004], Chapter 4; [Björk, 2009], Chapter 4
Implementation: Itô's lemma is used throughout for model derivations and is leveraged via JAX automatic differentiation.
Multidimensional Itô's Lemma¶
For \(\mathbf{X}_t \in \mathbb{R}^n\) satisfying:
where \(\mathbf{W}_t\) is a \(d\)-dimensional Brownian motion, and \(f(\mathbf{x}, t) \in C^{2,1}\):
where \(dX_t^i dX_t^j = (\boldsymbol{\Sigma} \boldsymbol{\Sigma}^T)_{ij} dt\)
Application: Multi-asset derivatives, Heston model (2D system)
Reference: [Shreve, 2004], Chapter 4
Risk-Neutral Pricing¶
Fundamental Theorem of Asset Pricing¶
The First Fundamental Theorem states:
A market model is arbitrage-free if and only if there exists an equivalent martingale measure \(\mathbb{Q}\) (risk-neutral measure).
Under \(\mathbb{Q}\), discounted asset prices are martingales:
where \(B_t = e^{\int_0^t r_s ds}\) is the money market account.
Second Fundamental Theorem: The market is complete if and only if the risk-neutral measure \(\mathbb{Q}\) is unique.
Reference: [Shreve, 2004], Chapter 5; [Björk, 2009], Chapter 10
Risk-Neutral Pricing Formula¶
The arbitrage-free price of a contingent claim \(V_T = g(S_T)\) at time \(t\) is:
Interpretation: 1. Compute expected payoff under \(\mathbb{Q}\) (not real-world \(\mathbb{P}\)) 2. Discount at risk-free rate \(r\)
Example: European call option
Reference: [Hull, 2022], Chapter 13; [Shreve, 2004], Chapter 5
Implementation: All pricing engines in src/neutryx/engines/ implement risk-neutral pricing via Monte Carlo, PDE, or Fourier methods.
Girsanov Theorem¶
Girsanov's Theorem allows us to change the drift of a Brownian motion by changing the probability measure.
Let \(\{W_t\}\) be a Brownian motion under \(\mathbb{P}\). Define the Radon-Nikodym derivative:
Then under \(\mathbb{Q}\):
is a Brownian motion.
Application: Deriving the risk-neutral measure from physical measure
Under \(\mathbb{P}\): \(dS_t = \mu S_t dt + \sigma S_t dW_t\)
Choose \(\theta_t = \frac{\mu - r}{\sigma}\) (market price of risk). Then under \(\mathbb{Q}\):
Reference: [Shreve, 2004], Chapter 5; [Björk, 2009], Chapter 11
Martingale Theory¶
Martingales¶
A process \(\{M_t\}\) adapted to \(\{\mathcal{F}_t\}\) is a martingale under \(\mathbb{P}\) if:
- \(\mathbb{E}[|M_t|] < \infty\) for all \(t\)
- \(\mathbb{E}[M_t | \mathcal{F}_s] = M_s\) for all \(s \leq t\)
Interpretation: Fair game - the expected future value equals the current value given current information.
Examples: - Brownian motion \(W_t\) is a martingale - \(W_t^2 - t\) is a martingale (compensated quadratic variation) - Discounted stock price under \(\mathbb{Q}\): \(e^{-rt} S_t\)
Reference: [Shreve, 2004], Chapter 3; [Björk, 2009], Chapter 6
Doob's Optional Stopping Theorem¶
For a martingale \(\{M_t\}\) and stopping time \(\tau\) with \(\mathbb{E}[\tau] < \infty\):
Application: Pricing American options (optimal stopping problems)
Reference: [Shreve, 2004], Chapter 3
Change of Measure¶
Change of Numeraire¶
The change of numeraire technique allows pricing in different units.
Let \(N_t\) be a strictly positive traded asset (numeraire). Under the \(N\)-forward measure \(\mathbb{Q}^N\):
Common numeraires: - Money market account: \(N_t = B_t = e^{rt}\) → standard risk-neutral measure \(\mathbb{Q}\) - Zero-coupon bond: \(N_t = P(t, T)\) → \(T\)-forward measure \(\mathbb{Q}^T\) - Stock price: \(N_t = S_t\) → stock measure (useful for volatility derivatives)
Example: Black's formula for bond options
Using the \(T\)-forward measure simplifies pricing: forward rates are martingales.
Reference: [Shreve, 2004], Chapter 6; [Brigo & Mercurio, 2006], Chapter 2
Implementation: Used implicitly in interest rate models (src/neutryx/models/vasicek.py, hull_white.py)
Cameron-Martin-Girsanov Formula¶
The general form of measure change (for continuous semimartingales):
where \([X]_s\) is the quadratic variation of \(X\).
Reference: [Shreve, 2004], Chapter 5
Feynman-Kac Formula¶
The Feynman-Kac theorem connects PDEs and expectations, providing the foundation for both PDE and Monte Carlo pricing.
Theorem: Suppose \(X_t\) satisfies:
and define:
Then \(u(x, t)\) satisfies the PDE:
with terminal condition \(u(x, T) = g(x)\).
Black-Scholes PDE: For GBM under \(\mathbb{Q}\) (\(\mu = r\)):
Reference: [Shreve, 2004], Chapter 5; [Björk, 2009], Chapter 7
Implementation:
- Monte Carlo: Directly samples the expectation (src/neutryx/engines/mc.py)
- PDE: Discretizes and solves the PDE (src/neutryx/models/pde.py)
Numerical Implementation Notes¶
JAX and Automatic Differentiation¶
Neutryx leverages JAX for automatic differentiation, which computes derivatives via:
- Forward mode: Efficient for \(\mathbb{R}^n \to \mathbb{R}^m\) with \(n \ll m\)
- Reverse mode (backpropagation): Efficient for \(\mathbb{R}^n \to \mathbb{R}^m\) with \(m \ll n\)
Greeks computation: \(\frac{\partial V}{\partial S}\), \(\frac{\partial^2 V}{\partial S^2}\) computed exactly via autodiff
Reference: [Bradbury et al., 2018]
Implementation: All models support automatic Greeks via JAX: src/neutryx/valuations/greeks/
Precision and Stability¶
- Float32 vs Float64: Configurable precision (GPU prefers float32, CPU can use float64)
- Log-space computations: Avoid overflow in characteristic functions
- Variance reduction: Reduces simulation noise, improving convergence
Implementation: Precision set globally; variance reduction in src/neutryx/engines/variance_reduction.py
Summary¶
This mathematical foundation provides:
- Probability framework: Filtered probability spaces, conditional expectation
- Stochastic processes: Brownian motion, Lévy processes, jump processes
- Stochastic calculus: Itô's lemma, quadratic variation
- Risk-neutral pricing: Fundamental theorems, martingale measures
- Measure changes: Girsanov theorem, change of numeraire
- Feynman-Kac: PDE-expectation duality
All Neutryx models and numerical methods are built on these rigorous mathematical foundations, as detailed in References.