pub trait VanillaModel {
// Required methods
fn price(
&self,
opt: &VanillaOption,
mkt: &MarketData,
) -> Result<f64, String>;
fn greeks(
&self,
opt: &VanillaOption,
mkt: &MarketData,
) -> Result<Greeks, String>;
fn implied_vol(
&self,
target_price: f64,
opt: &VanillaOption,
mkt: &MarketData,
) -> Result<f64, String>;
}Expand description
Core abstraction for a model that can price vanilla options.
This trait is intentionally conservative in scope for now:
- it operates only on the core domain types,
- it does not prescribe any particular volatility parametrisation,
- it exposes fallible operations via
Resultso callers can handle invalid inputs explicitly.
Required Methods§
Sourcefn price(&self, opt: &VanillaOption, mkt: &MarketData) -> Result<f64, String>
fn price(&self, opt: &VanillaOption, mkt: &MarketData) -> Result<f64, String>
Price a vanilla option under this model.
Sourcefn greeks(
&self,
opt: &VanillaOption,
mkt: &MarketData,
) -> Result<Greeks, String>
fn greeks( &self, opt: &VanillaOption, mkt: &MarketData, ) -> Result<Greeks, String>
Compute a set of Greeks for a vanilla option.
Sourcefn implied_vol(
&self,
target_price: f64,
opt: &VanillaOption,
mkt: &MarketData,
) -> Result<f64, String>
fn implied_vol( &self, target_price: f64, opt: &VanillaOption, mkt: &MarketData, ) -> Result<f64, String>
Compute implied volatility such that the model price matches target_price.