Administrator
2023-08-15 cc6fcdf8e3792d17ccf436fb2f03fcda57b0f06a
trade/huaxin/trade_api_server.py
@@ -420,58 +420,30 @@
        super().finish()
test_data = [('600829', 60024, 8.33), ('603610', 40000, 12.5), ('002945', 28474, 17.56), ('600689', 47438, 10.54),
             ('002907', 26288, 19.02), ('002999', 60680, 8.24), ('601136', 18939, 26.4), ('603190', 16062, 31.13),
             ('001231', 21844, 22.89), ('605138', 50454, 9.91), ('603963', 37850, 13.21), ('603029', 21608, 23.14),
             ('001222', 29833, 16.76), ('002898', 34868, 14.34), ('603106', 58754, 8.51), ('600361', 80775, 6.19),
             ('600280', 92251, 5.42), ('002370', 100402, 4.98), ('002640', 124378, 4.02), ('002758', 37821, 13.22),
             ('000953', 82237, 6.08), ('002747', 20602, 24.27), ('002146', 191571, 2.61), ('601696', 39620, 12.62),
             ('000411', 31566, 15.84), ('603220', 26810, 18.65), ('000739', 26137, 19.13), ('600575', 174825, 2.86),
             ('600257', 72464, 6.9), ('003042', 22686, 22.04), ('601059', 24522, 20.39), ('603667', 33400, 14.97)]
def __set_target_codes(pipe_l2):
    while True:
        try:
            datas = test_data
            _datas = huaxin_target_codes_manager.HuaXinL2SubscriptCodesManager.pop()
            if _datas:
                timestamp = _datas[0]
                datas = _datas[1]
                print("时间戳:", timestamp)
                print("内容:", datas)
                # 只处理20s内的数据
                if time.time() - timestamp < 20 and datas:
                    codes = [d[0] for d in datas]
                    for code in codes:
                        block_info.init_code(code)
            root_data = {"data": {"type": ClientSocketManager.CLIENT_TYPE_CMD_L2,
                                  "data": datas},
                         "request_id": f"{ClientSocketManager.CLIENT_TYPE_CMD_L2}_{round(time.time() * 1000)}"}
            root_data = socket_util.encryp_client_params_sign(root_data)
            pipe_l2.send(json.dumps(root_data))
            print("向L2发送数据")
                    print("设置L2代码结束")
        except Exception as e:
            logging.exception(e)
        finally:
            time.sleep(2)
#
# def __set_target_codes(pipe_l2):
#     while True:
#         try:
#             _datas = huaxin_target_codes_manager.HuaXinL2SubscriptCodesManager.pop()
#             if _datas:
#                 timestamp = _datas[0]
#                 datas = _datas[1]
#                 print("时间戳:", timestamp)
#                 print("内容:", datas)
#                 # 只处理20s内的数据
#                 if time.time() - timestamp < 20 and datas:
#                     codes = [d[0] for d in datas]
#                     for code in codes:
#                         block_info.init_code(code)
#                     root_data = {"type": ClientSocketManager.CLIENT_TYPE_CMD_L2,
#                                  "data": datas,
#                                  "request_id": f"{ClientSocketManager.CLIENT_TYPE_CMD_L2}_{round(time.time() * 1000)}"}
#                     root_data = socket_util.encryp_client_params_sign(root_data)
#                     pipe_l2.send(json.dumps(root_data))
#                     print("设置L2代码结束")
#         except Exception as e:
#             logging.exception(e)
#         finally:
#             time.sleep(1)
            time.sleep(1)
def __read_sync_task(pipe):