Skip to main content

BjerksundStenslandVanillaEngine

Struct BjerksundStenslandVanillaEngine 

Source
pub struct BjerksundStenslandVanillaEngine;
Expand description

Prices American vanilla options using the Bjerksund-Stensland 2002 approximation.

This synchronous, stateless engine supports shared concurrent use. It accepts scalar or constant rates only; it never substitutes another American algorithm. See Self::price for an example and applicability limits.

Trait Implementations§

Source§

impl Clone for BjerksundStenslandVanillaEngine

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for BjerksundStenslandVanillaEngine

Source§

impl Debug for BjerksundStenslandVanillaEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BjerksundStenslandVanillaEngine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PricingEngine<AmericanOption> for BjerksundStenslandVanillaEngine

Source§

fn price( &self, option: &AmericanOption, context: &PricingContext, ) -> Result<f64>

Returns the approximation, bounded below by intrinsic and European values.

At expiry returns intrinsic value, including under negative rates.

§Errors

Returns Error::UnsupportedOperation for nonconstant rate curves (before life validation), or, at positive volatility before expiry, negative transformed interest rates (call: rate; put: dividend), exercise boundaries at or below the strike, or boundaries out of decreasing order. Returns Error::InvalidInput outside the inclusive exercise window and Error::ComputationFailure for unstable exponents or non-finite results. European continuation pricing errors propagate.

§Examples
use kiyosi::{PricingEngine, AmericanOption, BjerksundStenslandVanillaEngine,
    BlackScholesMertonParameters, Date, OptionType, PricingContext};
let start = Date::new(2025, 1, 1)?.start_of_day();
let option = AmericanOption::new(OptionType::Put, 100.0, start, Date::new(2026, 1, 1)?.start_of_day())?;
let context = PricingContext::new(
    BlackScholesMertonParameters::new(0.05, 0.03, 0.2)?, 100.0, start.into())?;
let price = BjerksundStenslandVanillaEngine.price(&option, &context)?;
assert!((price - 6.95040044663925).abs() < 1e-11);
§Greeks

Returns the price and requested finite-difference Greeks with core bump defaults.

Expiry Greeks follow terminal payoffs; time Greeks are absent. Rate bumps outside the approximation’s domain leave the affected Greek unavailable.

§Errors

Checks flat-rate applicability before shift validation, then reuses Self::price and crate::numerical_greeks errors.

§Examples
use kiyosi::PricingEngine;
use kiyosi::{AmericanOption, BjerksundStenslandVanillaEngine,
    BlackScholesMertonParameters, Date, OptionType, PricingContext, Greek, GreeksRequest};
let start = Date::new(2025, 1, 1)?.start_of_day();
let option = AmericanOption::new(OptionType::Put, 100.0, start, Date::new(2026, 1, 1)?.start_of_day())?;
let context = PricingContext::new(
    BlackScholesMertonParameters::new(0.05, 0.03, 0.2)?, 100.0, start.into())?;
let result = BjerksundStenslandVanillaEngine.price_with_greeks(&option, &context,
    GreeksRequest::new([Greek::Delta]))?;
assert!(result.require(Greek::Delta)? < 0.0);
Source§

fn validate_applicability(&self, context: &PricingContext) -> Result<()>

Checks engine applicability before numerical requests or implied-volatility validation. Read more
Source§

fn price_with_greeks( &self, option: &I, context: &PricingContext, request: GreeksRequest, ) -> Result<PricingResult>
where I: OptionContract,

Returns requested sensitivities using shared bump defaults. Read more
Source§

fn price_with_greeks_with_settings( &self, option: &I, context: &PricingContext, request: GreeksRequest, settings: NumericalShiftSettings, ) -> Result<PricingResult>
where I: OptionContract,

Returns native sensitivities with explicit request-level numerical controls. Read more
Source§

fn greek_method( &self, option: &I, context: &PricingContext, ) -> Result<GreekMethod>
where I: OptionContract,

Reports the native Greek calculation path without pricing or drawing samples. Read more
Source§

fn default_spot_shift(&self, _option: &I, context: &PricingContext) -> f64

Returns the automatic pre-expiry spot bump for this engine and contract family. Read more
Source§

fn validate_solver_seed(&self) -> Result<()>

Checks that a solver’s random draws can be replayed by the caller. Read more
Source§

fn prepare_request(&self) -> Result<Option<Box<dyn PricingEngine<I> + '_>>>

Prepares request-local state for numerical Greeks and implied-parameter solvers. Read more
Source§

fn price_with_seed( &self, option: &I, context: &PricingContext, ) -> Result<(f64, Option<u64>)>

Returns a scalar price and the seed used, or None without sampling. Read more
Source§

fn price_with_statistics( &self, _option: &I, _context: &PricingContext, ) -> Result<MonteCarloEstimate>

Returns a price with sampling uncertainty when the engine provides an estimator. Read more
Source§

fn volatility_affects_price(&self, option: &I, context: &PricingContext) -> bool
where I: OptionContract,

Reports whether volatility affects a validated contract’s remaining payoff. Read more
Source§

fn prepare_implied_volatility( &self, _option: &I, _context: &PricingContext, settings: ImpliedVolatilitySettings, ) -> Result<ImpliedVolatilitySettings>

Restricts a validated solver bracket to the engine’s supported domain. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.