其他分享
首页 > 其他分享> > 量化交易之vnpy篇 - tqz_object - @dataclass的简单使用

量化交易之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)

标签:__,vnpy,float,risk,self,object,deposit,dataclass,balance
来源: https://blog.csdn.net/Michael_234198652/article/details/119038160