Skip to main content

Instrument

Trait Instrument 

Source
pub trait Instrument {
    // Required method
    fn try_npv(&self) -> Result<f64, RustyQLibError>;

    // Provided methods
    fn npv(&self) -> f64 { ... }
    fn price(&self) -> Result<PricingResult, RustyQLibError> { ... }
}

Required Methods§

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

Provided Methods§

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.

Source

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

Price the instrument once, returning value, Greeks and (for Monte Carlo engines) the standard error together in a PricingResult.

The default implementation reports the present value with zero Greeks; instruments that compute sensitivities override it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§