Struct 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§

Source§

impl Clone for SharesPosition

Source§

fn clone(&self) -> SharesPosition

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SharesPosition

Source§

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

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

impl From<SharesPosition> for Position

Source§

fn from(v: SharesPosition) -> Position

Converts to this type from the input type.
Source§

impl GenericPosition for SharesPosition

Source§

fn symbol(&self) -> &str

For an option position, the symbol of the option itself. For a share position, equal to Self::underlying_symbol().
Source§

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

fn is_long(&self) -> bool

Whether the position is long or short the underlying.
Source§

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

fn unit_cost_mut(&mut self) -> &mut Option<Rational64>

Source§

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

fn unit_bid_price_mut(&mut self) -> &mut Option<Rational64>

Source§

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

fn unit_ask_price_mut(&mut self) -> &mut Option<Rational64>

Source§

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

fn unit_vega(&self) -> Option<NotNan<f64>>

The vega per option contract or share in this position.
Source§

fn unit_theta(&self) -> Option<NotNan<f64>>

The theta per option contract in this position.
Source§

fn quantity(&self) -> Rational64

The number of option contracts or shares in this position.
Source§

fn quantity_mut(&mut self) -> &mut Rational64

Source§

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

fn equivalent_option_type(&self) -> OptionType

For an option position, the type of the option. For a share position, equal to OptionType::Call.
Source§

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

fn signed_quantity(&self) -> Rational64

Equal to Self::quantity(), but negative if the position is short.
Source§

fn cost(&self) -> Option<Rational64>

The total original cost of all option contracts or shares in this position.
Source§

fn net_liq(&self) -> Option<Rational64>

Source§

fn bid_price(&self) -> Option<Rational64>

The total current bid price for all option contracts or shares in this position.
Source§

fn ask_price(&self) -> Option<Rational64>

The total current ask price for all option contracts or shares in this position.
Source§

fn mid_price(&self) -> Option<Rational64>

The total current mid price for all option contracts or shares in this position.
Source§

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

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

fn vega(&self) -> Option<NotNan<f64>>

The total vega for all option contracts or shares in this position.
Source§

fn theta(&self) -> Option<NotNan<f64>>

The total theta for all option contracts or shares in this position.
Source§

fn profit_at_expiry(&self, underlying_price: Rational64) -> Rational64

Source§

impl PartialEq for SharesPosition

Source§

fn eq(&self, other: &SharesPosition) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryInto<SharesPosition> for Position

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<SharesPosition, <Self as TryInto<SharesPosition>>::Error>

Performs the conversion.
Source§

impl Eq for SharesPosition

Source§

impl StructuralPartialEq for SharesPosition

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

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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