Skip to main content

AnalyticDoubleBarrierEngine

Struct AnalyticDoubleBarrierEngine 

Source
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

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 AnalyticDoubleBarrierEngine

Source§

impl Debug for AnalyticDoubleBarrierEngine

Source§

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

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

impl Default for AnalyticDoubleBarrierEngine

Source§

fn default() -> Self

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

impl PricingEngine<DoubleBarrierOption> for AnalyticDoubleBarrierEngine

Source§

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<()>

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.