pub struct OptionInstrumentPair {
pub call: Option<OptionInstrument>,
pub put: Option<OptionInstrument>,
}Expand description
A pair of option instruments representing both call and put options for the same underlying asset
This structure groups together the call and put options for a specific underlying asset, allowing for easy access to both sides of an option strategy. Both options are optional, meaning you can have just a call, just a put, or both.
Fields§
§call: Option<OptionInstrument>Call option instrument data, if available
put: Option<OptionInstrument>Put option instrument data, if available
Implementations§
Source§impl OptionInstrumentPair
impl OptionInstrumentPair
Sourcepub fn expiration(&self) -> Option<DateTime<Utc>>
pub fn expiration(&self) -> Option<DateTime<Utc>>
Returns the expiration date and time of the option instrument
§Returns
Some(DateTime<Utc>)- The expiration timestamp if availableNone- If no instrument is available or expiration timestamp is not set
Sourcepub fn instrument(&self) -> Option<Instrument>
pub fn instrument(&self) -> Option<Instrument>
Returns the first available instrument from either the call or put option
§Returns
Some(Instrument)- The instrument data from call option if available, otherwise from put optionNone- If neither call nor put options are available
Sourcepub fn ticker(&self) -> Option<TickerData>
pub fn ticker(&self) -> Option<TickerData>
Returns the first available ticker data from either the call or put option
§Returns
Some(TickerData)- The ticker data from call option if available, otherwise from put optionNone- If neither call nor put options are available
Sourcepub fn volume(&self) -> f64
pub fn volume(&self) -> f64
Calculates the total trading volume across both call and put options
§Returns
The sum of volumes from both call and put options. Returns 0.0 if no options are available.
Sourcepub fn open_interest(&self) -> f64
pub fn open_interest(&self) -> f64
Calculates the total open interest across both call and put options
§Returns
The sum of open interest from both call and put options. Returns 0.0 if no options are available.
Sourcepub fn interest_rate(&self) -> f64
pub fn interest_rate(&self) -> f64
Calculates the total interest rate across both call and put options
§Returns
The sum of interest rates from both call and put options. Returns 0.0 if no options are available.
Sourcepub fn value(&self) -> Option<Value>
pub fn value(&self) -> Option<Value>
Serializes the option instrument pair to a JSON value
§Returns
Some(Value)- The serialized JSON representation of this option pairNone- If serialization fails
Sourcepub fn call_spread(&self) -> Spread
pub fn call_spread(&self) -> Spread
Calculates the bid-ask spread for the call option
§Returns
A Spread struct containing bid, ask, and mid prices for the call option.
Returns empty spread (all None values) if no call option is available.
Sourcepub fn put_spread(&self) -> Spread
pub fn put_spread(&self) -> Spread
Calculates the bid-ask spread for the put option
§Returns
A Spread struct containing bid, ask, and mid prices for the put option.
Returns empty spread (all None values) if no put option is available.
Sourcepub fn iv(&self) -> (Option<f64>, Option<f64>)
pub fn iv(&self) -> (Option<f64>, Option<f64>)
Returns the implied volatility for both call and put options
§Returns
A tuple containing (call_iv, put_iv) where each element is the implied volatility
for the respective option, or None if not available.
Sourcepub fn greeks(&self) -> BasicGreeks
pub fn greeks(&self) -> BasicGreeks
Calculates and returns the basic Greeks for both call and put options
§Returns
A BasicGreeks struct containing delta values for call and put options,
and gamma value (taken from either option if available).
Sourcepub fn data(&self) -> BasicOptionData
pub fn data(&self) -> BasicOptionData
Extracts and consolidates all relevant option data into a structured format
§Returns
A BasicOptionData struct containing comprehensive option information including
strike price, bid/ask prices, implied volatility, Greeks, volume, open interest,
expiration date, underlying price, risk-free rate, and additional fields.
Trait Implementations§
Source§impl Clone for OptionInstrumentPair
impl Clone for OptionInstrumentPair
Source§fn clone(&self) -> OptionInstrumentPair
fn clone(&self) -> OptionInstrumentPair
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OptionInstrumentPair
impl Debug for OptionInstrumentPair
Source§impl<'de> Deserialize<'de> for OptionInstrumentPair
impl<'de> Deserialize<'de> for OptionInstrumentPair
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for OptionInstrumentPair
impl Display for OptionInstrumentPair
Auto Trait Implementations§
impl Freeze for OptionInstrumentPair
impl RefUnwindSafe for OptionInstrumentPair
impl Send for OptionInstrumentPair
impl Sync for OptionInstrumentPair
impl Unpin for OptionInstrumentPair
impl UnwindSafe for OptionInstrumentPair
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.