feat(itofin-py): expose year-on-year inflation curve bindings - #850
Merged
Conversation
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.
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 #849