pub struct Position {Show 25 fields
pub position_id: u64,
pub position_side: i32,
pub code: String,
pub name: String,
pub qty: f64,
pub can_sell_qty: f64,
pub price: f64,
pub cost_price: Option<f64>,
pub val: f64,
pub pl_val: f64,
pub pl_ratio: Option<f64>,
pub sec_market: Option<i32>,
pub td_pl_val: Option<f64>,
pub td_trd_val: Option<f64>,
pub td_buy_val: Option<f64>,
pub td_buy_qty: Option<f64>,
pub td_sell_val: Option<f64>,
pub td_sell_qty: Option<f64>,
pub unrealized_pl: Option<f64>,
pub realized_pl: Option<f64>,
pub currency: Option<i32>,
pub trd_market: Option<i32>,
pub diluted_cost_price: Option<f64>,
pub average_cost_price: Option<f64>,
pub average_pl_ratio: Option<f64>,
}Expand description
账户持仓结构
Fields§
§position_id: u64持仓ID,一条持仓的唯一标识
position_side: i32持仓方向,参见PositionSide的枚举定义
code: String代码
name: String名称
qty: f64持有数量,2位精度,期权单位是“张“,下同
can_sell_qty: f64可卖数量
price: f64市价,3位精度,期货为2位精度
cost_price: Option<f64>成本价,无精度限制,期货为2位精度,如果没传,代表此时此值无效(已废弃,请使用 dilutedCostPrice 或 averageCostPrice)
val: f64市值,3位精度, 期货此字段值为0
pl_val: f64盈亏金额,3位精度,期货为2位精度
pl_ratio: Option<f64>摊薄成本价的盈亏百分比(如plRatio等于8.8代表涨8.8%),无精度限制,如果没传,代表此时此值无效
sec_market: Option<i32>证券所属市场,参见TrdSecMarket的枚举定义
td_pl_val: Option<f64>以下是此持仓今日统计
今日盈亏金额,3位精度,下同, 期货为2位精度
td_trd_val: Option<f64>今日交易额,期货不适用
td_buy_val: Option<f64>今日买入总额,期货不适用
td_buy_qty: Option<f64>今日买入总量,期货不适用
td_sell_val: Option<f64>今日卖出总额,期货不适用
td_sell_qty: Option<f64>今日卖出总量,期货不适用
unrealized_pl: Option<f64>未实现盈亏,期货适用
realized_pl: Option<f64>已实现盈亏,期货适用
currency: Option<i32>货币类型,取值参考 Currency
trd_market: Option<i32>交易市场, 参见TrdMarket的枚举定义
diluted_cost_price: Option<f64>摊薄成本价,仅支持证券账户使用
average_cost_price: Option<f64>平均成本价,模拟交易证券账户不适用
average_pl_ratio: Option<f64>平均成本价的盈亏百分比(如plRatio等于8.8代表涨8.8%),无精度限制,如果没传,代表此时此值无效
Implementations§
Source§impl Position
impl Position
Sourcepub fn cost_price(&self) -> f64
pub fn cost_price(&self) -> f64
Returns the value of cost_price, or the default value if cost_price is unset.
Sourcepub fn pl_ratio(&self) -> f64
pub fn pl_ratio(&self) -> f64
Returns the value of pl_ratio, or the default value if pl_ratio is unset.
Sourcepub fn sec_market(&self) -> i32
pub fn sec_market(&self) -> i32
Returns the value of sec_market, or the default value if sec_market is unset.
Sourcepub fn td_pl_val(&self) -> f64
pub fn td_pl_val(&self) -> f64
Returns the value of td_pl_val, or the default value if td_pl_val is unset.
Sourcepub fn td_trd_val(&self) -> f64
pub fn td_trd_val(&self) -> f64
Returns the value of td_trd_val, or the default value if td_trd_val is unset.
Sourcepub fn td_buy_val(&self) -> f64
pub fn td_buy_val(&self) -> f64
Returns the value of td_buy_val, or the default value if td_buy_val is unset.
Sourcepub fn td_buy_qty(&self) -> f64
pub fn td_buy_qty(&self) -> f64
Returns the value of td_buy_qty, or the default value if td_buy_qty is unset.
Sourcepub fn td_sell_val(&self) -> f64
pub fn td_sell_val(&self) -> f64
Returns the value of td_sell_val, or the default value if td_sell_val is unset.
Sourcepub fn td_sell_qty(&self) -> f64
pub fn td_sell_qty(&self) -> f64
Returns the value of td_sell_qty, or the default value if td_sell_qty is unset.
Sourcepub fn unrealized_pl(&self) -> f64
pub fn unrealized_pl(&self) -> f64
Returns the value of unrealized_pl, or the default value if unrealized_pl is unset.
Sourcepub fn realized_pl(&self) -> f64
pub fn realized_pl(&self) -> f64
Returns the value of realized_pl, or the default value if realized_pl is unset.
Sourcepub fn currency(&self) -> i32
pub fn currency(&self) -> i32
Returns the value of currency, or the default value if currency is unset.
Sourcepub fn trd_market(&self) -> i32
pub fn trd_market(&self) -> i32
Returns the value of trd_market, or the default value if trd_market is unset.
Sourcepub fn diluted_cost_price(&self) -> f64
pub fn diluted_cost_price(&self) -> f64
Returns the value of diluted_cost_price, or the default value if diluted_cost_price is unset.
Sourcepub fn average_cost_price(&self) -> f64
pub fn average_cost_price(&self) -> f64
Returns the value of average_cost_price, or the default value if average_cost_price is unset.
Sourcepub fn average_pl_ratio(&self) -> f64
pub fn average_pl_ratio(&self) -> f64
Returns the value of average_pl_ratio, or the default value if average_pl_ratio is unset.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Position
impl<'de> Deserialize<'de> for Position
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Message for Position
impl Message for Position
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self.