google / tf-quant-finance

High-performance TensorFlow library for quantitative finance.
Apache License 2.0
4.54k stars 574 forks source link

Options at-expiration return `nan` #89

Closed alembcke closed 1 year ago

alembcke commented 1 year ago

I am using tf-quant-finance for plotting option values and greeks. When plotting at-expiration (so expiries=0) most of the models return nan for some or all prices. Is this intended behavior, in which case I should wrap my calls to tf-quant-finance with some code to counter this, or is this something that could be changed?

This issue shows up for:

Only Black-Scholes-Merton and Bjerksund-Stensland with modified_boundary=False are not affected by this.

I could submit a PR to fix this issue, but before I do the work I want to make sure that this is a bug and not a feature.

saxena-ashish-g commented 1 year ago

This is definitely a bug. Please feel free to send a PR fixing whichever of the issues you would like and we will fix the rest.

alembcke commented 1 year ago

I tried to whip up a quick fix before heading on vacation, but it was slightly more complicated than I had hoped. If you have time to fix any of these issues, then please do. If anything is left in a few weeks when I am back, then I will work on it.