Skip to content

Commit

Permalink
Merge pull request #174 from lukaskiss222/feature/implied_volatility
Browse files Browse the repository at this point in the history
Implied volatility calculation based on lets be rational paper
  • Loading branch information
avhz authored Jan 31, 2024
2 parents 487d329 + 6cc9ebe commit eb1edff
Show file tree
Hide file tree
Showing 7 changed files with 1,123 additions and 14 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ tokio-test = { version = "0.4.2", optional = true }
yahoo_finance_api = { version = "2.0.0", optional = true }


# https://docs.rs/errorfunctions/latest/errorfunctions/
errorfunctions = "0.2.0"


[dev-dependencies]
finitediff = "0.1.4" # https://docs.rs/finitediff/latest/finitediff/

Expand Down
7 changes: 4 additions & 3 deletions src/instruments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ pub use bonds::*;
pub mod options {
pub use crate::instruments::options::{
american::*, asian::*, bachelier::*, barrier::*, binary::*, binomial::*,
black_scholes_merton::*, european::*, forward_start::*, greeks::*, heston::*, lookback::*,
merton_jump_diffusion::*, option::*, power::*,
black_scholes_merton::*, european::*, forward_start::*, greeks::*, heston::*,
implied_volatility::*, lookback::*, merton_jump_diffusion::*, option::*, power::*,
};

/// American option pricers.
pub mod american;
/// Asian option pricers.
Expand All @@ -121,6 +120,8 @@ pub mod options {
pub mod greeks;
/// Heston model option pricer.
pub mod heston;
/// Implied volatility functions.
pub mod implied_volatility;
/// Lookback option pricers.
pub mod lookback;
/// Merton (1976) jump diffusion model.
Expand Down
4 changes: 2 additions & 2 deletions src/instruments/options/black_scholes_merton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ impl BlackScholesMerton {
}
}

// Compute the year fraction between two dates.
/// Compute the year fraction between two dates.
#[must_use]
fn year_fraction(&self) -> f64 {
pub fn year_fraction(&self) -> f64 {
DayCounter::day_count_factor(
self.evaluation_date.unwrap_or(OffsetDateTime::now_utc()),
self.expiration_date,
Expand Down
Loading

0 comments on commit eb1edff

Please sign in to comment.