Administrator
2023-07-24 0304e71a1c82f6274c4af744a5284b3f1cbc0f57
bug修复
1个文件已修改
50 ■■■■ 已修改文件
trade/huaxin/trade_server.py 50 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/trade_server.py
@@ -228,31 +228,35 @@
                        sk.sendall(json.dumps({"code": 0}).encode(encoding='utf-8'))
                    elif data_json["type"] == "l2_market_data":
                        data = data_json["data"]
                        code = data["code"]
                        data = data["data"]
                        time_str = f"{data['dataTimeStamp']}"
                        if time_str.startswith("9"):
                            time_str = "0" + time_str
                        time_str = time_str[:6]
                        time_str = f"{time_str[0:2]}:{time_str[2:4]}:{time_str[4:6]}"
                        buy_1_price, buy_1_volume = data["buy"][0]
                        sell_1_price, sell_1_volume = data["sell"][0]
                        limit_up_price = gpcode_manager.get_limit_up_price(code)
                        try:
                            data = data_json["data"]
                            code = data["code"]
                            data = data["data"]
                            time_str = f"{data['dataTimeStamp']}"
                            if time_str.startswith("9"):
                                time_str = "0" + time_str
                            time_str = time_str[:6]
                            time_str = f"{time_str[0:2]}:{time_str[2:4]}:{time_str[4:6]}"
                            buy_1_price, buy_1_volume = data["buy"][0]
                            sell_1_price, sell_1_volume = data["sell"][0]
                            limit_up_price = gpcode_manager.get_limit_up_price(code)
                        if limit_up_price is not None:
                            # 处理买1,卖1信息
                            code_price_manager.Buy1PriceManager.process(code, buy_1_price, time_str, limit_up_price,
                                                                        sell_1_price, sell_1_volume // 100)
                        hx_logger_l2_market_data.info(f"{code}#{data}")
                        sk.sendall(json.dumps({"code": 0}).encode(encoding='utf-8'))
                            if limit_up_price is not None:
                                # 处理买1,卖1信息
                                code_price_manager.Buy1PriceManager.process(code, buy_1_price, time_str, limit_up_price,
                                                                            sell_1_price, sell_1_volume // 100)
                            hx_logger_l2_market_data.info(f"{code}#{data}")
                        finally:
                            sk.sendall(socket_util.load_header(json.dumps({"code": 0}).encode(encoding='utf-8')))
                    elif data_json["type"] == "l2_subscript_codes":
                        data = data_json["data"]
                        datas = data["data"]
                        print("l2_subscript_codes", data_json)
                        # 订阅的代码
                        huaxin_target_codes_manager.save_subscript_codes(datas)
                        sk.sendall(json.dumps({"code": 0}).encode(encoding='utf-8'))
                        try:
                            data = data_json["data"]
                            datas = data["data"]
                            print("l2_subscript_codes", data_json)
                            # 订阅的代码
                            huaxin_target_codes_manager.save_subscript_codes(datas)
                        finally:
                            sk.sendall(socket_util.load_header(json.dumps({"code": 0}).encode(encoding='utf-8')))
                else:
                    # 断开连接
                    break