feat(itofin-py): expose swaption volatility structures to Python#617
Merged
Conversation
This change adds Python bindings for swaption volatility surfaces via the new `swaptionvol` module, making them available under the `termstructures` submodule. **New Python bindings:** * Added `crates/itofin-py/src/swaptionvol.rs` and registered the new module in `lib.rs`, wiring `SwaptionVolatilityStructure`, `VolatilityType`, and `ConstantSwaptionVolatility` into the `termstructures` submodule. * `SwaptionVolatilityStructure` provides the shared `volatility`, `black_variance`, and `shift` accessors addressed by option and swap tenor. * `ConstantSwaptionVolatility` exposes fixed-reference-date constructors, including a `with_quote` form that reads volatility from a caller's quote. **Stub updates:** * Added hand-written stubs in `termstructures.pyi` for the new classes and updated the submodule-to-source maps in `__init__.pyi` and `termstructures.pyi` to include `src/vol.rs`, `src/helpers.rs`, and `src/swaptionvol.rs`.
This adds Python bindings for pricing swaptions off a swaption volatility surface instead of a short-rate model. **New pricing engine module:** * Added `swaptionengine.rs` exposing `PyBlackSwaptionEngine` and `PyCashAnnuityModel`, registered under a new `pricingengines` submodule on `itofin`. * Wired the new submodule into `lib.rs` so it is importable as `itofin.pricingengines` alongside the existing eight submodules. **Swaption pricing update:** * Added `set_black_engine` to `PySwaption`, letting a swaption price off a swaption volatility surface. The engine can be shared across swaptions and must carry the same `Settings` object the swaption was built with. **Type stubs:** * Added `pricingengines.py` and `pricingengines.pyi`, and updated the `__init__.pyi` and `instruments.pyi` stubs to expose the new module and the `set_black_engine` method.
benbenbang
enabled auto-merge (rebase)
July 27, 2026 03:13
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 #612