Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include time zero / evaluation date in option date interpolation #1783

Merged
merged 3 commits into from
Sep 29, 2023

Conversation

pcaspers
Copy link
Contributor

@pcaspers pcaspers commented Sep 3, 2023

For times before the first option date optionDateFromTime() can return a date < evaluation date. I would suggest to include the evaluation date and t = 0 into the linear interpolation used to do the time to date conversion.

@pcaspers
Copy link
Contributor Author

pcaspers commented Sep 4, 2023

Looking a bit closer I notice that for quite a few d we have vol->optionDateFromTime(vol->timeFromReference(d)) != d (independent of this fix here). I won't try to fix that under this ticket, I believe this is not straightforward to achieve in general.

@pcaspers
Copy link
Contributor Author

pcaspers commented Sep 4, 2023

@lballabio I'll check the failing test cases with high resolution dates - however I'll wait for your confirmation that we want to do this "intermediate" fix.

@lballabio
Copy link
Owner

Ouch, this slipped under the radar. I'm ok, I guess? I'd just keep optionDatesAsReal_ too, as you kept optionTimes_. It's in the protected section, so unfortunately it needs backward compatibility.

@pcaspers
Copy link
Contributor Author

I think the code mixes up the evaluation date from the settings with the reference date from the term structure. I fixed that, but renamed the protected member evaluationDate_ to cachedReferenceDate_. Do you think this is okay? After all, if this member is used in a derived class, the interpretation changes.

@pcaspers
Copy link
Contributor Author

The 3 new issues in the "Codacy Static Code Analysis" check look like false positives. Can those be added to an ignore-list somewhere?

Comment on lines -79 to -80
registerWith(Settings::instance().evaluationDate());
evaluationDate_ = Settings::instance().evaluationDate();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because it's already done in the base class, right? We still need a notification if the evaluation date changes, don't we?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think it is done in the TermStructure constructor.

@lballabio
Copy link
Owner

I fixed that, but renamed the protected member evaluationDate_ to cachedReferenceDate_. Do you think this is okay?

I would hope derived classes are not using it. Let's change it, I'll document the possibly breaking change in the release notes. I don't see an easy way to rename it in a backward-compatible way.

@pcaspers
Copy link
Contributor Author

Sounds good. So we are done here or is there something left to do for me?

@lballabio
Copy link
Owner

Nope, I'm merging.

@lballabio lballabio merged commit eaa249d into lballabio:master Sep 29, 2023
49 checks passed
@lballabio lballabio added this to the Release 1.32 milestone Oct 3, 2023
pcaspers added a commit to OpenSourceRisk/QuantLib that referenced this pull request Oct 15, 2023
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