Skip to content

feat(itofin-py): expose year-on-year inflation curve bindings - #850

Merged
benbenbang merged 5 commits into
mainfrom
fable/849
Aug 11, 2026
Merged

feat(itofin-py): expose year-on-year inflation curve bindings#850
benbenbang merged 5 commits into
mainfrom
fable/849

Conversation

@benbenbang

@benbenbang benbenbang commented Aug 11, 2026

Copy link
Copy Markdown
Owner
  • feat(itofin-py): expose year-on-year inflation curve bindings
  • feat(itofin-py): expose YoYInflationIndex to Python
  • feat(itofin-py): expose year-on-year inflation bootstrap bindings
  • feat(itofin-py): add YearOnYearInflationSwap bindings
  • test(itofin-py): add YoY inflation reprice test

close #849

Add the year-on-year inflation family to the Python bindings, mirroring
the zero inflation side already exposed.

**New Python classes:**
* `YoYInflationTermStructure` as the shared base for year-on-year curves,
  exposing `yoy_rate`, `yoy_rate_date`, `base_date`, `base_rate`,
  `frequency`, `set_seasonality` and `has_seasonality`. The two rate reads
  are not interchangeable: `yoy_rate_date` snaps its date to the enclosing
  inflation period and folds in any seasonality, while `yoy_rate` takes a
  year-fraction under the curve's own day counter.
* `InterpolatedYoYInflationCurve`, extending the base, built from
  (date, year-on-year rate) nodes interpolating linearly in rate space,
  with `times`, `dates` and `nodes` inspectors. `Linear` is pinned to
  match the C++ `YoYInflationCurve` typedef.
* `YoYInflationHelper` as the shared base for year-on-year bootstrap
  helpers, exposing `pillar_date` and `latest_date`.

**Registration:**
* Registered the three new classes on the `termstructures` module and
  wired up the corresponding `.pyi` type stubs.
Adds a Python facade for the core year-on-year inflation index, in both
its quoted and ratio forms, so callers can build and query these indexes
without dropping into Rust.

**New YoYInflationIndex facade:**
* Added `PyYoYInflationIndex` in `src/inflation.rs`, wrapping the core index over a facade-owned `RelinkableHandle` so an index can be built before the curve it forecasts off exists and linked later via `link_to`.
* Exposed the quoted constructor, which spells out region and currency as component fields since neither core type has a Python facade, plus the `from_underlying` ratio constructor that inherits metadata and holds onto the very `PyZeroInflationIndex` it was handed.
* Wired up `name`, `ratio`, `underlying_index`, `add_fixing`, `fixing`, `last_fixing_date`, `link_to`, `needs_forecast`, and `__repr__`.

**Registration and stubs:**
* Registered `PyYoYInflationIndex` on the `indexes` submodule in `src/lib.rs`.
* Added hand-written stubs for the new class in `indexes.pyi` and imported `YoYInflationTermStructure`.
This adds Python bindings for the year-on-year inflation curve
bootstrap, mirroring the existing zero-coupon facade.

**New helper and curve classes:**
* Added `PyYearOnYearInflationSwapHelper`, wrapping the core
  `YearOnYearInflationSwapHelper`. It fits a year-on-year swap quoted as
  a rate, discounting on a supplied nominal curve, and refuses
  `CpiInterpolationType.Linear` pending the interpolated branch (#847).
* Added `PyPiecewiseYoYInflationCurve`, wrapping
  `PiecewiseYoYInflationCurve<Linear>`. It bootstraps a year-on-year
  curve lazily from year-on-year helpers, keeping node zero on the base
  date and solving one rate node per helper. Exposes `calculate`,
  `times`, `dates`, and `nodes` inspectors that trigger the bootstrap.

**Registration and stubs:**
* Registered both classes in the `termstructures` module in `lib.rs` and
  imported them from the inflation module.
* Removed the now-used `#[allow(dead_code)]` markers on the
  `from_shared` and `shared` accessors threaded into the new facades.
* Added type stubs for both classes in `termstructures.pyi`, including
  the `YoYInflationIndex` import.
This pull request exposes the year-on-year inflation swap instrument to
Python, wiring the core `YearOnYearInflationSwap` through PyO3 and
registering it on the `instruments` module.

**New instrument binding:**
* Added `PyYearOnYearInflationSwap` in `src/inflation.rs`, constructing the swap from a fixed leg (schedule, rate, day count) against a year-on-year leg (schedule, index, observation lag, interpolation, spread) with payment calendar and convention.
* Exposed `set_engine`, `npv`, `fair_rate`, `fair_spread`, `fixed_leg_npv`, `yoy_leg_npv`, `fixed_rate`, and `spread`, with the priced accessors driving the calculation on demand.
* Registered `PyYearOnYearInflationSwap` on the `instruments` module in `src/lib.rs`.

**Type stubs and tests:**
* Added the `YearOnYearInflationSwap` class to `instruments.pyi`, including the `YoYInflationIndex` import and full method signatures.
* Added `tests/test_yoy_inflation_swap.py` covering the new instrument.
Add a new test file covering year-over-year inflation repricing
in the itofin-py crate.

Closes #849

close #849
@benbenbang
benbenbang enabled auto-merge (rebase) August 11, 2026 05:22
@github-actions github-actions Bot added the enhancement New feature or request label Aug 11, 2026
@benbenbang
benbenbang merged commit 5d38bbb into main Aug 11, 2026
3 of 6 checks passed
@benbenbang
benbenbang deleted the fable/849 branch August 11, 2026 05:25
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.

[Binding][YoY] Expose YoYInflationIndex + YoY curves + swap + helper in itofin-py

1 participant