feat(itofin-py): add MakeVanillaSwap builder facade - #628
Merged
Conversation
This pull request exposes the market-convention swap builder to Python so callers can state conventions instead of hand-building two schedules. The builder derives both schedules, the fixed-leg tenor and day count, and the discounting engine from a swap tenor and an Ibor index. **New MakeVanillaSwap facade:** * Added `PyMakeVanillaSwap` in `swap.rs`, a `#[pyclass]` wrapping the core `MakeVanillaSwap`. Since the core `with_*` chain consumes the builder by value, overrides are taken as constructor keywords and the chain is assembled inside `build`. * Exposed the four overrides the pass-A swaption fixture needs (`effective_date`, `nominal`, `fixed_leg_tenor`, `fixed_leg_day_count`); every other core override keeps its default. * `fixed_rate=None` builds a par swap; `build` returns a `PyVanillaSwap` that already carries its `DiscountingSwapEngine`, and added `PyVanillaSwap::from_inner` to wrap the lowered swap. **Registration and stubs:** * Registered `PyMakeVanillaSwap` under the `instruments` module in `lib.rs`. * Added the `MakeVanillaSwap` class stub to `instruments.pyi`. * Added `tests/test_make_vanilla_swap.py` covering the new builder.
Add a `BlackVolTimeExtrapolation` enum (`FlatVolatility`, `UseInterpolator`, `LinearVariance`) and a `time_extrapolation` parameter to `BlackVarianceCurve`, letting callers pick the rule applied past the curve's last node. The parameter defaults to `FlatVolatility` to match the C++ default, and construction now goes through `with_interpolator` to thread the choice into the core. `UseInterpolator` builds and answers in-range queries but errors on any extrapolating query rather than silently substituting another rule, surfacing an `ItofinError` from the query itself. Tests cover the flat default, linear variance continuation, and the deferred `UseInterpolator` failure. Closes #531 close #531
benbenbang
enabled auto-merge (rebase)
July 27, 2026 05:04
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 #531