| | |
| | | |
| | | class TradeActionCallback(object): |
| | | # 交易 |
| | | def OnTrade(self, client_id, request_id, type_, data): |
| | | def OnTrade(self, client_id, request_id, sk, type_, data): |
| | | pass |
| | | |
| | | # 委托列表 |
| | | def OnDelegateList(self, client_id, request_id): |
| | | def OnDelegateList(self, client_id, request_id, sk, can_cancel): |
| | | pass |
| | | |
| | | # 成交列表 |
| | | def OnDealList(self, client_id, request_id): |
| | | def OnDealList(self, client_id, request_id, sk): |
| | | pass |
| | | |
| | | # 成交列表 |
| | | def OnPositionList(self, client_id, request_id): |
| | | def OnPositionList(self, client_id, request_id, sk): |
| | | pass |
| | | |
| | | # 获取资金信息 |
| | | def OnMoney(self, client_id, request_id): |
| | | def OnMoney(self, client_id, request_id, sk): |
| | | pass |
| | | |
| | | # 测试 |
| | | def OnTest(self, client_id, request_id, data): |
| | | def OnTest(self, client_id, request_id, data, sk): |
| | | pass |
| | | |
| | | |
| | |
| | | cls.pipe_l2 = pipe_l2 |
| | | |
| | | @classmethod |
| | | def process_command(cls, _type, client_id, result_json): |
| | | def process_command(cls, _type, client_id, result_json, sk=None): |
| | | try: |
| | | data = result_json["data"] |
| | | print("接收内容", result_json) |
| | |
| | | if _type == CLIENT_TYPE_TRADE: |
| | | # 交易 |
| | | ctype = data["trade_type"] |
| | | cls.action_callback.OnTrade(client_id, request_id, ctype, data) |
| | | cls.action_callback.OnTrade(client_id, request_id, sk, ctype, data) |
| | | elif _type == CLIENT_TYPE_MONEY: |
| | | cls.action_callback.OnMoney(client_id, request_id) |
| | | cls.action_callback.OnMoney(client_id, request_id, sk) |
| | | elif _type == CLIENT_TYPE_DEAL_LIST: |
| | | cls.action_callback.OnDealList(client_id, request_id) |
| | | cls.action_callback.OnDealList(client_id, request_id, sk) |
| | | elif _type == CLIENT_TYPE_DELEGATE_LIST: |
| | | can_cancel = data["can_cancel"] |
| | | cls.action_callback.OnDelegateList(client_id, request_id, can_cancel) |
| | | cls.action_callback.OnDelegateList(client_id, request_id, sk, can_cancel) |
| | | elif _type == CLIENT_TYPE_POSITION_LIST: |
| | | cls.action_callback.OnPositionList(client_id, request_id) |
| | | cls.action_callback.OnPositionList(client_id, request_id, sk) |
| | | elif _type == "test": |
| | | cls.action_callback.OnTest(client_id, request_id, data) |
| | | cls.action_callback.OnTest(client_id, request_id, data, sk) |
| | | except Exception as e: |
| | | logger_local_huaxin_trade_debug.debug(f"process_command出错:{result_json}") |
| | | logging.exception(e) |