pub struct AnalyticDoubleBarrierEngine;Expand description
Prices continuous double-barrier options analytically with flat rates.
See Self::price for usage and applicability limits.
Trait Implementations§
Source§impl Clone for AnalyticDoubleBarrierEngine
impl Clone for AnalyticDoubleBarrierEngine
impl Copy for AnalyticDoubleBarrierEngine
Source§impl Debug for AnalyticDoubleBarrierEngine
impl Debug for AnalyticDoubleBarrierEngine
Source§impl PricingEngine<DoubleBarrierOption> for AnalyticDoubleBarrierEngine
impl PricingEngine<DoubleBarrierOption> for AnalyticDoubleBarrierEngine
Source§fn price(
&self,
option: &DoubleBarrierOption,
context: &PricingContext,
) -> Result<f64>
fn price( &self, option: &DoubleBarrierOption, context: &PricingContext, ) -> Result<f64>
Prices inclusive boundary touches, prior history and remaining cash flows.
Uses image/spectral absorbing-density series and first-exit rebate integration. Resolved contracts settle before the continuous-monitoring restriction.
§Errors
Missing required history returns crate::Error::MissingHistory;
see the caller-supplied history contract.
Returns Error::UnsupportedOperation for nonconstant rate curves or unresolved schedules at positive volatility,
Error::InvalidInput outside life, for impossible history,
or outside required curve coverage. Unrepresentable
calculations return Error::ComputationFailure; series or integration
limits reached without convergence return Error::NonConvergence.
§Examples
use kiyosi::*;
let start = Date::new(2025, 1, 1)?.start_of_day();
let option = DoubleBarrierOption::new(DoubleBarrierOptionTerms::new(OptionType::Call,
100.0, start, Date::new(2026, 1, 1)?.start_of_day(), 80.0, 120.0, DoubleBarrierType::KnockOut))?;
let context = PricingContext::new(BlackScholesMertonParameters::new(0.04, 0.01, 0.2)?,
100.0, start.into())?;
assert!((AnalyticDoubleBarrierEngine.price(&option, &context)? - 1.0838814592583166).abs() < 1e-9);§Greeks
Computes all requested numerical Greeks using the shared core bump defaults.
Expiry Greeks follow terminal payoffs. At a current touch, rate and
volatility Greeks follow the resolved payoff. Spot derivatives can be
undefined where a touch changes cash flows. Stencils reaching such boundaries
or changing observation/history regimes omit affected measures.
See Self::price for a construction example.
§Errors
Missing required history returns crate::Error::MissingHistory;
see the caller-supplied history contract.
Reuses crate::numerical_greeks validation and propagates pricing failures.
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 AnalyticDoubleBarrierEngine
impl RefUnwindSafe for AnalyticDoubleBarrierEngine
impl Send for AnalyticDoubleBarrierEngine
impl Sync for AnalyticDoubleBarrierEngine
impl Unpin for AnalyticDoubleBarrierEngine
impl UnsafeUnpin for AnalyticDoubleBarrierEngine
impl UnwindSafe for AnalyticDoubleBarrierEngine
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