Skip to content

Use the global evaluation date in American, barrier and binary option tests - #2994

Open
destinyN1 wants to merge 1 commit into
lballabio:masterfrom
destinyN1:tests/fixed-evaluation-date
Open

destinyN1 wants to merge 1 commit into
lballabio:masterfrom
destinyN1:tests/fixed-evaluation-date

Conversation

@destinyN1

@destinyN1 destinyN1 commented Oct 31, 2026 •

Copy link
Copy Markdown

These tests got their date from Date::todaysDate(), so they ignored the evaluation date set by the test suite (and the --date option) and their results depended on the day they were run.

This switches 13 of them in americanoption.cpp, barrieroption.cpp and binaryoption.cpp to Settings::instance().evaluationDate(), as suggested in AGENTS.md. In testFdGreeks the line setting the evaluation date back to today became redundant, so I removed it.

To check it, I temporarily printed the date each changed test was using and ran the three suites with the default date and with --date set to 2024-02-29, 2025-12-31, 2026-10-31 and 2026-12-25. Before the change all of them printed the system date whatever --date said; after it, they follow the suite's date. With --date=2026-12-25, testBaroneAdesiWhaleyValues, testJuValues and testFdValues failed before the change and pass after it.

The full test suite passes (1680 test cases). BarrierOptionTests/testParity fails for some of those --date values both before and after this change, so that looks like a separate issue.

… tests

These tests read the date from the system clock with Date::todaysDate(),
so they ignored the evaluation date set by the test suite (and --date)
and could fail depending on the day they were run. For instance, with
--date=2026-12-25 three American option tests failed because their curves
and the global evaluation date were almost two months apart.

They now use Settings::instance().evaluationDate(), as suggested in
AGENTS.md. In testFdGreeks, the assignment back to the evaluation date
became redundant and was removed.
@CLAassistant

CLAassistant commented Oct 31, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@boring-cyborg

boring-cyborg Bot commented Oct 31, 2026

Copy link
Copy Markdown

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.

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.

2 participants