feat(itofin-py): expose CapFloor instrument to Python - #629
Merged
Conversation
Add Python bindings for cap and floor instruments built through the standard MakeCapFloor market builder. The new `CapFloor` and `CapFloorType` classes are registered in the `instruments` module. **New instrument bindings:** * Added `crates/itofin-py/src/capfloor.rs` implementing `PyCapFloor` and `PyCapFloorType`, registered in `lib.rs` under the `instruments` module. * The `Collar` variant is intentionally not exposed since it has no construction path from Python yet. **Stubs and tests:** * Updated `instruments.pyi` with hand-written stubs for `CapFloor` and `CapFloorType`, documenting the unit-nominal single-strike leg and the zero forward-start behavior that avoids a historical index fixing. * Added `tests/test_capfloor.py` covering the new instrument.
This change adds Python bindings for caplet/floorlet volatility surfaces, making them available under the `termstructures` module. **New optionlet volatility bindings:** * Added `crates/itofin-py/src/optionletvol.rs` implementing `PyOptionletVolatilityStructure` and `PyConstantOptionletVolatility`. * Registered both classes in the `termstructures` module in `lib.rs`. * `OptionletVolatilityStructure` exposes `volatility`, `volatility_date`, `black_variance`, and `displacement` on a single option axis. * `ConstantOptionletVolatility` provides a fixed-reference constructor and a quote-backed `with_quote` factory that tracks its `SimpleQuote`. **Stubs and tests:** * Extended `termstructures.pyi` with hand-written stubs for the new classes. * Added tests covering constant volatility queries, Black variance, and quote-backed surfaces reacting to `set_value`.
Expose the shifted-lognormal Black cap/floor engine to Python and wire it into cap/floor instruments so each optionlet prices off an optionlet volatility surface. * Add the `PyBlackCapFloorEngine` binding with a surface-handle constructor and a `with_flat_vol` builder, registered under `pricingengines`. * Add `set_black_engine` on `CapFloor` to attach the engine, requiring it to resolve dates against the same `Settings` object as the instrument. * Reject normal-volatility surfaces and displacements that disagree with the surface's own shift. * Add Python tests covering finite/positive NPVs, strike sensitivity, volatility sensitivity, constructor equivalence, and validation errors. * Update the `instruments` and `pricingengines` type stubs. Closes #621
benbenbang
enabled auto-merge (rebase)
July 27, 2026 05:14
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 #621