Docs / nablatensor-cva / com.nablatensor.cva
final class
ExposureSimulation
The Phase-2 exposure engine: a Monte-Carlo simulation of a netting set's mark-to-market on a time grid, recorded once onto the adjoint tape.
Each path evolves a one-factor Hull-White short rate and a lognormal FX spot, values every trade at every grid date from analytic P(t, T) bonds, applies the CSA (variation margin with a threshold and a margin period of risk), and accumulates the pathwise CVA integrand
CVA = LGD * sum_k max(V(t_k) - C(t_k), 0) * D(t_k) * ( S(t_{k-1}) - S(t_k) )
against a piecewise-flat counterparty survival curve whose forward hazards are tape inputs. One .greeks() run therefore returns the CVA and its full risk vector — IR delta and rate vega, counterparty CS01 by tenor bucket, recovery and FX — from a single reverse sweep. The bump-and-revalue alternative re-runs cvaOnly once per shocked risk factor.
Constructors
Methods
Force the replay precision. Left unset, the precision follows the engine: the Vulkan engine is single-precision, every other engine runs fp64. The money-scaled integrand and the expm1-form marginal-default probability keep the fp32 path within Monte-Carlo error of the fp64 one.
CVA and the full CVA gradient from one adjoint sweep on engine, plus the expected-exposure profile. The CVA value and gradient come from a single greeks() kernel over the scalar CVA — the timed sweep. The per-date profile is a separate priceOnly() kernel with many named outputs; that runs on engine where the backend supports it and falls back to cpu-jit otherwise (it is a picture, not a headline number).
Just the CVA number — the kernel a prescribed-bump sensitivity re-runs.