feat(instruments): add YoY inflation cap floor instrument - #855
Merged
Conversation
Introduce a new `inflationcapfloor` module exposing the `YoYInflationCapFloor` instrument and its `YoYInflationCapFloorArguments`, and re-export them from the instruments module for public use.
Add a test module for `inflationcapfloor.rs` covering the behaviour the pricing oracle's flat-gearing fixture cannot observe: strike padding, constructor refusals, and strike de-gearing. **Testing improvements:** * Verify a cap pads a single strike to the full leg length and leaves the floor side empty. * Verify constructor refusals: a collar cannot be built from one strike vector, and a cap requires at least one rate. * Verify `setup_arguments` de-gears the strike to `(rate - spread) / gearing` and leaves the unused side as `None`. * Verify an optionlet carries a single coupon with its own strike and keeps the parent's type, and that out-of-range indices are rejected. * Verify `validate` rejects a per-coupon nominal vector that has desynced from the leg.
Move the YoY inflation optionlet price computation out of the optionlet pricer and into a shared `yoy_optionlet_price` helper in the new `pricingengines::inflation` module, so it can be reused by the cap/floor engines. * Added `pricingengines/inflation/mod.rs` and `inflationcapfloorengines.rs`, exposing `YoYInflationCapFloorEngine` and `yoy_optionlet_price`. * Replaced the private `optionlet_price_imp` method in the YoY optionlet pricer with a call to the shared `yoy_optionlet_price`. * Registered the new `inflation` module in `pricingengines/mod.rs`.
This adds a comprehensive oracle test module for the year-on-year inflation cap/floor pricing engines, ported from the QuantLib `inflationcapfloor.cpp` test suite. **Bootstrapped market fixture:** * Builds a `PiecewiseYoYInflationCurve<Linear>` from real UK RPI history and a 5% nominal curve, bootstrapped off fifteen year-on-year swap quotes. * Deliberately reproduces two `CommonVars` fixture quirks: the RPI history overruns by two months with `-999.0` sentinels that move the curve base date to 1 August 2007, and the shadowed observation lag that leaves the leg, surface, and parity swap observing zero days. **Test coverage:** * Pins the curve base date to August 2007 so a change names the sentinel fixings as its cause rather than surfacing as drifting cached values. * Verifies put/call parity (cap - floor == swap) across all three distributions, three lengths, three strikes, and two volatilities.
…loor This pull request adds two new tests for the YoY inflation cap/floor pricing engine, covering the collar identity and QuantLib's cached values. **Collar consistency test:** * Added `a_collar_is_a_cap_less_a_floor_and_each_is_its_optionlets`, verifying that cap minus floor equals collar within `1e-6` across all distributions, lengths, strikes, and volatilities. * Un-nested the per-optionlet recomposition so it runs unconditionally, giving the `optionlet(n)` accessor real coverage by rebuilding each instrument's NPV from its optionlets. **Cached value test:** * Added `a_two_year_cap_and_floor_match_the_cached_values`, pinning a two-year cap and floor struck at 2.95% on 1% volatility against QuantLib's cached values for the Black, UnitDisplaced, and Bachelier distributions. * Uses a 1e6 nominal to reproduce the cached figures, matching QuantLib's `CommonVars` rather than the stale 10e6 comments in the C++ source. close #851
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 #851