Repository navigation
Derivatives at interpolation kinks; notional-independent solver checks; discount at Inf - #320
Merged
Merged
Conversation
alecloudenback
force-pushed
the
fix/interpolation-kinks
branch
from
September 24, 2026 23:23
ba329ec to
9535c38
Compare
alecloudenback
force-pushed
the
fix/swaption-critical-rate-derivatives
branch
from
September 24, 2026 23:23
86e9098 to
24e157e
Compare
…tional-independent MonotoneConvex, PCHIP and Akima are only piecewise smooth in their knot rates. Where they switch formula, ForwardDiff returned derivatives that matched neither an up nor a down bump. A flat MonotoneConvex curve was off by up to a factor of two per knot; on a dense grid rounding picked the sector and the error reached 3.4. Flat PCHIP gave NaN, and a straight run of Akima knots a fallback formula's derivative. - MonotoneConvex: each partial is the limit of a centered bump in its direction. Where two sectors meet (adjacent discrete forwards equal) that is the average of their partials, which stays additive. On a flat interval it is the sector formula evaluated at the tangent. A collar tie averages the raw and bound forwards. Ties within rounding of the discrete forwards count, and unresolvable ties or second derivatives throw. Primal values are unchanged. - PCHIP and Akima: the public constructors throw when dual knot rates move a kink. FinanceModels' own trial curves are not checked. - Differentiated fits throw when the fitted curve lies on a kink, or within the fit's precision of one. Also: - implied_quote, the swaption critical rate, and differentiated fits now judge vanishing slopes and conditioning relative to the quote's size. A bootstrap solves each quote relative to its size too: at a 1e-10 notional it had fitted only to about 1e-5 in its zero rate. - discount(curve, Inf) returns the tail's limit; with a zero tail forward it was NaN. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…he infinite tail under AD Rereview of 9b26de3: - A first knot at t = 0 leaves a zero-width interval. The rounding tolerances divided by it: PCHIP/Akima threw on smooth curves (Inf) and a flat MonotoneConvex gave NaN gradients (0/0). Both now skip it. - DataInterpolations (9.2 to 10.1) switches an Akima node to its fallback slope where the node's weight is at most 1e-9 of the largest, and the curve's value jumps there. The kink quantities now include that cutoff, so dual knots and differentiated fits at it throw. A test checks that the quantity changes sign exactly where the installed version switches. - discount(curve, Inf) classifies its limit on primal values. A zero `:linear` slope or tail forward that carries partials throws instead of returning 1.0 for 0.0. - A differentiated fit's accuracy check bounds one Newton step (the knot rates' distance from the exact fit), not the row-scaled residual, which an ill-conditioned family can keep small while a knot is far off. - Docs no longer say market curves essentially never sit on a kink; the kink tests no longer overwrite local methods. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Move the kink logic to src/model/Yield/Kinks.jl, with the copies of DataInterpolations' PCHIP and Akima branch rules in one marked block. Differentiated fits call a single `Yield.__near_kink(curve, z[, δ])` instead of handling kink quantities and rounding tolerances themselves. - Group the tests that tie those copies to the installed DataInterpolations, and add PCHIP's end-slope limit |d| = 3|δ₁| to them. - State the fit accuracy criterion precisely: the largest absolute component of one Newton correction of the knot rates must be at most 1e-6, a local error estimate rather than a guaranteed distance to the exact fit. - Summarize the sensitivity contract (first order; risk to the quotes passed versus a synthetic quote family; exact fits; kinks, including that MonotoneConvex's responses on flat stretches do not aggregate like a gradient) on the calibration page, in the migration guide, in the `fit` and `reconstruct` docstrings, in NEWS, and on the home page and README. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
alecloudenback
force-pushed
the
fix/interpolation-kinks
branch
from
September 25, 2026 01:30
9535c38 to
f1fa2ea
Compare
alecloudenback
force-pushed
the
fix/swaption-critical-rate-derivatives
branch
from
September 25, 2026 01:30
24e157e to
58d6923
Compare
This was referenced Sep 25, 2026
Closed
Merged
This was referenced Sep 30, 2026
Merged
Base automatically changed from
fix/swaption-critical-rate-derivatives
to
master
October 1, 2026 13:39
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.
Merge map (updated 2026-10-01)
Part of the coordinated FinanceCore 2.8, FinanceModels 7.0, ActuaryUtilities 6.0 and MortalityTables 3.0 releases. Merge each stack bottom-up with Create a merge commit. Automatic branch deletion is on, so after each merge GitHub retargets the next PR onto the default branch: check that its base says
masterand let its CI finish before merging it.master; #327 lands them)master; #152 lands them. Independent of the other three)This PR: FinanceModels #320, number 5 of 10 open (base #319; next #322).
Stacked on #319. Review against
fix/swaption-critical-rate-derivatives. Three commits from an external review of the FM 7 work and two rereviews.Derivatives at interpolation kinks.
Spline.MonotoneConvex(),PCHIP()andAkima()are only piecewise smooth in their knot rates. Where they switch formula (a flat stretch, equal adjacent forwards, a straight run of Akima knots), ForwardDiff returned a derivative that matched neither an up nor a down bump: flat MonotoneConvex knot sensitivities could be off by a factor of two, flat PCHIP gaveNaN, and a flat MonotoneConvex curve on a dense grid gave derivatives driven by rounding noise.1e-9weight cutoff, where DataInterpolations' value jumps. These rules copy DataInterpolations internals; they live insrc/model/Yield/Kinks.jl, and a grouped testset checks them against the installed version.Notional-independent solver checks.
implied_quote, the swaption critical rate and differentiated fits judged vanishing slopes and conditioning on an absolute scale, and bootstrap solved each quote to an absolute tolerance (a1e-10notional fitted its zero rate only to about1e-5). Every check and solve is now relative to the size of the quote. A differentiated loss fit's accuracy check bounds one Newton correction of its knot rates (≤ 1e-6).discount(curve, Inf)returns the tail's limit instead ofNaNfor a zero tail forward, and throws under AD where a zero tail slope or forward carries partials.Docs: the sensitivity contract (first order; risk to the quotes passed vs. a synthetic quote family; exact fits; kinks) is summarized on the calibration page, in the migration guide, in the
fitandreconstructdocstrings, and on the home page.🤖 Generated with Claude Code