ek_data/account.rs
1//! 账户对象(`object.py:268-282`)。
2
3/// 账户资金数据:余额、冻结、可用。
4#[derive(Debug, Clone, PartialEq, Default)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub struct AccountData {
7 /// 上游网关名
8 pub gateway_name: String,
9 /// 账户号
10 pub accountid: String,
11
12 /// 总余额
13 pub balance: f64,
14 /// 冻结额
15 pub frozen: f64,
16}
17
18impl AccountData {
19 /// `en_accountid` = `"{gateway_name}.{accountid}"`(`object.py:282`)。
20 pub fn en_accountid(&self) -> String {
21 format!("{}.{}", self.gateway_name, self.accountid)
22 }
23
24 /// 可用资金 = `balance - frozen`(Python `__post_init__` 暂存字段方法化)。
25 pub fn available(&self) -> f64 {
26 self.balance - self.frozen
27 }
28}