Skip to main content

Module vol_surface_cache

Module vol_surface_cache 

Source
Expand description

Volatility surface cache for storing and querying implied volatility data.

This module provides an efficient cache for volatility surface data with:

  • O(1) lookups for exact (strike, expiry) matches
  • Bilinear interpolation for points between grid nodes
  • Strike quantization to avoid floating-point comparison issues

StructsΒ§

BilinearPoint πŸ”’
DeltaCurveExport
Exported delta curve for a single expiry.
DeltaIvExport
Exported delta-IV pair for API responses.
DeltaIvPoint πŸ”’
A delta-IV pair on the vol smile for a single expiry.
VolPoint
A single point on the volatility surface.
VolatilitySurface
Volatility surface for a single underlying.

ConstantsΒ§

IV_EPS πŸ”’
Minimum IV change worth writing back after solving (avoids flapping).
IV_FLOOR πŸ”’
IV floor used during bisection; below this the option is effectively intrinsic.
PRICE_EPS πŸ”’
Tolerance for declaring a call-price arb violation (quote-unit dollars).

FunctionsΒ§

bs_call πŸ”’
find_bracketing_sorted πŸ”’
Find bracketing values in a sorted slice.
interpolate_curve πŸ”’
Linear interpolation on a sorted delta-IV curve.
normal_cdf πŸ”’
Normal CDF approximation (Abramowitz & Stegun 26.2.17).
solve_call_iv πŸ”’
Find Οƒ in [IV_FLOOR, iv_hint] such that BS call price β‰ˆ target. BS call is monotone increasing in Οƒ, so bisection converges. If the lower bound’s price already exceeds target (target below intrinsic), returns IV_FLOOR.