pub struct AccountRow {Show 14 fields
pub gateway: String,
pub alias: String,
pub broker_id: String,
pub account: String,
pub md_source: bool,
pub form: CtpForm,
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:不持久化)。
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
impl AccountRow
Sourcepub fn derive(form: &CtpForm) -> Result<Self, String>
pub fn derive(form: &CtpForm) -> Result<Self, String>
由表单派生账户行(派生名唯一入口 = ek_ctp::derived_gateway_name)。
返回 Err(原因) = broker/账号非法或派生名超宿主 32 字符上限;
界面须红字呈现,不得静默替换(规划 §3)。
Sourcepub fn status_label(&self) -> String
pub fn status_label(&self) -> String
状态列文案(装配态 + 登录态拼一起)。
「已装配」后面必须跟着登录态,不能光写「已装配」——0.2.18 那条「不得读成在线」
的口径(规划 U5)现在有了真读数才真正立住:没有证据时写「已装配·登录态未知」。
装配段一律走 AccountStage::label(),不在这里重抄一遍文案(两处不同式就是坑)。
Sourcepub fn apply_status(
&mut self,
st: &GatewayStatus,
now_ms: i64,
reject_limit: u32,
stale_secs: i64,
)
pub fn apply_status( &mut self, st: &GatewayStatus, now_ms: i64, reject_limit: u32, stale_secs: i64, )
把 {gw}.status 读数折成界面登录态 + 细节(0.2.19;规划 P3 / Q10)。
判据顺序写明(每条都有理由):
- 登录失败先判 —— 网关在登录成功后会清零
td_login_failed,所以它显形就是现在登不上; - 登录着 → 才谈「查询断供」,三条判据:连续被拒达阈 / 距最后一次资金回报超时 / 登录后资金回报从未到手且已超过同一个 stale 阈值(0.2.21,实连 S15f 逼出来的第三条); 都没中 = 在线;
- 没登录 → 用户主动『断开』优先(那是自己按的钮,比柜台掉线计数更贴近用户意图),
其次才是柜台掉线(
disconnects > 0),最后才是「未知」; - 纯行情账户(td 前置留档为空)看 MD 半边 —— 看 TD 半边永远是「未知」,那是假信息。
「从未发生」= None 不当 0 用:网关没回报过资金时刻 ≠ 「0 秒前刚回报过」。
Sourcepub fn display_name(&self) -> String
pub fn display_name(&self) -> String
显示名:别名优先,空则回退账号(寻址仍只用 gateway,规划 Q3)。
Trait Implementations§
Source§impl Clone for AccountRow
impl Clone for AccountRow
Source§impl Debug for AccountRow
impl Debug for AccountRow
Source§impl Default for AccountRow
impl Default for AccountRow
Source§impl PartialEq for AccountRow
impl PartialEq for AccountRow
impl StructuralPartialEq for AccountRow
Auto Trait Implementations§
impl Freeze for AccountRow
impl RefUnwindSafe for AccountRow
impl Send for AccountRow
impl Sync for AccountRow
impl Unpin for AccountRow
impl UnsafeUnpin for AccountRow
impl UnwindSafe for AccountRow
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.