//! 账户对象(`object.py:268-282`)。
/// 账户资金数据:余额、冻结、可用。
#[derive(Debug, Clone, PartialEq, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AccountData {
/// 上游网关名
pub gateway_name: String,
/// 账户号
pub accountid: String,
/// 总余额
pub balance: f64,
/// 冻结额
pub frozen: f64,
}
impl AccountData {
/// `en_accountid` = `"{gateway_name}.{accountid}"`(`object.py:282`)。
pub fn en_accountid(&self) -> String {
format!("{}.{}", self.gateway_name, self.accountid)
}
/// 可用资金 = `balance - frozen`(Python `__post_init__` 暂存字段方法化)。
pub fn available(&self) -> f64 {
self.balance - self.frozen
}
}