| | |
| | | huaxin_trade_api.ClientSocketManager.CLIENT_TYPE_POSITION_LIST] |
| | | fdata = {} |
| | | for t in types: |
| | | trade_list = huaxin_trade_api.ClientSocketManager.list_client(t) |
| | | fdata[t] = len(trade_list) |
| | | client_list = huaxin_trade_api.ClientSocketManager.list_client(t) |
| | | client_state_list = [] |
| | | for t in client_list: |
| | | # 判断是否已经上锁 |
| | | lock_state = huaxin_trade_api.ClientSocketManager.is_client_locked(t[0]) |
| | | lock_state_desc = "" |
| | | if lock_state is None: |
| | | lock_state_desc = "未知" |
| | | elif lock_state: |
| | | lock_state_desc = "已锁" |
| | | else: |
| | | lock_state_desc = "未锁" |
| | | client_state_list.append((t[0],lock_state_desc)) |
| | | fdata[t] = client_state_list |
| | | return_str = json.dumps( |
| | | {"code": 0, "data": fdata, "msg": ""}) |
| | | elif type_ == 'juejin_is_valid': |
| | |
| | | if data: |
| | | type_ = data["type"] |
| | | hx_logger_trade_debug.info(f"获取交易数据开始:{type_}") |
| | | |
| | | try: |
| | | if type_ == "delegate_list": |
| | | dataJSON = huaxin_trade_api.get_delegate_list(can_cancel=False, timeout=5) |
| | | print("获取委托列表", dataJSON) |
| | |
| | | datas = dataJSON["data"] |
| | | huaxin_trade_record_manager.DealRecordManager.add(datas) |
| | | if datas: |
| | | tempList = [{"time": d["tradeTime"], "type": int(d['direction']), "code": d['securityID']} |
| | | tempList = [ |
| | | {"time": d["tradeTime"], "type": int(d['direction']), "code": d['securityID']} |
| | | for d in datas] |
| | | try: |
| | | trade_manager.process_trade_success_data(tempList) |
| | |
| | | huaxin_trade_record_manager.PositionManager.add(data) |
| | | |
| | | hx_logger_trade_debug.info(f"获取交易数据成功:{type_}") |
| | | except Exception as e1: |
| | | if str(e1).find("超时") >= 0: |
| | | # 读取结果超时需要重新请求 |
| | | trade_data_request_queue.put_nowait({"type": type_}) |
| | | raise e1 |
| | | except Exception as e: |
| | | hx_logger_trade_debug.exception(e) |
| | | finally: |