Struct Holding

Source
pub struct Holding {
Show 24 fields pub account_id: String, pub trading_symbol: String, pub exchange: Exchange, pub isin: String, pub product: Product, pub instrument_token: u32, pub quantity: i32, pub t1_quantity: i32, pub realised_quantity: i32, pub authorised_quantity: i32, pub authorised_date: Option<String>, pub opening_quantity: i32, pub collateral_quantity: i32, pub collateral_type: Option<String>, pub collateral_update_quantity: i32, pub discrepancy: bool, pub average_price: f64, pub last_price: f64, pub close_price: f64, pub price_change: f64, pub pnl: f64, pub day_change: f64, pub day_change_percentage: f64, pub used_quantity: i32,
}
Expand description

Holdings data structure

Fields§

§account_id: String

Account ID

§trading_symbol: String

Trading symbol

§exchange: Exchange

Exchange

§isin: String

ISIN (International Securities Identification Number)

§product: Product

Product type

§instrument_token: u32

Instrument token

§quantity: i32

Quantity in the holding

§t1_quantity: i32

T1 quantity (can be sold after T+1 day)

§realised_quantity: i32

Realised quantity (can be sold immediately)

§authorised_quantity: i32

Authorized quantity (pledged/unpledged)

§authorised_date: Option<String>

Authorised date

§opening_quantity: i32

Opening quantity at the start of the day

§collateral_quantity: i32

Collateral quantity

§collateral_type: Option<String>

Collateral type

§collateral_update_quantity: i32

Collateral update quantity

§discrepancy: bool

Discrepancy flag

§average_price: f64

Average price at which the stock was bought

§last_price: f64

Last price from exchange

§close_price: f64

Close price

§price_change: f64

Price change

§pnl: f64

P&L (profit and loss)

§day_change: f64

Day change

§day_change_percentage: f64

Day change percentage

§used_quantity: i32

Used quantity (used for pledging)

Implementations§

Source§

impl Holding

Source

pub fn market_value(&self) -> f64

Calculate current market value of the holding

Source

pub fn investment_value(&self) -> f64

Calculate investment value (at average price)

Source

pub fn pnl_percentage(&self) -> f64

Calculate the P&L percentage

Source

pub fn is_profitable(&self) -> bool

Check if the holding is profitable

Source

pub fn is_loss(&self) -> bool

Check if the holding is in loss

Source

pub fn available_quantity(&self) -> i32

Get available quantity for trading

Source

pub fn can_sell_today(&self) -> bool

Check if quantity can be sold today

Source

pub fn sellable_today(&self) -> i32

Get quantity that can be sold today

Source

pub fn sellable_tomorrow(&self) -> i32

Get quantity that can be sold tomorrow (T+1)

Source

pub fn has_discrepancy(&self) -> bool

Check if the holding has any discrepancy

Source

pub fn change_from_close(&self) -> f64

Get the change from previous day close

Source

pub fn change_percentage_from_close(&self) -> f64

Get the change percentage from previous day close

Source

pub fn is_pledged(&self) -> bool

Check if the holding is pledged

Source

pub fn unpledged_quantity(&self) -> i32

Get unpledged quantity

Trait Implementations§

Source§

impl Clone for Holding

Source§

fn clone(&self) -> Holding

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Holding

Source§

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

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

impl<'de> Deserialize<'de> for Holding

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Holding

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,