Skip to content

feat(itofin-py): add SwaptionVolatilityMatrix Python bindings#618

Merged
benbenbang merged 3 commits into
mainfrom
fable/613
Jul 27, 2026
Merged

feat(itofin-py): add SwaptionVolatilityMatrix Python bindings#618
benbenbang merged 3 commits into
mainfrom
fable/613

Conversation

@benbenbang

@benbenbang benbenbang commented Jul 27, 2026

Copy link
Copy Markdown
Owner
  • feat(itofin-py): add SwaptionVolatilityMatrix Python bindings
  • test(itofin-py): add swaption vol matrix tests
  • test(swaption-vol): verify flat extrapolation clamps past the grid

close #613

This adds Python bindings for the at-the-money swaption volatility grid,
bilinear over an option-tenor x swap-tenor lattice.

**New surface class:**
* Added `PySwaptionVolatilityMatrix` in `swaptionvol.rs`, extending
  `PySwaptionVolatilityStructure` and exposing two constructors: a pinned
  reference-date grid over fixed volatilities and a `moving` grid that
  floats off the evaluation date, reading each node from a live quote so a
  later `set_value` rebuilds the interpolation and notifies observers.
* Both constructors accept optional per-node shifts and a
  `flat_extrapolation` flag that clamps out-of-grid queries to the nearest
  edge or corner vol.

**Grid validation helpers:**
* Added `check_grid` to reject empty or ragged `list[list[...]]` inputs
  before they reach the core dimension checks, and `matrix_from_rows` to
  convert a `list[list[float]]` into a core `Matrix`.

**Registration and stubs:**
* Registered `PySwaptionVolatilityMatrix` in `lib.rs` under the
  `termstructures` module and added the corresponding type stub in
  `termstructures.pyi`.
Add a new test file for the swaption volatility matrix functionality
in the itofin-py crate.

Closes #613
Add a test covering flat extrapolation behavior for both the fixed and
moving `SwaptionVolatilityMatrix` constructors. Past the 30Y option
tenor, the plain grid extends the boundary surface while the flat one
clamps to the 30Y x 30Y corner vol exactly. Pinning both constructors
guards against an inverted flag or a route that ignores it, which would
otherwise be invisible.

close #613
@github-actions github-actions Bot added the enhancement New feature or request label Jul 27, 2026
@benbenbang
benbenbang enabled auto-merge (rebase) July 27, 2026 03:22
@benbenbang
benbenbang merged commit e8a1c6b into main Jul 27, 2026
5 of 6 checks passed
@benbenbang
benbenbang deleted the fable/613 branch July 27, 2026 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[D7][itofin-py] Pass A2: PySwaptionVolatilityMatrix (#605)

1 participant