Closed Zarathustra2 closed 2 years ago
The API change makes sense, feel free to work on it and PR.
Is decimal that big of a deal? Any loss in precision is dwarfed by model error :).
I added a cached version that computes all prices and strikes at once.
Wow, awesome! Thanks @danielhstahl :)
The benchmark comparison between the cache and the "naive" calling of each price and greek individually: https://danielhstahl.github.io/black_scholes_rust/dev/bench/
Currently one has to call 5 functions -
gamma
,delta
,vega
,theta
,sigma/iv
, and the parameters of the function take a float and don't support decimals.Going forward I would like to add support for calculating greeks with decimals as input, https://docs.rs/rust_decimal/1.10.3/rust_decimal/
This can be added as a feature so users can decide whether they want to have the decimal feature or not.
Second, it would be nice if we could do something like this:
Benefits would be we could optimize the code - if we are interested in all greeks - in a way that we don't have to recalculate d1/d2 for instance.
Let me know what you think @danielhstahl, I can take a shot at this if you want.