Repository navigation
Conversation
Port of the AdjointHestonModel C++ example. A Heston model is calibrated to 104 DAX option prices and prices a forward-start call; the sensitivities of the price to all 114 market inputs are computed with the implicit function theorem - Hessian blocks of the calibration objective from central differences of its XAD gradient (11 recordings) - instead of recording the calibration itself. The example cross-checks the eight largest sensitivities by bumping each input, recalibrating, and repricing.
|
|
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.
Closes #19.
Python port of the
AdjointHestonModelC++ example, following the pattern ofswap-adjoint.py:HestonModelHelperwithPriceError),COSHestonEngine(model, 12, 75), Levenberg-Marquardt at tolerance 1e-12 starting from (0.1, 1.0, 0.5, -0.5, 0.1), then a forward-start call (strike set in 6M, expiry 18M) priced withAnalyticHestonForwardEuropeanEngine.Testing, with two caveats I want to be explicit about:
QuantLibAADwheel is not reachable from my sandbox, so I ran the identical example code against QuantLib-Risks 1.33.3 (the direct predecessor of QuantLibAAD; the tape-construction lines differ slightly between the two APIs). The full flow runs end to end and the cross-check agrees: e.g. zero rate 524d IFT 2887.910476 vs bump-and-recalibrate 2888.227150 (1.1e-4 relative); zero rate 165d -1040.308095 vs -1040.250569; worst of the eight is 4.3e-4 relative.COSHestonEnginesegfaults when pricing a helper, so for the local run I substitutedAnalyticHestonEnginefor the calibration engine only (the submitted file uses COS, as in the C++ example and as the issue describes; plain QuantLib 1.44 prices the same helper with COS without issue, giving the same model value as the analytic engine to 6 significant digits). With the analytic engine the local calibration lands on theta 0.0722, kappa 3.6200, sigma 1.2293, rho -0.5790, v0 0.1289 and a forward-start value of 480.64; the COS calibration in the current build may differ slightly in the last digits. If the COS engine misbehaves in the current build as well, the analytic engine is a drop-in fallback for this example.Note: this repo requires a signed CLA before merge (per CONTRIBUTING) — I understand it will be handled through the CLA flow.