Verification infrastructure: cross-engine consistency, property invariants, hot-path benchmarks#186
Merged
Merged
Conversation
18 deterministic property tests over seeded random sweeps: put-call parity (BS/Black76/Garman-Kohlhagen/digital cash+asset), monotonicity and bounds (strike/spot/vol/maturity with documented q=0 restriction, delta ranges, gamma/vega positivity), strike convexity, barrier in/out parity across all four barrier types plus KO monotonicity in the barrier level, SVI calendar monotonicity and Fengler butterfly checks through the public query APIs, curve invariants (DF(0)=1, monotone DFs, swap-bootstrap par repricing), CDS bootstrap repricing and survival monotonicity, and analytic-vs-finite-difference Greeks consistency. All properties hold at the specified tolerances; runtime 0.03s. https://claude.ai/code/session_01FAx1FjfzYunS5ZmSzywFjv
Eleven deterministic tests pricing the same instruments through every applicable engine and asserting agreement: - European vanillas over a 96-point grid: Black-Scholes analytic vs CRR (1000 steps), trinomial (800), Crank-Nicolson (400x400 with a vol-adaptive S_max so low-vol short-maturity points are grid-resolved, not tolerance-excused), Monte Carlo (4 stderr), and Carr-Madan FFT via the exact BS characteristic function. - American puts: CRR vs the independent AmericanBinomialEngine (agree to 1e-9), trinomial, CN, and LSM; American call with q=0 equals European. - Barriers: in+out = vanilla exactly in both analytic and common-path MC; discrete-monitoring MC vs analytic at the Broadie-Glasserman-Kou shifted barrier; one-sided discrete/continuous ordering checks. - Asians: discrete geometric closed form vs MC with observations on grid. - Digitals: analytic vs exact-terminal GBM MC. No genuine inter-engine discrepancies found. ~20s debug runtime. https://claude.ai/code/session_01FAx1FjfzYunS5ZmSzywFjv
Twelve criterion benchmarks covering the recently optimized paths: vol-surface queries, BS analytic reference, MC European (standard, SoA scalar, SoA SIMD), ADI Heston, LSM American, autocallable price-only vs with-greeks, CDS bootstrap, one LM Heston iteration, rolling historical VaR, and the curve gamma ladder. Measured against the pre-review baseline (da6b4b8, release, criterion quick medians): - vol-surface query path 20.1us -> 3.3us (~6.1x) - autocallable single price 285.6ms -> 31.9ms (~8.9x, Greeks opt-in) - CDS bootstrap (5 pillars) 1.011ms -> ~75us (~13x) - rolling historical VaR 21.7ms -> ~3.4ms (~6.4x) - gamma ladder (10 pillars) 33.3us -> 22.4us (~1.45x) - autocallable with_greeks parity, as expected https://claude.ai/code/session_01FAx1FjfzYunS5ZmSzywFjv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Durable verification infrastructure following the two review passes (#183/#185): instead of more reading, this PR makes the engine stack check itself.
tests/cross_engine_consistency.rs(11 tests, ~20s debug)The same instruments priced through every applicable engine with agreement asserted:
No genuine inter-engine discrepancies found. The two independent CRR implementations agree to 1e-9; MC barrier parity holds to float precision.
tests/property_invariants.rs(18 tests, 0.03s)Seeded-sweep no-arbitrage and structural properties: put-call parity (BS/Black76/GK/digital cash+asset), monotonicity/bounds/delta ranges/gamma–vega positivity, strike convexity, barrier parity and KO monotonicity, SVI calendar + Fengler butterfly checks, curve DF and swap-bootstrap repricing identities, CDS bootstrap repricing, analytic-vs-FD Greeks. All properties hold at first run.
benches/hot_paths_bench.rs(12 benchmarks)Covers every recently optimized hot path so future regressions are measurable. Measured against the pre-review baseline (
da6b4b8, release, criterion quick medians):Validation: both suites green,
cargo bench --no-run --features parallel,simdcompiles, fmt clean, workspace clippy zero errors.https://claude.ai/code/session_01FAx1FjfzYunS5ZmSzywFjv
Generated by Claude Code