Repository navigation
Give the short rate trees discount factors on their ACT/365F clock - #502
Open
hereiszepedro wants to merge 2 commits into
Open
hereiszepedro wants to merge 2 commits into
hereiszepedro wants to merge 2 commits into
Conversation
IborSwaption (BK and BDT), IborBermudanSwaption, BondOption and BondEmbeddedOption passed the curve's knot times straight to the trees. Those times are on the curve's day count clock, while the trees and the coupon times use days / 365. With a curve on ACT/360, for example, the trees discounted every flow with the wrong discount factor. DiscountCurve.tree_dfs returns the knots unchanged for an ACT/365F curve and otherwise samples the curve daily on the trees' clock.
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.
IborSwaption(BK and BDT),IborBermudanSwaption,BondOptionandBondEmbeddedOptionpassdiscount_curve._timesanddiscount_curve._dfsstraight tobuild_tree. Those times are measured on the curve's own day count clock (curve_dc_type), but the trees and the coupon times use days /G_DAYS_IN_YEAR. When the curve is not on ACT/365F, the tree reads every discount factor at the wrong time, so the price depends on the curve's day count even when the discount factors on every date are the same.Two
DiscountCurves with the same discount factors on the same dates, one withcurve_dc_type=ACT_365Fand one withACT_360(the curve in the new test):The same happens with
IborSingleCurve(..., curve_dc_type=DayCountTypes.ACT_360).This PR adds
DiscountCurve.tree_dfs(t_max)and uses it in the four products. For an ACT/365F curve it returns the knots unchanged, so prices with the default curves are unchanged. For any other clock it samples the curve daily out tot_maxand returns the times as days /G_DAYS_IN_YEAR. Because the knots fall on dates, the samples reproduce a flat-forward curve exactly. The analytic Hull-White branch ofIborSwaptionalready handles this (#465) and is not touched.IborCapFlooris left alone because #501 is open on that file.The first commit adds
tests/unit/test_tree_curve_day_count.py, which prices each product with both curves and expects the same value. Its 11 cases fail on master and pass with the fix. The unit suite passes (2153 tests). I also ran the golden regression scripts for the swaption, Bermudan swaption, bond option and embedded option (HW, BK, BDT). Only the timing columns change.AI-assisted (Claude Code). I checked the numbers above and ran the tests locally.