Repository navigation
Skip the caplets and floorlets already paid in IborCapFloor.value - #501
Open
QuantIntellect wants to merge 1 commit into
Open
QuantIntellect wants to merge 1 commit into
QuantIntellect wants to merge 1 commit into
Conversation
value took the first caplet from start_dt and the others from their own dates without comparing them with value_dt, so once the first payment date had passed libor_curve.df(end_dt) asked for a date before the curve anchor and raised "Negative time period", with every model. Caplets and floorlets paid on or before value_dt are now worth 0.0, and the first unpaid one is valued as the first caplet was, from last_fixing when it is given, as SwapFloatLeg.value does with first_fixing_rate. A cap or floor whose last payment has passed is worth 0.0.
This branch has not been deployed
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.
IborCapFloor.valuevalues the first caplet or floorlet fromstart_dtand every later one from its own dates, without comparing them withvalue_dt(ibor_cap_floor.py#L165-L174, #L197-L203). Once the first payment date has passed,libor_curve.df(end_dt)asks the curve for a date before its anchor and raises, so a cap or floor can't be valued after its first payment, with any model:The same contract described from the start of its current period,
IborCapFloor(Date(16, 6, 2025), Date(16, 6, 2028), ...), has the same caplets left to pay and values fine, so the two should agree:BlackBachelierHWTreeBlackBachelierHWTreeChange
Caplets and floorlets paid on or before
value_dtare skipped. Their entries in the caplet lists are 0.0, so the lists still line up withcaplet_floorlet_dates. The first unpaid one is valued the way the first caplet was, fromlast_fixingwhen it is given, and a cap or floor whose last payment has passed is worth 0.0. This followsSwapFloatLeg.value, which counts a payment on the value date as paid and appliesfirst_fixing_rateto the first unpaid period (swap_float_leg.py#L196-L204), and #445, which did the same for the swaps inproducts/rates/swaps.Two things change for existing users, and they are your call:
last_fixingis now the fixing of the period that holdsvalue_dt, not always of the first period. Before the first payment they are the same period, so nothing changes there.last_fixing). This PR gives 26215.9701, withlast_fixingapplied to the period starting that day.Without
last_fixing, a seasoned cap still raises, as master already does once the first period has started: the current period's rate can't be implied from a curve that starts after it was fixed.Tests
tests/unit/test_cap_floor_seasoned.py(new):Black,BachelierandHWTree, the contract described from its trade date values the same as from its current period (6 cases);All 8 fail on master and pass with the change. The rest of
tests/unitgives the same result as at ef59d2a, which this branch is on: 2,134 pass, and the 2test_inflation_swap.pytests that failed there fail the same way (fixed on master since, in 4477109).regression_test_ibor_cap_floor.pygives the same output as on master. I ran these with numba 0.68.1, numpy 2.3.5, scipy 1.17.1 and pandas 2.3.3.