Closed dgbustos closed 5 years ago
Thanks for bringing up this issue @dgbustos ! I've gone back and forth when considering the API for the implied volatility functions. With the "approximate_vol" function providing a value close to the optimum value I have not ever had a panic. In the tests I randomly simulate parameters; with no panics.
Have you actually experienced a panic when using the implied volatility functions? If so, can you provide the parameters which resulted in the panic?
Thanks!
I have 500 examples from a recent file of SPY option quotes. They're all for deep-in-the-money calls. For example
black_scholes::call_iv( 50.275, 274.525, 225.000, 0.0244, 0.156 );
black_scholes::call_iv( 62.02, 274.525, 222.000, 0.0244, 1.823 );
When I encountered this in another library, I think I tracked the reason down to negative time value, and https://math.stackexchange.com/a/2959355 might be informative.
That makes a lot of sense. I'll update the code (hopefully this weekend) and bump the crates version.
In
call_iv()
, if there is no volatility which matches the price, thennrfind::find_root()
incall_iv_guess()
will returnResult.Err
andunwrap()
will panic.call_iv()
and the like should probably returnResult<f64>
instead off64
.