feat(itofin-py): add SwaptionVolatilityMatrix Python bindings#618
Merged
Conversation
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
benbenbang
enabled auto-merge (rebase)
July 27, 2026 03:22
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.
close #613