FinancialToolbox.jl
FinancialToolbox.jl copied to clipboard
[proposal] don't error for implied vol non-convergence
It is quite annoying (I think) that blkimpv or blsimpv error when for whatever reason they can't find the iv. I am broadcasting the function over hundreds of options, I have no clue which one is the troublemaker, so how am I supposed to debug it?
Instead of throwing an error, just return something like NaN, missing, -999.999, etc. (I'd pick missing). Add a note about it in the docstring. The user can then inspect those options to try to find the underlying issue or can easily just delete those observations. This should not impact performance because the compiler can optimize over small type unions.
You could add a kwarg to disable/enable this if you wanted.
Sorry I missed this, I think that is reasonable to raise an error in such situation since the problem is not the convergence of the method but the actual existence of such value, otherwise you can tune the tolerance values in order to get convergence.
You are supposed to manage such error since you are not sure about the existence of the implied volatility.
I will add a more appropriate check since the function to invert is monotone.
I think it is nonsense to throw an ACTUAL error. NaN or missing are observationally equivalent for this purpose and way less disruptive. I also disagree with what you've said the problem is. The conditions for the mere existence of an implied volatility value are not hard to satisfy -- if you have anything remotely resembling actual market data then the implied vol exists. Therefore, the problem actually is one of non-convergence and not one of existence.
EDIT: Rereading this and my tone perhaps could be interpreted as aggressive. I did not intend that FYI. I just don't see the value in the error. That's all.
Would you mind to provide an example where it happens that the algorithm is throwing? I would like to switch to Roots.jl for Brent instead of using my own, but I would like to be sure that the problem is not showing up there as well.
Approved, it will be available in the next release.