mod greeks_higher;
mod greeks_impl;
mod iv;
mod math;
mod pricing;
use crate::{
core::{Greeks, MarketData, VanillaOption},
models::VanillaModel,
};
#[derive(Debug, Clone, Copy, Default)]
pub struct BlackScholes {
pub vol: f64,
}
impl BlackScholes {
pub fn new(vol: f64) -> Self {
Self { vol }
}
}
impl VanillaModel for BlackScholes {
fn price(&self, opt: &VanillaOption, mkt: &MarketData) -> Result<f64, String> {
BlackScholes::price(opt, mkt, self.vol)
}
fn greeks(&self, opt: &VanillaOption, mkt: &MarketData) -> Result<Greeks, String> {
BlackScholes::greeks(opt, mkt, self.vol)
}
fn implied_vol(
&self,
target_price: f64,
opt: &VanillaOption,
mkt: &MarketData,
) -> Result<f64, String> {
BlackScholes::rational_implied_vol(target_price, opt, mkt)
}
}