Skip to content

Add example 1.6: exact Heston Greeks via AADC - #28

Open
mar20tinha-dot wants to merge 1 commit into
cantaro86:masterfrom
mar20tinha-dot:feat/aadc-greeks
Open

Add example 1.6: exact Heston Greeks via AADC#28
mar20tinha-dot wants to merge 1 commit into
cantaro86:masterfrom
mar20tinha-dot:feat/aadc-greeks

Conversation

@mar20tinha-dot

@mar20tinha-dot mar20tinha-dot commented Aug 8, 2026

Copy link
Copy Markdown

Summary

Adds a new example (1.6) showing how AADC (Automatic Adjoint Differentiation) computes exact Heston Greeks, accelerates calibration, and enables implicit differentiation through calibration (AITF).

Four levels of speedup, all verified against the library's own Fourier_inversion() and finite differences:

Section What Speedup
A. Fourier price + 5 Greeks via PROJ on AADC tape 158x vs FD
B. Calibration exact Jacobian for 20 instruments 39x vs scipy FD
C. AITF d(calibrated params)/d(market prices) via IFT 245x vs recalibration
D. Monte Carlo batch API, 200K paths + 6 Greeks 111x (1 thread) / 348x (4 threads)

All gradients match FD (ratio 0.999-1.001). AITF sensitivities match FD recalibration (ratio 1.0000).

Key techniques

  • Complex arithmetic with idouble (real/imag split) for the Heston characteristic function
  • Branch-free csqrt/clog (Heston CF guarantees re(z) > 0)
  • Cooley-Tukey FFT on tape with precomputed twiddle factors
  • MC batch API: random normals via mark_as_input_no_diff(), one evaluate() call for all paths
  • AITF: one Jacobian + 5x5 linear solve replaces 40 recalibrations

Dependencies

  • aadc (pip install aadc, free evaluation, no licence key)
  • No changes to FMNM source code

…F 245x)

Four levels of AADC-accelerated differentiation for Heston options:

  A) Fourier pricing (PROJ method): price + 5 Greeks in 0.8 ms (158x vs FD)
  B) Calibration: exact Jacobian for 20 instruments (39x vs scipy FD)
  C) AITF: d(calibrated params)/d(market prices) via IFT (245x vs recalibration)
  D) Monte Carlo: batch API, 200K paths + 6 Greeks (111x single-thread, 348x 4-thread)

All gradients verified against finite differences (ratio 0.999–1.001).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant