Struct options_common::SharesPosition
source · [−]pub struct SharesPosition {
pub symbol: String,
pub is_long: bool,
pub unit_cost: Option<Rational64>,
pub unit_bid_price: Option<Rational64>,
pub unit_ask_price: Option<Rational64>,
pub quantity: Rational64,
}
Fields
symbol: String
The symbol of the stock.
is_long: bool
Whether the position is long or short the underlying.
unit_cost: Option<Rational64>
The original cost per share in this position. If the position is long, this should be negative.
unit_bid_price: Option<Rational64>
The current bid price per share in this position. If the position is long, this should be positive.
unit_ask_price: Option<Rational64>
The current ask price per share in this position. If the position is long, this should be positive.
quantity: Rational64
The number of shares in this position.
Trait Implementations
sourcefn clone(&self) -> SharesPosition
fn clone(&self) -> SharesPosition
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourcefn from(v: SharesPosition) -> Position
fn from(v: SharesPosition) -> Position
Converts to this type from the input type.
sourcefn symbol(&self) -> &str
fn symbol(&self) -> &str
For an option position, the symbol of the option itself. For a share position, equal to Self::underlying_symbol()
.
sourcefn underlying_symbol(&self) -> &str
fn underlying_symbol(&self) -> &str
For an option position, the symbol of the instrument that the option is a derivative of. For a share position, the symbol of the stock. Read more
sourcefn unit_cost(&self) -> Option<Rational64>
fn unit_cost(&self) -> Option<Rational64>
The original cost per option contract or share in this position. If the position is long, this should be negative.
fn unit_cost_mut(&mut self) -> &mut Option<Rational64>
sourcefn unit_bid_price(&self) -> Option<Rational64>
fn unit_bid_price(&self) -> Option<Rational64>
The current bid price per option contract or share in this position. If the position is long, this should be positive.
fn unit_bid_price_mut(&mut self) -> &mut Option<Rational64>
sourcefn unit_ask_price(&self) -> Option<Rational64>
fn unit_ask_price(&self) -> Option<Rational64>
The current ask price per option contract or share in this position. If the position is long, this should be positive.
fn unit_ask_price_mut(&mut self) -> &mut Option<Rational64>
sourcefn unit_delta(&self) -> Option<NotNan<f64>>
fn unit_delta(&self) -> Option<NotNan<f64>>
The delta per option contract or share in this position, where the delta equivalent of 1 share == 0.01.
sourcefn unit_vega(&self) -> Option<NotNan<f64>>
fn unit_vega(&self) -> Option<NotNan<f64>>
The vega per option contract or share in this position.
sourcefn unit_theta(&self) -> Option<NotNan<f64>>
fn unit_theta(&self) -> Option<NotNan<f64>>
The theta per option contract in this position.
sourcefn quantity(&self) -> Rational64
fn quantity(&self) -> Rational64
The number of option contracts or shares in this position.
fn quantity_mut(&mut self) -> &mut Rational64
sourcefn equivalent_strike_price(&self) -> Rational64
fn equivalent_strike_price(&self) -> Rational64
For an option position, the strike price of the option. For a share position, the strike price of the call option with the equivalent cost at the time of purchase i.e. $0. Read more
sourcefn equivalent_option_type(&self) -> OptionType
fn equivalent_option_type(&self) -> OptionType
For an option position, the type of the option. For a share position, equal to OptionType::Call
.
sourcefn equivalent_lot_size(&self) -> i64
fn equivalent_lot_size(&self) -> i64
For an option position, the number of units of the underlying per option contract. For a share position, equal to 1. Read more
sourcefn signed_quantity(&self) -> Rational64
fn signed_quantity(&self) -> Rational64
Equal to Self::quantity()
, but negative if the position is short.
sourcefn cost(&self) -> Option<Rational64>
fn cost(&self) -> Option<Rational64>
The total original cost of all option contracts or shares in this position.
fn net_liq(&self) -> Option<Rational64>
sourcefn bid_price(&self) -> Option<Rational64>
fn bid_price(&self) -> Option<Rational64>
The total current bid price for all option contracts or shares in this position.
sourcefn ask_price(&self) -> Option<Rational64>
fn ask_price(&self) -> Option<Rational64>
The total current ask price for all option contracts or shares in this position.
sourcefn mid_price(&self) -> Option<Rational64>
fn mid_price(&self) -> Option<Rational64>
The total current mid price for all option contracts or shares in this position.
sourcefn unit_mid_price(&self) -> Option<Rational64>
fn unit_mid_price(&self) -> Option<Rational64>
The current mid price per option contract or share in this position. If the position is long, this will be positive.
sourcefn delta(&self) -> Option<NotNan<f64>>
fn delta(&self) -> Option<NotNan<f64>>
The total delta for all option contracts or shares in this position, where the delta equivalent of 1 share == 0.01.
sourcefn vega(&self) -> Option<NotNan<f64>>
fn vega(&self) -> Option<NotNan<f64>>
The total vega for all option contracts or shares in this position.
sourcefn theta(&self) -> Option<NotNan<f64>>
fn theta(&self) -> Option<NotNan<f64>>
The total theta for all option contracts or shares in this position.
fn profit_at_expiry(&self, underlying_price: Rational64) -> Rational64
sourcefn eq(&self, other: &SharesPosition) -> bool
fn eq(&self, other: &SharesPosition) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SharesPosition) -> bool
fn ne(&self, other: &SharesPosition) -> bool
This method tests for !=
.
sourcefn try_into(
self
) -> Result<SharesPosition, <Self as TryInto<SharesPosition>>::Error>
fn try_into(
self
) -> Result<SharesPosition, <Self as TryInto<SharesPosition>>::Error>
Performs the conversion.
Auto Trait Implementations
Blanket Implementations
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.