From c81e244207a297280c602d40fb3ce0a365fb23e5 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期四, 21 三月 2024 13:07:07 +0800
Subject: [PATCH] L2数据本地加载优化

---
 l2/l2_data_manager_new.py |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py
index 2b5c092..049b874 100644
--- a/l2/l2_data_manager_new.py
+++ b/l2/l2_data_manager_new.py
@@ -308,9 +308,8 @@
     def process_huaxin(cls, code, origin_datas):
         datas = None
         try:
-            l2_data_log.l2_time_log(code, "寮�濮嬪姞杞藉巻鍙叉暟鎹�")
             # 鍔犺浇鍘嗗彶鐨凩2鏁版嵁
-            is_normal = l2.l2_data_util.load_l2_data(code, load_latest=False)
+            is_normal = l2.l2_data_util.l2_data_is_normal(code)
             if not is_normal:
                 # 鏁版嵁涓嶆甯搁渶瑕佺姝氦鏄�
                 l2_trade_util.forbidden_trade(code, msg="L2鍘嗗彶鏁版嵁寮傚父")
@@ -319,11 +318,9 @@
             total_datas = local_today_datas.get(code)
             if total_datas:
                 _start_index = total_datas[-1]["index"] + 1
-            l2_data_log.l2_time_log(code, "寮�濮嬫牸寮忓寲鍘熷鏁版嵁")
             datas = l2_huaxin_util.get_format_l2_datas(code, origin_datas,
                                                        gpcode_manager.get_limit_up_price(code), _start_index)
             __start_time = round(t.time() * 1000)
-            l2_data_log.l2_time_log(code, "寮�濮嬪鐞嗘暟鎹�")
             if len(datas) > 0:
                 cls.process_add_datas(code, datas, 0, __start_time)
         except Exception as e:
@@ -332,7 +329,6 @@
             logger_l2_error.exception(e)
         finally:
             if datas:
-                l2_data_log.l2_time_log(code, "寮�濮嬩繚瀛樻暟鎹�")
                 l2.l2_data_util.save_l2_data(code, None, datas)
             origin_datas.clear()
 
@@ -341,13 +337,17 @@
         real_order_index = huaxin_delegate_postion_manager.recompute_for_slow_time(code, order_info,
                                                                                    pre_real_order_index)
         if real_order_index:
-            exec_data = order_info[2]
-            order_begin_pos = cls.__get_order_begin_pos(
-                code)
-            if order_begin_pos and order_begin_pos.buy_exec_index == exec_data["index"]:
-                cls.set_real_place_order_index(code, real_order_index, order_begin_pos)
-                async_log_util.info(logger_real_place_order_position,
-                                    f"鐪熷疄涓嬪崟浣嶇煫姝o細{code}-{real_order_index}  涓嬪崟鏁版嵁锛歿order_info}")
+            try:
+                exec_data = order_info[2]
+                order_begin_pos = cls.__get_order_begin_pos(
+                    code)
+                async_log_util.info(logger_debug, f"涓嬪崟浣嶇煫姝o細鐪熷疄涓嬪崟浣�-{real_order_index} 璁㈠崟淇℃伅-{order_info}  涓嬪崟淇℃伅-{order_begin_pos}")
+                if order_begin_pos and order_begin_pos.buy_exec_index == exec_data["index"]:
+                    cls.set_real_place_order_index(code, real_order_index, order_begin_pos)
+                    async_log_util.info(logger_real_place_order_position,
+                                        f"鐪熷疄涓嬪崟浣嶇煫姝o細{code}-{real_order_index}  涓嬪崟鏁版嵁锛歿order_info}")
+            except Exception as e:
+                logger_debug.exception(e)
 
     @classmethod
     def process_add_datas(cls, code, add_datas, capture_timestamp, __start_time):
@@ -360,7 +360,6 @@
             l2.l2_data_util.load_num_operate_map(local_today_num_operate_map, code, add_datas)
             l2.l2_data_util.load_buy_no_map(local_today_buyno_map, code, add_datas)
             l2.l2_data_util.load_canceled_buy_no_map(local_today_canceled_buyno_map, code, add_datas)
-            l2_data_log.l2_time_log(code, "process_add_datas 鍔犺浇瀹屾暟鎹�")
             if constant.L2_SOURCE_TYPE == constant.L2_SOURCE_TYPE_HUAXIN:
                 try:
                     if constant.TEST:
@@ -452,7 +451,6 @@
                 state = cls.__CodesTradeStateManager.get_trade_state_cache(code)
                 start_index = len(total_datas) - len(add_datas)
                 end_index = len(total_datas) - 1
-                l2_data_log.l2_time_log(code, "process_add_datas 寮�濮嬪鐞�")
                 if state == trade_manager.TRADE_STATE_BUY_DELEGATED or state == trade_manager.TRADE_STATE_BUY_PLACE_ORDER or state == trade_manager.TRADE_STATE_BUY_SUCCESS:
                     # 宸叉寕鍗�
                     cls.__process_order(code, start_index, end_index, capture_timestamp, is_first_code)
@@ -1463,7 +1461,6 @@
             # 璁板綍娌′笅鍗曞師鍥�
             async_log_util.info(logger_l2_not_buy_reasons, f"{code}#{not_buy_msg}")
             _start_time = t.time()
-        l2_data_log.l2_time_log(code, "__start_compute_buy 缁撴潫")
 
     # 鑾峰彇涓嬪崟璧峰淇″彿
     @classmethod

--
Gitblit v1.8.0