Skip to main content

PriceBlackScholes

Struct PriceBlackScholes 

Source
pub struct PriceBlackScholes { /* private fields */ }
Expand description

Builder-backed container for computing undiscounted European option prices under the Black–Scholes model.

Construct instances with PriceBlackScholes::builder(). The builder performs basic domain validation when you call .build(). Use .build_unchecked() to skip validation when you know inputs are already valid.

Fields:

  • forward: forward price of the underlying (F). Must be finite.
  • strike: strike price (K). Must be finite.
  • volatility: volatility (σ). Must be finite and σ >= 0.
  • expiry: time to expiry (T). Must be finite and T >= 0.
  • is_call: true to price a call option, false to price a put option.

The calculate::<SpFn>() method performs the numerical evaluation and uses a SpecialFn implementation for any special-function approximations required by the numerical routines.

Implementations§

Source§

impl PriceBlackScholes

Source

pub const fn builder() -> PriceBlackScholesBuilder

Create an instance of PriceBlackScholes using the builder syntax

Source§

impl PriceBlackScholes

Source

pub fn calculate<SpFn: SpecialFn>(&self) -> f64

Compute the undiscounted Black–Scholes option price for the stored inputs.

§Type parameter
  • SpFn: SpecialFn — implementation used for internal special-function evaluations. Use the crate’s DefaultSpecialFn for the default behavior or provide a custom implementation to change numerical characteristics.
§Returns

The computed undiscounted European option price.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.