Fix convertible dividend indexing after settlement - #2702
Open
wenn-id wants to merge 1 commit into
Open
Conversation
|
Thanks for opening this pull request! It might take a while before we look at it, so don't worry if there seems to be no feedback. We'll get to it. |
Owner
|
Thanks! A suggestion: if you want to run the test suite locally, compile it in Release mode. As you've seen, Debug mode is a lot slower, to the point of being unusable. |
Author
|
Thanks for the tip. I rebuilt the test suite in Release mode and reran it locally: That is indeed much more practical than the Debug run. |
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.
Summary
dividendValues_from the already settlement-filtered dividend containersThis addresses Issue A in #2701. Issue B is intentionally out of scope because it requires a separate design decision about evaluation-date versus settlement-date spot adjustment.
Root cause
dividendValues_was sized usingdividends_, which excludes dividends that occurred before the bond settlement date, but populated by iterating the original unfiltereddividendsschedule. Once an earlier dividend was filtered out, the raw index no longer matched the destination array and could write out of bounds.TDD evidence
Before the production change, the regression test failed because the single retained slot contained the discounted pre-settlement dividend instead of the future dividend:
After the fix:
ConvertibleBondTestssuite: passed (4/4)git diff --check: passedA repository-wide Release build and test run also passed: 1,374/1,374 test cases and 12,423/12,423 assertions in 4 minutes 44 seconds.
Scope
Only these files change:
ql/pricingengines/bond/discretizedconvertible.cpptest-suite/convertiblebonds.cppAI assistance
AI assistance was used to help draft the initial regression scenario and perform an independent review. The initial test was manually rejected because it mixed Issue B pricing semantics into Issue A; the final test was rewritten to inspect
DiscretizedConvertible::dividendValues()directly. All changes and test results were reviewed and executed locally by the contributor.