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: StringAccount ID
trading_symbol: StringTrading symbol
exchange: ExchangeExchange
isin: StringISIN (International Securities Identification Number)
product: ProductProduct type
instrument_token: u32Instrument token
quantity: i32Quantity in the holding
t1_quantity: i32T1 quantity (can be sold after T+1 day)
realised_quantity: i32Realised quantity (can be sold immediately)
Authorized quantity (pledged/unpledged)
Authorised date
opening_quantity: i32Opening quantity at the start of the day
collateral_quantity: i32Collateral quantity
collateral_type: Option<String>Collateral type
collateral_update_quantity: i32Collateral update quantity
discrepancy: boolDiscrepancy flag
average_price: f64Average price at which the stock was bought
last_price: f64Last price from exchange
close_price: f64Close price
price_change: f64Price change
pnl: f64P&L (profit and loss)
day_change: f64Day change
day_change_percentage: f64Day change percentage
used_quantity: i32Used quantity (used for pledging)
Implementations§
Source§impl Holding
impl Holding
Sourcepub fn market_value(&self) -> f64
pub fn market_value(&self) -> f64
Calculate current market value of the holding
Sourcepub fn investment_value(&self) -> f64
pub fn investment_value(&self) -> f64
Calculate investment value (at average price)
Sourcepub fn pnl_percentage(&self) -> f64
pub fn pnl_percentage(&self) -> f64
Calculate the P&L percentage
Sourcepub fn is_profitable(&self) -> bool
pub fn is_profitable(&self) -> bool
Check if the holding is profitable
Sourcepub fn available_quantity(&self) -> i32
pub fn available_quantity(&self) -> i32
Get available quantity for trading
Sourcepub fn can_sell_today(&self) -> bool
pub fn can_sell_today(&self) -> bool
Check if quantity can be sold today
Sourcepub fn sellable_today(&self) -> i32
pub fn sellable_today(&self) -> i32
Get quantity that can be sold today
Sourcepub fn sellable_tomorrow(&self) -> i32
pub fn sellable_tomorrow(&self) -> i32
Get quantity that can be sold tomorrow (T+1)
Sourcepub fn has_discrepancy(&self) -> bool
pub fn has_discrepancy(&self) -> bool
Check if the holding has any discrepancy
Sourcepub fn change_from_close(&self) -> f64
pub fn change_from_close(&self) -> f64
Get the change from previous day close
Sourcepub fn change_percentage_from_close(&self) -> f64
pub fn change_percentage_from_close(&self) -> f64
Get the change percentage from previous day close
Sourcepub fn is_pledged(&self) -> bool
pub fn is_pledged(&self) -> bool
Check if the holding is pledged
Sourcepub fn unpledged_quantity(&self) -> i32
pub fn unpledged_quantity(&self) -> i32
Get unpledged quantity