1use crate::constant::{Direction, Exchange};
4
5#[derive(Debug, Clone, PartialEq, Default)]
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8pub struct PositionData {
9 pub gateway_name: String,
11 pub symbol: String,
13 pub exchange: Exchange,
15 pub direction: Direction,
17
18 pub volume: f64,
20 pub frozen: f64,
22 pub price: f64,
24 pub pnl: f64,
26 pub yd_volume: f64,
28
29 pub name: String,
32 pub can_use_volume: f64,
34 pub market_value: f64,
36 pub on_road_volume: f64,
38 pub avg_price: f64,
40 pub last_price: f64,
42 pub profit_rate: f64,
44}
45
46impl PositionData {
47 pub fn en_symbol(&self) -> String {
49 crate::symbol::vt_symbol(&self.symbol, self.exchange)
50 }
51
52 pub fn en_positionid(&self) -> String {
58 format!(
59 "{}.{}.{}",
60 self.gateway_name,
61 self.en_symbol(),
62 self.direction.as_str()
63 )
64 }
65}