Skip to content

feat(instruments): add YoY inflation cap floor instrument - #855

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

feat(instruments): add YoY inflation cap floor instrument#855
benbenbang merged 5 commits into
mainfrom
fable/851

Conversation

@benbenbang

@benbenbang benbenbang commented Aug 11, 2026

Copy link
Copy Markdown
Owner
  • feat(instruments): add YoY inflation cap floor instrument
  • test(crates): add unit tests for YoY inflation cap/floor structure
  • refactor(src): extract yoy optionlet pricing into inflation engine
  • test(crates): add oracle test for YoY inflation cap/floor engines
  • test(inflation): add consistency and cached value tests for YoY cap/floor

close #851

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
@benbenbang
benbenbang enabled auto-merge (rebase) August 11, 2026 10:46
@github-actions github-actions Bot added the enhancement New feature or request label Aug 11, 2026
@benbenbang
benbenbang merged commit 4f1fd12 into main Aug 11, 2026
3 of 6 checks passed
@benbenbang
benbenbang deleted the fable/851 branch August 11, 2026 10:48
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.

[Inflation][YoY] YoYInflationCapFloor instrument + engines + MakeYoYInflationCapFloor

1 participant