Skip to content

Check the CDS and American option samples, and bump their sensitivities without AAD - #59

Open
auto-differentiation-dev wants to merge 2 commits into
mainfrom
fix/sample-cds-american
Open

auto-differentiation-dev wants to merge 2 commits into
mainfrom
fix/sample-cds-american

Conversation

@auto-differentiation-dev

Copy link
Copy Markdown
Contributor

AdjointCDS printed 8 of its 9 hazard-rate sensitivities and shifted the recovery, fixed-rate and notional sensitivities by one entry. Neither AdjointCDS nor AdjointAmericanEquityOption had a sample test, and without AAD both printed only the price.

Changes

  • AdjointCDS prints all 9 hazard-rate sensitivities and the last three under their own labels
  • Without AAD (QLAAD_DISABLE_AAD=ON), both samples compute their sensitivities by bump and revalue (forward differences for the CDS, central differences for the American option) and print them in the same format
  • Sample tests for both: exit code, price, and every sensitivity against stored AAD values. With AAD a sensitivity must be within 1e-7 relative, or differ by at most one in the last printed digit (the CDS prints 6 significant digits). With bumping it must be within 5e-4 (CDS) or 1e-4 (American). The CDS price must print exactly as stored, the American price within 1e-8 relative
  • The tests are picked up by the "Test samples" step that every CI job already runs (ctest -R "^Adjoint"), so the workflow is unchanged
  • CheckSample.cmake gets a helper that compares numbers printed in iostreams' default format, scientific notation included

Testing

The tests fail on the old CDS print and on the dividend rho that AAD gave before lballabio/QuantLib#3057, and pass in AAD and non-AAD builds, together with the existing sample tests, against current QuantLib master plus two pending fixes that let it compile with AD types. The two new check scripts also run with CMake 3.15, QuantLib's minimum. The bumped and AAD sensitivities agree to within 1e-5 relative for both samples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant