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§
impl Copy for BjerksundStenslandVanillaEngine
Source§impl PricingEngine<AmericanOption> for BjerksundStenslandVanillaEngine
impl PricingEngine<AmericanOption> for BjerksundStenslandVanillaEngine
Source§fn price(
&self,
option: &AmericanOption,
context: &PricingContext,
) -> Result<f64>
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<()>
fn validate_applicability(&self, context: &PricingContext) -> Result<()>
Source§fn price_with_greeks(
&self,
option: &I,
context: &PricingContext,
request: GreeksRequest,
) -> Result<PricingResult>where
I: OptionContract,
fn price_with_greeks(
&self,
option: &I,
context: &PricingContext,
request: GreeksRequest,
) -> Result<PricingResult>where
I: OptionContract,
Source§fn price_with_greeks_with_settings(
&self,
option: &I,
context: &PricingContext,
request: GreeksRequest,
settings: NumericalShiftSettings,
) -> Result<PricingResult>where
I: OptionContract,
fn price_with_greeks_with_settings(
&self,
option: &I,
context: &PricingContext,
request: GreeksRequest,
settings: NumericalShiftSettings,
) -> Result<PricingResult>where
I: OptionContract,
Source§fn greek_method(
&self,
option: &I,
context: &PricingContext,
) -> Result<GreekMethod>where
I: OptionContract,
fn greek_method(
&self,
option: &I,
context: &PricingContext,
) -> Result<GreekMethod>where
I: OptionContract,
Source§fn default_spot_shift(&self, _option: &I, context: &PricingContext) -> f64
fn default_spot_shift(&self, _option: &I, context: &PricingContext) -> f64
Source§fn validate_solver_seed(&self) -> Result<()>
fn validate_solver_seed(&self) -> Result<()>
Source§fn prepare_request(&self) -> Result<Option<Box<dyn PricingEngine<I> + '_>>>
fn prepare_request(&self) -> Result<Option<Box<dyn PricingEngine<I> + '_>>>
Source§fn price_with_seed(
&self,
option: &I,
context: &PricingContext,
) -> Result<(f64, Option<u64>)>
fn price_with_seed( &self, option: &I, context: &PricingContext, ) -> Result<(f64, Option<u64>)>
None without sampling. Read moreSource§fn price_with_statistics(
&self,
_option: &I,
_context: &PricingContext,
) -> Result<MonteCarloEstimate>
fn price_with_statistics( &self, _option: &I, _context: &PricingContext, ) -> Result<MonteCarloEstimate>
Source§fn volatility_affects_price(&self, option: &I, context: &PricingContext) -> boolwhere
I: OptionContract,
fn volatility_affects_price(&self, option: &I, context: &PricingContext) -> boolwhere
I: OptionContract,
Source§fn prepare_implied_volatility(
&self,
_option: &I,
_context: &PricingContext,
settings: ImpliedVolatilitySettings,
) -> Result<ImpliedVolatilitySettings>
fn prepare_implied_volatility( &self, _option: &I, _context: &PricingContext, settings: ImpliedVolatilitySettings, ) -> Result<ImpliedVolatilitySettings>
Auto Trait Implementations§
impl Freeze for BjerksundStenslandVanillaEngine
impl RefUnwindSafe for BjerksundStenslandVanillaEngine
impl Send for BjerksundStenslandVanillaEngine
impl Sync for BjerksundStenslandVanillaEngine
impl Unpin for BjerksundStenslandVanillaEngine
impl UnsafeUnpin for BjerksundStenslandVanillaEngine
impl UnwindSafe for BjerksundStenslandVanillaEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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