Skip to content

feat(itofin-py): add MakeVanillaSwap builder facade - #628

Merged
benbenbang merged 2 commits into
mainfrom
fable/531
Jul 27, 2026
Merged

feat(itofin-py): add MakeVanillaSwap builder facade#628
benbenbang merged 2 commits into
mainfrom
fable/531

Conversation

@benbenbang

@benbenbang benbenbang commented Jul 27, 2026

Copy link
Copy Markdown
Owner
  • feat(itofin-py): add MakeVanillaSwap builder facade
  • feat(itofin-py): expose BlackVolTimeExtrapolation on BlackVarianceCurve

close #531

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
benbenbang enabled auto-merge (rebase) July 27, 2026 05:04
@github-actions github-actions Bot added the enhancement New feature or request label Jul 27, 2026
@benbenbang
benbenbang merged commit 3ed86db into main Jul 27, 2026
3 of 6 checks passed
@benbenbang
benbenbang deleted the fable/531 branch July 27, 2026 05:06
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 B4: MakeVanillaSwap facade + UseInterpolator (#605)

1 participant