Skip to main content

EquityOption

Struct EquityOption 

Source
pub struct EquityOption {
    pub base: EquityOptionBase,
    pub market: EquityMarketData,
    pub payoff: Box<dyn Payoff>,
    pub engine: PricingEngine,
    pub model: Model,
}

Fields§

§base: EquityOptionBase

The contract (and trade identity): pure data, never market state.

§market: EquityMarketData

The market this instrument is currently bound to.

§payoff: Box<dyn Payoff>§engine: PricingEngine

The numerical method, carrying its own settings.

§model: Model

The dynamics of the underlying (GBM, local vol, or Heston with its parameters); consulted by the MC, FD and analytic engines.

Implementations§

Source§

impl EquityOption

Source

pub fn snapshot_market(&self) -> Market

Snapshot this option’s embedded market objects into a typed Market anchored at the option’s valuation date. Repricing under the unmodified snapshot reproduces npv() exactly.

Source

pub fn with_market( &self, market: &Market, ) -> Result<EquityOption, RustyQLibError>

This contract rebound to market: spot, vol surface and discount curve are taken from the store (by symbol / currency code) and the valuation date from the snapshot; contract terms and engine are unchanged. Errors name the missing key when the market lacks data for this option.

The model moves with the market where it must: a Heston model’s parameters follow the surface’s parallel shift (measured at this contract’s strike and maturity) via Model::with_vol_shift, so vol scenarios reach Heston-priced positions without recalibration.

The market’s objects are expected to be anchored at its valuation date (as snapshot_market guarantees).

Source

pub fn npv_in(&self, market: &Market) -> Result<f64, RustyQLibError>

Value under a typed market snapshot: rebind, then price on the option’s own engine through the ordinary npv path.

Source§

impl EquityOption

Source

pub fn from_json(data: &EquityOptionData) -> Box<EquityOption>

Build an option from contract data, panicking on any invalid field. Fallible callers (batch pricing, services) should use EquityOption::try_from_json.

Source

pub fn try_from_json( data: &EquityOptionData, ) -> Result<Box<EquityOption>, RustyQLibError>

Build an option from contract data, reporting the offending field in the error instead of panicking.

This is a thin translation layer: it parses JSON-level fields (dates, enum strings) into typed values and feeds them through EquityOptionBuilder, which owns all domain validation and assembly — both construction paths share one set of checks.

Source§

impl EquityOption

Source

pub fn time_to_maturity(&self) -> f64

Source

pub fn maturity_discount_factor(&self) -> f64

Discount factor from the valuation date to maturity, off the curve.

Source

pub fn risk_free_rate(&self) -> f64

Continuously compounded zero rate to maturity implied by the curve. This is the r that enters d1/d2; it is consistent with maturity_discount_factor by construction.

Source

pub fn carry_yield(&self) -> f64

Total continuous carry on the underlying: dividend yield plus borrow cost. This is the “q” every pricing formula uses.

Source

pub fn pv_cash_dividends(&self) -> f64

Escrow value of the cash dividends with ex-dates inside the option’s life: the amount to carve out of spot so the risky stub reproduces the jump-model forward.

Each dividend is discounted at the net carry rate r - carry, not the risk-free rate, so that the escrow accretes at the same rate the risky stub grows (effective_spot is grown at r - carry in forward_price). This makes the analytic forward match the well-defined jump model F = (S - D e^{-(r-carry)t}) e^{(r-carry)T} used by the FD and path-wise Monte Carlo engines. With no continuous carry this reduces to plain risk-free discounting.

Source

pub fn effective_spot(&self) -> f64

Escrowed-model spot: the quoted spot minus the PV of cash dividends paid over the option’s life. This is the lognormal driver for the analytic and terminal-simulation engines.

Source

pub fn forward_price(&self) -> f64

Forward price of the underlying at maturity: escrowed spot grown at the carry-adjusted rate, (S - PV(divs)) * exp((r - q - b) * T).

Source

pub fn volatility(&self) -> f64

Black volatility for this option’s strike and expiry, read off the surface (a flat surface returns its single vol).

Source

pub fn d1(&self) -> f64

Source

pub fn d2(&self) -> f64

Source§

impl EquityOption

Source

pub fn get_premium_at_risk(&self) -> f64

Source

pub fn try_imp_vol(&self, option_price: f64) -> Result<f64, RustyQLibError>

Implied Black-Scholes volatility for option_price (safeguarded Newton with arbitrage-bound checks); does not modify the option.

Source

pub fn imp_vol(&mut self, option_price: f64) -> f64

Implied vol for option_price; leaves the option holding a flat surface at the solved vol. Panics on arbitrage-violating prices — use try_imp_vol to handle those gracefully.

Source

pub fn get_imp_vol(&mut self) -> f64

Source§

impl EquityOption

Greeks route through the central sensitivity engine (crate::equity::greeks): the FD and Binomial engines read delta/gamma/theta off their own grid/tree with higher orders from bumped solutions; the analytic engine uses the payoff-aware Black-Scholes closed forms (including Black-76 futures); the bump engines (Monte Carlo with common random numbers, BAW, Bjerksund-Stensland, analytic Heston) share one set of central-difference stencils with per-engine bump sizes.

Source

pub fn delta(&self) -> f64

Source

pub fn gamma(&self) -> f64

Source

pub fn vega(&self) -> f64

Source

pub fn theta(&self) -> f64

Source

pub fn rho(&self) -> f64

Source

pub fn vanna(&self) -> f64

Vanna: change in delta per unit change in implied volatility.

Source

pub fn charm(&self) -> f64

Charm: change in delta per year of calendar time.

Source

pub fn gamma_p(&self) -> f64

Delta elasticity (S * gamma / delta), also called percentage gamma.

Source

pub fn zomma(&self) -> f64

Zomma: change in gamma per unit change in implied volatility.

Source

pub fn volga(&self) -> f64

Volga (vomma): change in vega per unit change in implied volatility.

Source

pub fn price_with( &self, d_spot: f64, d_vol: f64, d_rate: f64, d_time: f64, ) -> f64

Reprice under a shifted market: spot + d_spot, a parallel implied vol shift + d_vol, rate + d_rate, and d_time years of elapsed calendar time. price_with(0, 0, 0, 0) is the base price; the portfolio PnL attribution uses the difference of the two.

Monte Carlo repricing uses common random numbers, so the difference is free of sampling noise.

Trait Implementations§

Source§

impl Clone for EquityOption

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 Debug for EquityOption

Source§

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

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

impl Instrument for EquityOption

Source§

fn price(&self) -> Result<PricingResult, RustyQLibError>

Value, all nine Greeks, and (on the Monte Carlo engine) the standard error, from one call — batched through the central sensitivity engine (crate::equity::greeks), which shares solves and reprices across the Greeks.

Source§

fn try_npv(&self) -> Result<f64, RustyQLibError>

Present value, or a typed error when the instrument cannot be priced (invalid inputs, or an engine/product combination the library refuses to price).
Source§

fn npv(&self) -> f64

Present value, panicking on any pricing error. Convenience for instruments already known to be valid; fallible callers (batch pricing, services) should use Instrument::try_npv.

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

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 = 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V