Economic Invariants
This page is the source of truth for qualitative, economics-driven tests of the solver. It complements exact-solution tests and convergence/consistency tests. Exact-solution tests verify a known closed form; economic-invariant tests verify that the numerical result has the sign, ordering, symmetry, or limit that the model's mathematics predicts.
The exact model formulations and derivations live in Exact Solutions in Stochastic Optimal Control. This page only concerns qualitative properties of the resulting values and controls.
Why these tests exist
Exact-solution tests cannot catch every error:
- A model may solve a well-posed but wrong equation.
- A solver may converge to the wrong sign, monotonicity, or boundary behavior in a regime with no closed form.
- A control optimizer may return finite but economically nonsensical quotes.
- A stochastic solver may produce unstable sign changes hidden by averaging.
Economic invariants are high-signal, low-cost guards against those failures. They are deterministic where possible; stochastic solvers use fixed seeds or repeated runs with a statistical tolerance.
Invariant taxonomy
Every economic test is assigned one or more of these labels.
R1. Symmetry and parity
The value and controls respect the symmetries of the model.
R2. Inventory skew and no-crossing
Quotes create a price incentive to reduce inventory. For the convention used throughout this codebase, a bid fill increases inventory and an ask fill decreases inventory.
R3. Parameter monotonicity and directional sensitivity
A parameter change moves the value or control in the direction predicted by the economics.
R4. Degenerate and limit reduction
A model parameter set to a limit reduces the model to a simpler reference.
R5. Terminal and boundary behavior
The solution satisfies known terminal or boundary facts.
R6. Well-posedness and stability
Results are finite, sign-correct, and repeatable.
R7. Cross-solver consistency
Independent numerical methods agree where their approximations overlap.
Current test layout
The current economic-style tests are spread across the existing model-specific folders. The structure is kept as-is.
| Location | Coverage |
|---|---|
solver/tests/numerical/physics/edge_cases.rs | AS symmetry, zero-vol, zero-inventory, drift/impact reduction, American put bounds |
solver/tests/numerical/physics/hawkes.rs | Hawkes value sign and inventory symmetry |
solver/tests/numerical/physics/bilateral_hawkes.rs | Bilateral Hawkes sign, symmetry, side sensitivity, terminal conditions |
solver/tests/numerical/fdm_hawkes/validity.rs | Hawkes control scales with intensity |
solver/tests/numerical/fdm_hawkes/degenerate.rs | Hawkes reduces to AS |
solver/tests/numerical/fdm_heston/validity.rs | Heston finiteness and vol-of-vol sensitivity |
solver/tests/numerical/fdm_heston/parameter_relations.rs | Heston variance/theta/kappa/xi/rho behavior |
solver/tests/numerical/fdm_heston/degenerate.rs | Heston reduces to AS |
solver/tests/numerical/bsde_hawkes/intensity_sensitivity.rs | BSDE Hawkes intensity sensitivity |
solver/tests/numerical/bsde_heston/parameter_relations.rs | BSDE Heston terminal invariants |
solver/tests/numerical/bsde_heston/spread_sensitivity.rs | BSDE Heston vol-of-vol sensitivity |
solver/tests/numerical/bsde_heston/rho_stability.rs | BSDE Heston rho stability and no-crossing |
solver/tests/numerical/bsde_correctness/ | Exact matches and solution consistency |
solver/tests/numerical/bsde_vs_fdm/ | FD/BSDE agreement |
Per-model invariants and their mathematics
Each invariant below includes the economic argument that justifies the assertion. The argument follows the model code, not a generic reference.
Avellaneda-Stoikov
The value function separates as
\[ V(t, q, S) = -\exp(-\gamma (X + q S + \theta(t, q))) \]
The optimal half-spreads are
\[ \delta_b = \text{base} - fwd[0] \] \[ \delta_a = \text{base} + bwd[0] \] \[ \text{base} = (1/\gamma) \ln(1 + \gamma/\kappa) \]
where \(fwd[0] = V(q+1) - V(q)\) and \(bwd[0] = V(q) - V(q-1)\).
\(bid(0) = ask(0)\)
At \(q = 0\) the model is symmetric in the jump directions. The inventory gradient term vanishes at zero inventory because \(\theta(t, q)\) is even in \(q\). Hence \(fwd[0] = bwd[0]\) and both spreads equal the base spread.
\(bid(q) = ask(-q)\) and \(ask(q) = bid(-q)\)
The AS model has no drift and no permanent impact, so \(\theta(t, q) = \theta(t, -q)\). Substituting \(q \to -q\) swaps the forward and backward differences, which swaps the two spread formulas.
Zero volatility gives the base spread
When \(\sigma = 0\), the inventory risk term \(-0.5 \gamma \sigma^2 q^2\) vanishes,
so \(\theta(t, q)\) is flat and both directional derivatives are zero. The
spread therefore equals base.
Positive zero-inventory spread
The base spread is positive because \(\gamma > 0\), \(\kappa > 0\), and \(\ln(1 + \gamma/\kappa) > 0\).
Avellaneda-Stoikov with drift and impact
The reduction tests check that the extensions reproduce the base model in the limit:
AvellanedaDrift(mu = 0)has no drift term in the diagonal of the GLT matrix.AvellanedaImpact(xi = 0)has no asymmetric off-diagonal.
Both therefore coincide with AvellanedaStoikov. The tests compare values
and spreads at \(q = 0\).
Hawkes (unilateral)
The unilateral Hawkes intensity evolves as
\[ d\lambda = \beta (\mu - \lambda) \, dt + \alpha \lambda \, dt \]
in the deterministic PDE approximation.
\(alpha = 0\) reduces to Avellaneda-Stoikov
With \(\alpha = 0\) and \(\lambda = \mu\), the intensity stays at \(\mu\) and the
model is exactly AvellanedaStoikov(a = mu). The tests compare FD spreads
against AvellanedaExact.
Positive value at zero inventory
At \(q = 0\) and \(\lambda = \mu\) the market maker earns the base spread on incoming orders, so \(V > 0\).
Inventory symmetry
For a fixed \(\lambda = \mu\), the unilateral model has no inventory drift or asymmetry; \(V(q) = V(-q)\).
Control intensity scales with state intensity
The fill intensities are proportional to the state intensity lambda:
\[ \lambda_b = \lambda \exp(-\kappa \delta_b) \] \[ \lambda_a = \lambda \exp(-\kappa \delta_a) \]
The test verifies that the total control intensity reacts to the state intensity, with finite and non-negative bounds.
Bilateral Hawkes
The value is a function of inventory \(q\) and two intensities \((\lambda_+, \lambda_-)\).
Positive value at zero inventory
Same argument as unilateral Hawkes.
Symmetry in inventory
At \(\lambda_+ = \lambda_-\), the model is symmetric in the buy/sell directions, so \(V(q, \lambda_+, \lambda_-) = V(-q, \lambda_+, \lambda_-)\).
Side sensitivity
A higher sell order-flow intensity \(\lambda_-\) increases the probability of a bid fill (inventory increases and the market maker earns the bid spread), raising \(V\) at \(q = 0\). A higher buy order-flow intensity \(\lambda_+\) has the mirror effect. The tests assert strict monotonicity in each intensity at \(q = 0\).
Terminal conditions
The terminal value under TerminalCondition::Zero is identically zero.
Under TerminalCondition::LiquidationCost, the terminal value is
\[ V(T, q) = -|q| \cdot \text{base\_spread} \]
where \(base\_spread = (1/\gamma) \ln(1 + \gamma/\kappa)\). The tests check both forms at zero time steps, so the solver returns the terminal data exactly.
Heston
The Heston market-making model has state (q, v), where v is the variance
process. The value function solves a PDE with the generator
\[ \mu_v = v_{\kappa} (v_{\theta} - v) - \gamma \cdot \text{price\_scale} \cdot \rho \cdot v_{\xi} \cdot v \cdot q \] \[ \sigma2_v = v_{\xi}^2 v \]
and the inventory risk penalty
\[ -0.5 \gamma \cdot \text{price\_scale}^2 v q^2 \]
Higher instantaneous variance widens spreads
At \(q = 0\) the spread is symmetric, and the inventory risk penalty is
proportional to \(v q^2\). Increasing \(v\) deepens the value function's
inventory curvature, so both fwd[0] and bwd[0] grow in magnitude and both
spreads widen.
Higher long-run variance widens spreads
The drift \(v_\kappa (v_\theta - v)\) pulls future variance toward \(v_\theta\). Higher \(v_\theta\) means higher expected future variance and therefore higher expected inventory risk, which widens the spreads.
Faster mean reversion tightens spreads when \(v > v_{\theta}\)
If the current variance is above its long-run mean, a larger \(v_\kappa\) pulls it back down faster, so expected future risk is lower. The spreads tighten.
Higher vol-of-vol widens spreads
\(v_\xi\) controls the variance-of-variance. Increasing \(v_\xi\) increases the diffusion term \(0.5 v_\xi^2 v V_{vv}\) in the variance generator, which increases the value function's curvature and therefore the inventory gradient. The test uses a low liquidity \(a = 10\) so the effect is visible.
rho has no effect at terminal
At \(T = 0\) the value function and all of its gradients are zero, so the spreads equal the base spread. The \(\rho\) term enters only through the variance drift \(-\gamma \rho \xi v q\) and therefore has no effect at terminal.
No-crossing inventory skew
At a positive inventory \(q\), the market maker quotes a lower ask and a higher bid to shed inventory; at a negative inventory the skew reverses. Therefore the bid spread is increasing in \(q\) and the ask spread is decreasing in \(q\), with no crossing. This is checked for a range of \(\rho\).
BSDE stability
BSDE Monte Carlo results must be finite, positive, and have bounded coefficient of variation across repeated runs. The rho sweep checks all three.
American put
The American put value satisfies
\[ \min(-V_t - L V + r V, \, V - (K - S)_+) = 0 \]
Deep out-of-the-money
For \(S \gg K\), the payoff \((K - S)_+\) is zero and immediate exercise is never optimal, so \(V = 0\).
Deep in-the-money
For \(S \ll K\), immediate exercise is optimal and \(V = K - S\).
Merton
The Merton problem has log-utility value
\[ V(t, x) = \ln x + \left[ r + 0.5 (\mu - r)^2 / \sigma^2 \right] (T - t) \]
and constant optimal fraction
\[ u^* = (\mu - r) / \sigma^2 \]
The policy is independent of wealth and time; the tests check the closed form and that the optimizer reproduces it.
Separability
The value is ln x + g(t); the tests check the closed form directly.
Linear-quadratic regulator
The finite-horizon LQ value is
\[ V(t, x) = -x' P(t) x - q(t) \]
and the optimal control is
\[ u^*(t, x) = -R^{-1} B' P(t) x \]
The running cost is positive definite, so the value is negative and quadratic
in x.
Linear negative feedback
The optimal control is linear in x with a stabilizing negative gain.
Stationary finite value
For the discounted stationary LQ problem with rho > 0, the value
\(V(x) = -P x^2 - c^2 P / \rho\) is finite and negative.
Algebraic Riccati root
The Riccati equation residual is checked directly.
Stationary Avellaneda
The stationary value is the principal eigenvector of the GLT operator \(A = -\alpha q^2\) with off-diagonal \(+\eta\).
Positive Perron eigenvector
By Perron-Frobenius theory the principal eigenvector is positive.
\(theta(0) = 0\) normalization
The gauge is fixed by normalizing \(\theta(0) = 0\).
theta decreases away from zero inventory
The diagonal \(-\alpha q^2\) penalizes large inventory, so the principal eigenvector is largest near \(q = 0\) and decreases as \(|q|\) grows. Since \(\theta = (1/\kappa) \ln v\), \(\theta\) is decreasing in \(|q|\).
Implied spreads match the GLT reference
The spreads are computed from the eigenvector and must agree with
AvellanedaGueant::stationary_spreads.
Expanding the suite
To add economic coverage for a model or parameter:
- Add a row to the per-model table above with the invariant, the expected direction, and the one-sentence economic argument.
- Add a test in the existing model-specific folder.
- For deterministic FD tests, assert a strict ordering or equality.
- For stochastic BSDE tests, average enough repeats or use a fixed seed and assert the invariant with a statistical tolerance.
- For reductions, compare the reduced model and reference model on a
representative state, not only at
q = 0. - Update the table to mark the invariant as covered.
An invariant test must fail when the sign flips. A loose "close enough" assertion on a qualitative sign is not an economic invariant.