Repository navigation
Conversation
|
|
Rebase onto current main and address review: run against QuantLibAAD 1.44.0, move the AAD computation into aad_sensitivities() returning the portfolio value and a dict of sensitivities keyed by input name, replace the forward-difference check with central differences over all 13 inputs, and add a CHANGELOG entry. Run on QuantLibAAD 1.44.0: barrier option value 4.652838435318750, replicating portfolio value 4.154324163665421; largest relative difference over all 13 inputs 3.4e-06 (rate February 9th, 2007), on a small sensitivity at the central-difference noise floor through the kill loop.
019bd89 to
a3a9dc1
Compare
|
Review points addressed (same as #23):
Run on QuantLibAAD 1.44.0: barrier option value 4.652838435318750, replicating portfolio value 4.154324163665421, both unchanged from the 1.33.3 run. The CLA is still unsigned on my side; that is separate from these changes. |
|
Thanks, the rebase and the 1.44.0 run are what we asked for. Before we can take the review further, the CLA needs signing for this PR as well: see the bot comment at the top for the link, or use its "recheck" link if you've already signed. Tell us if anything about the CLA is unclear. The description above still describes the 1.33.3 run; please bring it in line with your latest comment. We'll review once the CLA check passes. |
Closes #20.
Python port of the
AdjointReplicationC++ example (Joshi's static replication of a down-and-out barrier option with European options), following the pattern ofswap-adjoint.py:aad_sensitivities()function returning the portfolio value and a dict of sensitivities keyed by input name. The example cross-checks every adjoint against central differences (h = 1e-5) over all 13 inputs at the end.Testing: run on QuantLibAAD 1.44.0 (Python 3.12): barrier option value 4.652838435318750, replicating portfolio 4.154324163665421, largest relative difference over all 13 inputs: 3.4e-06 (rate February 9th, 2007). The worst input is a small sensitivity (2.7e-3) at the central-difference noise floor through the kill loop; the large sensitivities agree to ~1e-8 (volatility 3.9e-08). Noted in the example.
One deliberate difference from the C++ code, also noted in the example: the C++ registers a single variable for the flat 4% rate shared by all nine curve nodes, so its rho is the sum over nodes. This port registers one input per node (all set to 4%) and reports the rhos per node; the per-node values sum to the C++-style sensitivity. Shout if you would prefer the single-variable form instead.
Note: this repo requires a signed CLA before merge (per CONTRIBUTING) — I understand it will be handled through the CLA flow.