Skip to main content

AccountRow

Struct AccountRow 

Source
pub struct AccountRow {
Show 17 fields pub gateway: String, pub alias: String, pub broker_id: String, pub account: String, pub md_source: bool, pub form: CtpForm, pub restored: bool, pub auto_connect: bool, pub password_ref: bool, pub stage: AccountStage, pub fail_note: Option<String>, pub effective_classes: Vec<String>, pub connected: bool, pub login: LoginState, pub status_note: Option<String>, pub login_brief: Option<String>, pub chain_note: Option<String>,
}
Expand description

账户行(多账号面;规划 §5.B + 0.2.18 四态)。

界面是账户清单的唯一事实源(不新增“账户注册表“插件): 网关实例的在场由 svctl.list 回填,身份与凭据留在这一行,每账户一份 form (旧「全界面共享一张表单」已退役 → 消 U4 凭据串味 / U6 取消编辑不清空)。

Fields§

§gateway: String

派生注册名(ctp_<broker>_<账号>;寻址唯一用这个,别名不参与)。

§alias: String

用户别名(显示用,可空 = 回退账号;唯一性由 add_account 校验,规划 Q3)。

§broker_id: String§account: String§md_source: bool

是否行情元账号(全局单源——用户裁定“单数据源“;已装配后锁定,规划 D3)。

§form: CtpForm

该账户自己的表单留档(编辑弹窗回填用;密码只存内存,裁定 2:不持久化)。

§restored: bool

档案复原标(0.9.0):这一行来自启动清点(%APPDATA%\ek\cfg 的存档段), 不是本次会话手输的。呈现面:行上「档案」徽标 + 编辑弹窗密码位显示 「密库引用,不回显」;行为面:「连接」= UiCmd::Start(存档直连), 不走表单 configure —— 存档的密码在密库,不在表单里,发空表单只会把 空密码受理下去(这就是复原行必须走 svctl.start 的唯一理由)。

§auto_connect: bool

自动连接勾选(0.9.0):手点才置位 + 落盘标记;只存 ui 段 (账户行为面归界面档案,不进网关段 —— 2026-10-28 用户裁定「编排归 station/界面层,网关只当哑网关」的落点)。消费方:守护复原(ek-station boot 清点 = 开则起连)与桌面启动清点(不复原 spawn,行列出后手点「连接」)。

§password_ref: bool

密码密库引用在位(0.9.0;只读元信息,来自存档段的 Field::secret 引用行)。呈现面:复原行密码位显示「密库引用 ✓」;它不是密码本身, 也不参与任何连接判据(实例 on_start 才解密,ek-ctp BD-CFG-16)。 手输行恒为 false(受理受理面另有实况档位口 credentials_state)。

§stage: AccountStage

装配四态(规划 §3.3)。

§fail_note: Option<String>

装配失败原因(AssembleFailed 时留显形;成功即清空)。

§effective_classes: Vec<String>

网关实际收录回带值(ConfigureReply.product_classes,规划 U9)。

与 form.accept_*(用户勾选)并排显示:勾选是意图,这一栏是事实。 空 = 尚未装配过或旧版网关未回带。

§connected: bool

在场位(由 svctl.list 快照回填:该注册名在不在 = 实例已装配)。 0.2.19 起登录成败另有事实源({gw}.status → login),这一位只管实例。

§login: LoginState

登录态(0.2.19):{gw}.status 读数折出来的,与 stage/connected 正交。

默认 Unknown:装配成功本身不构成任何登录证据(ek-ctp D-STATUS ①)。

§status_note: Option<String>

状态细节(「掉线 2 次」「查询连续被拒 3 次」「资金回报已 45s 未更新」)。 None = 没有可说的细节(不是「一切正常」——一切正常由 login 说)。

§login_brief: Option<String>

柜台原因的短标签(0.4.1 十期 BD-UI-63):登录失败/掉线时从 td_last_error 里 抠出「代码:N」与「信息:」的正文,给账户行的状态列用(红字后面直接跟着原因)。

为什么不直接把整句塞进状态列:柜台原句是「交易服务器登录失败,代码:3,信息:CTP:不 合法的登录」这种长句,Grid 状态列被它挤宽就会把别的列顶窄(s39 那口径)。整句留在 status_note 里,窗下方「状态细节」那一行照旧给全。

§chain_note: Option<String>

链状态(0.5.0,用户定「链进行的状态改为事件日志推送」):该网关最近一条 [链] 状态行的正文(去掉前缀)。

事实源是 ek-ctp 0.9.8 推送的日志(前置已连接 / 授权通过 / 登录成功 / 结算单已确认 / 查询合约 第N次 / 合约已到手开始轮询 / 合约未到手本轮已停止 / 会话已复位),不是轮询读数。 None = 这一条会话还没推过状态行(显示「—」)。它只是显示:不参与 apply_status 那套在线/断供判据,也不参与任何下单判据。

Implementations§

Source§

impl AccountRow

Source

pub fn derive(form: &CtpForm) -> Result<Self, String>

派生入口(兼容 1 参 = 在场清单空;多前置判定见 derive_with)。

Source

pub fn derive_with( form: &CtpForm, taken: &[(String, String, String, String)], ) -> Result<Self, String>

由表单派生账户行(派生名唯一入口 = appconfig::unique_gw_name,0.9.10)。

taken = 在场清单 (gw, broker, 账号, td 前置):

  • 三处全同 = Err(同前置不重复登记);
  • 同 broker+账号 而 td 前置不同 = 自动后缀 _2/_3…(用户裁定「一账号多套 前置,别名备注切换」,IP 相同端口不同也算两套)。

返回 Err(原因) = broker/账号非法、派生名超 32 字符或重复; 界面须红字呈现,不得静默替换(规划 §3)。

Source

pub fn status_label(&self) -> String

状态列文案(装配态 + 登录态拼一起)。

「已装配」后面必须跟着登录态,不能光写「已装配」——0.2.18 那条「不得读成在线」 的口径(规划 U5)现在有了真读数才真正立住:没有证据时写「已装配·登录态未知」。 装配段一律走 AccountStage::label(),不在这里重抄一遍文案(两处不同式就是坑)。

Source

pub fn apply_status( &mut self, st: &GatewayStatus, now_ms: i64, reject_limit: u32, stale_secs: i64, )

把 {gw}.status 读数折成界面登录态 + 细节(0.2.19;规划 P3 / Q10)。

判据顺序写明(每条都有理由):

  1. 登录失败先判 —— 网关在登录成功后会清零 td_login_failed,所以它显形就是现在登不上;
  2. 登录着 → 才谈「查询断供」,三条判据:连续被拒达阈 / 距最后一次资金回报超时 / 登录后资金回报从未到手且已超过同一个 stale 阈值(0.2.21,实连 S15f 逼出来的第三条); 都没中 = 在线;
  3. 没登录 → 用户主动『断开』优先(那是自己按的钮,比柜台掉线计数更贴近用户意图), 其次才是柜台掉线(disconnects > 0),最后才是「未知」;
  4. 纯行情账户(td 前置留档为空)看 MD 半边 —— 看 TD 半边永远是「未知」,那是假信息。

「从未发生」= None 不当 0 用:网关没回报过资金时刻 ≠ 「0 秒前刚回报过」。

Source

pub fn display_name(&self) -> String

显示名:别名优先,空则回退账号(寻址仍只用 gateway,规划 Q3)。

Trait Implementations§

Source§

impl Clone for AccountRow

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for AccountRow

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for AccountRow

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for AccountRow

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AccountRow

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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