量化交易之vnpy篇 - tqz_object - @dataclass的简单使用



from dataclasses import dataclass

from vnpy.trader.object import AccountData



@dataclass
class TQZAccountData(AccountData):
    """
    Add user_deposit、risk_float based on AccountData
    """

    def __post_init__(self):
        """ callback after __init__ """

        self.vt_accountid = f"{self.gateway_name}.{self.accountid}"
        self.available = self.balance - self.frozen
        self.use_deposit = self.balance - self.available

        if self.balance is 0:
            self.risk_float = round(0, 4)
        else:
            self.risk_float = round(self.use_deposit / self.balance, 4)

上一篇:《LabVIEW 虚拟仪器程序设计从入门到精通(第二版)》一2.4 前面板对象的操作


下一篇:JavaScript字符集编码与解码