pub struct Position {Show 30 fields
pub account_id: String,
pub trading_symbol: String,
pub exchange: Exchange,
pub instrument_token: u32,
pub product: Product,
pub quantity: i32,
pub overnight_quantity: i32,
pub multiplier: f64,
pub average_price: f64,
pub close_price: f64,
pub last_price: f64,
pub value: f64,
pub pnl: f64,
pub m2m: f64,
pub unrealised: f64,
pub realised: f64,
pub buy_quantity: u32,
pub buy_price: f64,
pub buy_value: f64,
pub buy_m2m: f64,
pub sell_quantity: u32,
pub sell_price: f64,
pub sell_value: f64,
pub sell_m2m: f64,
pub day_buy_quantity: u32,
pub day_buy_price: f64,
pub day_buy_value: f64,
pub day_sell_quantity: u32,
pub day_sell_price: f64,
pub day_sell_value: f64,
}Expand description
Position data structure
Fields§
§account_id: StringAccount ID
trading_symbol: StringTrading symbol
exchange: ExchangeExchange
instrument_token: u32Instrument token
product: ProductProduct type
quantity: i32Net quantity (positive for long, negative for short)
overnight_quantity: i32Overnight quantity
multiplier: f64Multiplier for the instrument
average_price: f64Average price at which the position was taken
close_price: f64Close price
last_price: f64Last price from exchange
value: f64Current value of the position
pnl: f64P&L (profit and loss)
m2m: f64M2M (Mark to Market) P&L
unrealised: f64Unrealised P&L
realised: f64Realised P&L
buy_quantity: u32Buy quantity
buy_price: f64Buy price
buy_value: f64Buy value
buy_m2m: f64Buy M2M
sell_quantity: u32Sell quantity
sell_price: f64Sell price
sell_value: f64Sell value
sell_m2m: f64Sell M2M
day_buy_quantity: u32Day buy quantity
day_buy_price: f64Day buy price
day_buy_value: f64Day buy value
day_sell_quantity: u32Day sell quantity
day_sell_price: f64Day sell price
day_sell_value: f64Day sell value
Implementations§
Source§impl Position
impl Position
Sourcepub fn is_profitable(&self) -> bool
pub fn is_profitable(&self) -> bool
Check if the position is profitable
Sourcepub fn abs_quantity(&self) -> u32
pub fn abs_quantity(&self) -> u32
Get the absolute quantity
Sourcepub fn pnl_percentage(&self) -> f64
pub fn pnl_percentage(&self) -> f64
Calculate the P&L percentage
Sourcepub fn market_value(&self) -> f64
pub fn market_value(&self) -> f64
Get the current market value of the position
Sourcepub fn is_day_position(&self) -> bool
pub fn is_day_position(&self) -> bool
Check if this is a day position (intraday)
Sourcepub fn is_overnight_position(&self) -> bool
pub fn is_overnight_position(&self) -> bool
Check if this is an overnight position
Sourcepub fn change_from_close(&self) -> f64
pub fn change_from_close(&self) -> f64
Calculate the change from close price
Sourcepub fn change_percentage_from_close(&self) -> f64
pub fn change_percentage_from_close(&self) -> f64
Calculate the change percentage from close price
Sourcepub fn net_day_quantity(&self) -> i32
pub fn net_day_quantity(&self) -> i32
Get net day quantity
Sourcepub fn has_day_activity(&self) -> bool
pub fn has_day_activity(&self) -> bool
Check if there was day trading activity