Skip to main content

Position

Struct Position 

Source
pub struct Position {
Show 16 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: f64, pub val: f64, pub pl_val: f64, pub pl_ratio: f64, pub diluted_cost_price: Option<f64>, pub average_cost_price: Option<f64>, pub average_pl_ratio: Option<f64>, pub currency: Option<i32>, pub trd_market: Option<i32>,
}
Expand description

持仓信息

v1.4.94 Tier M2 (mobile-driven extension): 加 diluted_cost_price / average_cost_price / average_pl_ratio / currency / trd_market 字段, 对齐 OpenD Trd_Common.proto Position 字段 32-34 + 30-31 + mobile NN aas_cmn.proto CostProfitCalcMethod 用 case (JP 加权平均 / 美 开仓价).

cost_price (字段 8) 已 deprecated (proto 注释: “已废弃,请使用 dilutedCostPrice 或 averageCostPrice”), 但保留向后兼容. 客户端推荐用新字段:

  • diluted_cost_price: 摊薄成本价 (HK/US/CN 默认显示)
  • average_cost_price: 平均成本价 (JP 信用 / 模拟交易证券默认)
  • average_pl_ratio: 基于 average_cost_price 的盈亏百分数值

Fields§

§position_id: u64

服务端分配的持仓 ID

§position_side: i32

持仓方向(0=多 / 1=空,对齐 proto PositionSide

§code: String

证券代码(市场内 code,不含 MKT. 前缀)

§name: String

证券名称(中文或本地化)

§qty: f64

持仓数量

§can_sell_qty: f64

可卖数量(已扣除冻结 / 当日买入不可卖等)

§price: f64

当前价

§cost_price: f64

持仓均价(已废弃,用 diluted_cost_price 或 average_cost_price)

§val: f64

持仓市值(qty * price

§pl_val: f64

盈亏金额

§pl_ratio: f64

C++ APIServer 原样返回的持仓盈亏比例数值(基于 cost_price 旧字段)。 Rust gateway/API/JSON 保持该数值不变;CLI 展示层再格式化为带符号的 百分比字符串,例如 0.6078 显示为 +60.78%

§diluted_cost_price: Option<f64>

v1.4.94 Tier M2: 摊薄成本价 (proto 字段 32, 仅证券账户) 对齐 C++ Trd_Common.proto:411 “仅支持证券账户使用”.

§average_cost_price: Option<f64>

v1.4.94 Tier M2: 平均成本价 (proto 字段 33, 模拟交易证券账户不适用)

§average_pl_ratio: Option<f64>

v1.4.94 Tier M2: 平均成本价的盈亏百分数值 (proto 字段 34)

§currency: Option<i32>

v1.4.94 Tier M2: 货币类型 (proto 字段 30, 取值 Currency enum)

§trd_market: Option<i32>

v1.4.94 Tier M2: 交易市场 (proto 字段 31, 取值 TrdMarket enum)

Implementations§

Source§

impl Position

Source

pub fn from_proto(p: &Position) -> Self

Trait Implementations§

Source§

impl Clone for Position

Source§

fn clone(&self) -> Position

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Position

Source§

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

Formats the value using the given formatter. 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.

§

impl<T> Instrument for T

§

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

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

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> 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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