예제 #1
0
파일: td_api.py 프로젝트: dengwen168/ctpbee
    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)
예제 #2
0
 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,
         ))
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
 def on_account(self, account: AccountData) -> None:
     data = {"type": "account", "data": account._to_dict()}
     self.io.emit('account', data)