hayden4r4 / blackscholes-rust

A Black-Scholes pricing model built in Rust
MIT License
11 stars 6 forks source link

add support for pricing via "let's be rational" #4

Closed yonch closed 1 year ago

yonch commented 1 year ago

the "let's be rational" paper claims to have put significant effort into stabilizing pricing (not only computing implied volatility):

As was perhaps previously underestimated, of crucial importance for the precision of the implied volatility is a highly accurate Black function that minimizes round- off errors and numerical truncations in the various para- meter limits. We implement the Black call option price by the aid of Cody’s [Cod69, Cod90] rational approxim- ation for the complementary error function erfc(·) and its little known cousin, the scaled complementary error func- tion erfcx(·).

(from the paper's abstract)

This PR adds FFI for let's be rational's black() function (also moving both wrappers into a module), and adds calc_rational_price() to the Pricing trait (similar naming convention as calc_iv() / calc_rational_iv().

A new test (which passes for me) compares the output of calc_rational_price() to calc_price().