Repository navigation
Fix notional-dependent implied quotes and the PCHIP/Akima fit seed; add solve_kwargs - #322
Merged
Merged
Conversation
The root solvers stopped on an absolute residual, and the scale-aware check ran only after a root was accepted. A nonlinear quote with a notional of 1e-10 was implied about 1e-5 off, and at 1e-14 the starting guess came back. implied_quote now solves the residual relative to the quote's size at the guess, and __implicit_root checks that the residual at an accepted root is at most sqrt(eps) times the scale (this also covers the swaption critical rate). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ForwardDiff orders Duals with equal values by their partials, so a duplicated tenor carrying different partials passed the strictly-increasing check. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… the optimizer PCHIP and Akima loss fits started from rates linear in the knot number, which are collinear on evenly spaced maturities: Akima switches formula there and the loss derivatives are NaN, so a coupon-bearing Akima fit on 1:8 failed to converge. They now start from a curve strictly increasing and concave in the maturities; a test checks the seed against every kink quantity on several grids. The differentiated-fit error told users to tighten the optimizer, but fit could not pass solver settings. Optimizer-backed fits now take solve_kwargs, passed verbatim to Optimization.solve, and the error names it. The calibration docs no longer put reconstruct in the first-order-only rule. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The job ran only FinanceModels' 12 integration checks. It now also runs ActuaryUtilities' full suite against this FinanceModels, through the same environment. ActuaryUtilities' FinanceModels compat is set to this version's major instead of deleted, so its Aqua compat check passes and a 6.x master still resolves. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The ordering check already compares primal values, because ForwardDiff orders Duals with equal values by their partials. The first tenor's sign check did not, so a knot at t = 0 carrying a negative partial was rejected as a negative tenor. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nw2FiivhYrC16532c1mJQN
fit(::FX.Forwards, quotes, method) had no keyword arguments, so a call with optimizer, solve_kwargs or extrapolation skipped it and failed inside the generic optic fit. Both methods now pass their keywords to the foreign-curve fit. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nw2FiivhYrC16532c1mJQN
Zero-coupon and coupon quotes scaled by 1e-12, 1 and 1e10 bootstrap to the zero rates they were priced from. implied_quote already has the same notional sweep for its value and derivative. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nw2FiivhYrC16532c1mJQN
KnotGrid owns the knot-grid rules and __build_tail owns the extrapolation policy; the copies elsewhere are removed: - the sampling form of ZeroRateCurve re-checked finite, positive and distinct tenors and the knot count before KnotGrid checked them again. A tenor of 0 now takes the source curve's zero-rate limit, as in the direct form; a curve without one gives a non-finite rate, which KnotGrid rejects. This also removes a Dual comparison that accepted Dual(0, 1) as positive; - bootstrap keeps only its own rule, that quotes mature after t = 0 (a knot there is not identified); KnotGrid rejects empty, non-finite and duplicate maturities; - __owned_float_vector no longer rewraps the conversion's MethodError or InexactError in an ArgumentError. KnotGrid checks the knot count first, and the tenors before the rates; - the extrapolation policy is checked where the tail is built, with one message that also covers :extension on MonotoneConvex; a policy of another type is a MethodError; - the differentiated fit's one-knot-per-quote check could not fail (the knots are the quote maturities). Two comments that misdescribed the kink checks are corrected. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nw2FiivhYrC16532c1mJQN
…patches and read-only knots Three errors only restated an error Julia raises on its own: - FlatForwardAt(::Real) threw an ArgumentError; without the method, the MethodError names the FlatForwardAt(::Rate) candidate; - setproperties rejected unknown keys before calling reconstruct, whose keywords are exactly the settable properties, so a cache patch is now reconstruct's MethodError; - ReadOnlyVector defined setindex! only to throw, and hid its field from getproperty. Without them, indexed assignment raises Base's CanonicalIndexError, and _data is an ordinary internal field. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nw2FiivhYrC16532c1mJQN
- A polynomial or B-spline on k knots interpolates at order min(n, k - 1), so a cubic fit to two quotes is linear and one knot is flat. That rule was only a code comment; it is now in the Spline.PolynomialSpline, BSpline, Quadratic and Cubic, ZeroRateCurve and fit docstrings (the B-spline's uniform knot vector below three knots too). - The FitConvergenceError example caught the error and refitted with Spline.Linear(), silently changing the curve. The docstring now says to address the cause (model, optimizer, solve_kwargs, quotes) and to choose the method deliberately. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nw2FiivhYrC16532c1mJQN
The :extension policy evaluates DataInterpolations' continuation of the last piece at every time, including Inf, where even a flat extension computes 0 * Inf. discount(curve, Inf) now throws a DomainError saying infinite-time evaluation is unsupported for that policy (a flat positive extension does have a limit, 0; the other policies return their tail limits). zero(curve, Inf) keeps its documented legacy value. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nw2FiivhYrC16532c1mJQN
`__owned_float_vector` promoted a non-concrete input's element types with an empty-collection `mapreduce`, so `fit(spline, [], Fit.Bootstrap())` failed there before `KnotGrid`'s length check ran. That native error is a MethodError on Julia 1.10 and an ArgumentError on 1.12, so the bootstrap test failed on the minimum-version and Downgrade jobs. Starting the promotion from `Bool`, which every real type absorbs, gives an empty input `Float64[]`, and the grid's own check raises its ArgumentError on every supported version. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nw2FiivhYrC16532c1mJQN
This was referenced Sep 30, 2026
Closed
This was referenced Sep 30, 2026
Merged
Merged
Merged
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 #322, number 6 of 10 open (base #320; next #323).
Updated 2026-09-27. One commit from the published-stack review (
review-artifacts/2026-09-26-published-review/):fit(spline, [], Fit.Bootstrap())failed in__owned_float_vector's empty-collectionmapreducebeforeKnotGrid's length check ran. That native error is aMethodErroron Julia 1.10 and anArgumentErroron 1.12, so the bootstrap test failed on the minimum-version and Downgrade jobs. Promotion now starts fromBool, which every real type absorbs, so an empty input becomesFloat64[], and the grid raises its ownArgumentErroron every supported version.Full suite: 6,294 tests pass on Julia 1.10.10 and 1.12.5.
Updated 2026-09-26. Seven commits follow the 2026-09-25 fixes rereview and a scrub of guards that duplicated or rewrapped natural errors:
KnotGridcompares the first tenor by its primal value, as the ordering check already did. A knot at t = 0 carrying a negative partial was rejected as negative.fit(::FX.Forwards, quotes, method; kwargs...)passesoptimizer,solve_kwargsandextrapolationto the foreign-curve fit. Keyword calls used to fall through to the generic fit and fail in__default_optic.KnotGridowns the knot-grid rules and__build_tailowns the extrapolation policy.ZeroRateCurve, bootstrap and__owned_float_vectorno longer repeat or rewrap them.MethodError.FlatForwardAt(0.035), patching a derived cache through Accessors, and writing to a knot vector raise Julia's ownMethodErrororCanonicalIndexError, not customArgumentErrors.FitConvergenceErrorexample that silently refitted withSpline.Linear()is removed.discount(curve, Inf)under:extension(f84f698): throws aDomainError(unsupported) instead of returningNaN.The dual-closure check in
implied_quotestays. Without it, three of four closing families failed with a crypticFloat64(::Dual)inside Roots. The fourth (a dual maturity) matched finite differences only because AD ran through the solver iterations.Stacked on #320. Review against
fix/interpolation-kinks. These are the fixes from an ecosystem-wide rereview of the FM 7 stack (September 24, 2026).implied_quotewas notional-dependent for nonlinear quotes. The root solvers stopped on an absolute residual, and the new scale-aware check ran only after a root had been accepted. For an annual-effective zero-coupon quote with notional1e-10, the implied rate was about1e-5off; at1e-14it came back as the starting guess. The existing notional tests used an affine price quote, which this problem doesn't affect.__implicit_rootchecks that the accepted root's residual is at mostsqrt(eps)times the scale. The swaption critical rate gets the same check.1e-14through1e10, for both the value and its derivative.PCHIP/Akima fit seed. Loss fits started from knot rates linear in the knot number. On evenly spaced maturities those are collinear: Akima switches formula there and the loss derivatives are
NaN, sofit(Spline.Akima(), CMTYield.(0.02 .+ 0.001 .* t.^2, t))witht = 1:8failed to converge.Kinks.jlon regular, irregular and zero-first-knot grids, and that the loss has finite gradients and Hessians there. A quadratic seed that is flat at the first knot would have hit PCHIP'sd == 0switch.solve_kwargsforfit. The differentiated-fit error told users to tighten the optimizer, butfitcouldn't pass solver settings. Optimizer-backedfits now takesolve_kwargs = (;), passed verbatim toOptimization.solve, for example(; maxiters = 10_000, g_tol = 1e-12). The error message names it.Downstream runs ActuaryUtilities' own suite. The job ran only FinanceModels' 12 integration checks. It now also runs
Pkg.test("ActuaryUtilities")in the same environment, against this FinanceModels. ActuaryUtilities' FinanceModels compat is set to this version's major instead of being deleted, so its Aqua compat check passes. Locally, both steps pass at this tip.Smaller fixes:
reconstructin the first-order-only rule. A reconstructed curve has derivatives of any order away from kinks.🤖 Generated with Claude Code