def onRspQryTradingAccount(self, data: dict, error: dict, reqid: int, last: bool): """""" account = AccountData(accountid=data["AccountID"], balance=data["Balance"], frozen=data["FrozenMargin"] + data["FrozenCash"] + data["FrozenCommission"], gateway_name=self.gateway_name) account.available = data["Available"] self.on_event(type=EVENT_ACCOUNT, data=account)
def to_object(self) -> AccountData: return AccountData._create_class( dict( accountid=self.account_id, local_account_id=f"{self.account_id}.SIM", frozen=self.frozen, balance=self.balance, ))
def on_account(self, account: AccountData) -> None: data_list = [] for k, v in account._to_dict().items(): temp = {} temp['key'] = k temp['value'] = v data_list.append(temp) data = {"type": "account", "data": data_list} self.io.emit('account', data)
def query_account(self): data = AccountData(account_id=self.api.account, balance=self.api.balance, frozen=self.api.balance - self.api.assets) event = Event(EVENT_ACCOUNT, data=data) self.event_engine.put(data)
def on_account(self, account: AccountData) -> None: data = {"type": "account", "data": account._to_dict()} self.io.emit('account', data)