diff --git a/LICENSE b/LICENSE index de21dbd..7b04c08 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 hnakashima +Copyright (c) 2024 Hikaru Nakashima Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,3 +19,19 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +The externally maintained library from which parts of the Software is derived is: + + - LetsBeRational, licensed as follows: + + ========================================================================================= + Copyright © 2013 - 2023 Peter Jäckel. + + Permission to use, copy, modify, and distribute this software is freely granted, + provided that this notice is preserved. + + WARRANTY DISCLAIMER + The Software is provided "as is" without warranty of any kind, either express or implied, + including without limitation any implied warranties of condition, uninterrupted use, + merchantability, fitness for a particular purpose, or non-infringement. + ========================================================================================== diff --git a/README.md b/README.md index 763de4b..263b79e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,10 @@ -# implied-vol -A pure rust implementation of Peter Jäckel's implied volatility calculation +# Implied Vol + +Welcome to `implied-vol`, a lightning-fast, pure Rust implementation of Peter Jäckel's renowned implied volatility +calculations. + +Originally found at [Peter Jäckel's homepage](http://www.jaeckel.org/), this library is a robust Rust reimplementation +of the pioneering work laid out in Jäckel's article, [Let's Be Rational](http://www.jaeckel.org/LetsBeRational.pdf). + +Our aim is to offer a tool that provides blazingly fast and precise calculations of implied Black volatility. +With `implied-vol`, speed and accuracy in your quantitative finance projects need not be mutually exclusive. \ No newline at end of file diff --git a/src/lets_be_rational.rs b/src/lets_be_rational.rs index 78dceb6..78d7428 100644 --- a/src/lets_be_rational.rs +++ b/src/lets_be_rational.rs @@ -183,6 +183,19 @@ fn normalised_black(x: f64, s: f64, theta: f64) -> f64 { normalised_black_call(if theta < 0f64 { -x } else { x }, s) } +/// Calculates the price of a European option using the Black-Scholes formula. +/// +/// # Arguments +/// +/// * `f` - The current value of the underlying asset. +/// * `k` - The strike price of the option. +/// * `sigma` - The volatility of the underlying asset. +/// * `t` - The time to expiration of the option. +/// * `q` - Positive if call else put. +/// +/// # Returns +/// +/// The price of the European option. pub fn black(f: f64, k: f64, sigma: f64, t: f64, q: f64) -> f64 { let intrinsic = if q < 0f64 { k - f } else { f - k }.max(0f64).abs(); if q * (f - k) > 0f64 { @@ -452,6 +465,19 @@ fn implied_volatility_from_a_transformed_rational_guess_with_limited_iterations( // return unchecked_normalised_implied_volatility_from_a_transformed_rational_guess_with_limited_iterations(beta, x, q, n); // } +/// Calculates the implied black volatility using a transformed rational guess with limited iterations. +/// +/// # Arguments +/// +/// * `price` - The current price of the option. +/// * `f` - The current forward price of the underlying asset. +/// * `k` - The strike price of the option. +/// * `t` - The time to expiration in years. +/// * `q` - Positive if call else put. +/// +/// # Returns +/// +/// The implied black volatility. pub fn implied_black_volatility(price: f64, f: f64, k: f64, t: f64, q: f64) -> f64 { implied_volatility_from_a_transformed_rational_guess_with_limited_iterations(price, f, k, t, q, 2) }