From ddd49deef7ac6daff95086f112a0061a641c4fe3 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期四, 13 六月 2024 15:36:00 +0800
Subject: [PATCH] 添加订阅日志

---
 log_module/log_export.py                           |   21 ++++++++++++++++++++-
 l2/huaxin/huaxin_target_codes_manager.py           |    2 ++
 code_attribute/first_target_code_data_processor.py |    5 ++++-
 trade/huaxin/huaxin_trade_server.py                |   11 ++++++++---
 4 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/code_attribute/first_target_code_data_processor.py b/code_attribute/first_target_code_data_processor.py
index e926dbd..e2fff56 100644
--- a/code_attribute/first_target_code_data_processor.py
+++ b/code_attribute/first_target_code_data_processor.py
@@ -110,7 +110,7 @@
     #         except Exception as e:
     #             logging.exception(e)
     #             pass
-
+    logger_l2_codes_subscript.info(f"{request_id}鍔犺浇l2浠g爜娑ㄥ仠浠风粨鏉�")
     # 鑾峰彇60澶╂渶澶ц褰�
     for code in codes:
         need_get_volumn = False
@@ -201,6 +201,9 @@
             except Exception as e:
                 logger_first_code_record.error(f"{code}:{str(e)}")
                 logger_first_code_record.exception(e)
+
+    logger_l2_codes_subscript.info(f"{request_id}鍔犺浇l2浠g爜K绾跨粨鏉�")
+
     gpcode_manager.FirstCodeManager().add_record(codes)
     # 鍒濆鍖栨澘鍧椾俊鎭紝鏆傛椂鍒犻櫎
     # for code in codes:
diff --git a/l2/huaxin/huaxin_target_codes_manager.py b/l2/huaxin/huaxin_target_codes_manager.py
index edcd767..c1fd82f 100644
--- a/l2/huaxin/huaxin_target_codes_manager.py
+++ b/l2/huaxin/huaxin_target_codes_manager.py
@@ -145,6 +145,8 @@
             current_price_process_manager.accept_prices(tick_datas, request_id)
         except Exception as e:
             logger_debug.exception(e)
+        finally:
+            async_log_util.info(logger_l2_codes_subscript, f"({request_id})L1鏁版嵁鏁翠綋澶勭悊缁撴潫")
 
 
 if __name__ == "__main__":
diff --git a/log_module/log_export.py b/log_module/log_export.py
index 2696945..a45f3ac 100644
--- a/log_module/log_export.py
+++ b/log_module/log_export.py
@@ -124,7 +124,7 @@
         date = datetime.datetime.now().strftime("%Y-%m-%d")
     pos_list = []
     path_ = "{}/logs/gp/l2/l2_process.{}.log".format(constant.get_path_prefix(), date)
-    if os.path.exists(path_):
+    try:
         with open(path_, mode='r',
                   encoding="utf-8") as f:
             while True:
@@ -141,6 +141,8 @@
                             pos_list.append((int(line.split("-")[0]), int(line.split("-")[1])))
                         except Exception as e:
                             logging.exception(e)
+    except:
+        pass
     return pos_list
 
 
@@ -626,6 +628,23 @@
     return fdatas
 
 
+def load_huaxin_order_detail(date=tool.get_now_date_str()):
+    """
+    鍔犺浇L2閫愮瑪濮旀墭鏁版嵁
+    @param date:
+    @return:
+    """
+    fdatas = []
+    path = f"{constant.get_path_prefix()}/logs/huaxin/l2/orderdetail.{date}.log"
+    lines = __load_file_content(path)
+    for line in lines:
+        if line:
+            time = __get_async_log_time(line)
+            line = line[line.rfind("#") + 1:]
+            fdatas.append((time, eval(line)))
+    return fdatas
+
+
 def load_pre_close_price(date=tool.get_now_date_str()):
     """
     鍔犺浇涔嬪墠鐨勬敹鐩樹环
diff --git a/trade/huaxin/huaxin_trade_server.py b/trade/huaxin/huaxin_trade_server.py
index 56412dc..8f0f76d 100644
--- a/trade/huaxin/huaxin_trade_server.py
+++ b/trade/huaxin/huaxin_trade_server.py
@@ -46,7 +46,7 @@
 from log_module.log import hx_logger_contact_debug, hx_logger_trade_callback, \
     hx_logger_l2_orderdetail, hx_logger_l2_market_data, logger_l2_g_cancel, logger_debug, \
     logger_system, logger_trade, logger_trade_position_api_request, logger_request_api, \
-    logger_local_huaxin_l1_trade_info, logger_real_place_order_position, logger_device
+    logger_local_huaxin_l1_trade_info, logger_real_place_order_position, logger_device, logger_l2_codes_subscript
 from output import l2_output_util
 from third_data import block_info, kpl_data_manager, kpl_util, history_k_data_util, kpl_api
 from third_data.code_plate_key_manager import KPLCodeJXBlockManager, CodePlateKeyBuyManager
@@ -373,8 +373,12 @@
         request_id = data_json["request_id"]
         datas = data["data"]
         cls.__save_l1_current_price(datas)
-        cls.__process_l1_data_thread_pool.submit(
-            lambda: HuaXinL1TargetCodesManager.set_level_1_codes_datas(datas, request_id=request_id))
+        # 9:30涔嬪墠閲囩敤闈炵嚎绋�
+        if int(tool.get_now_time_str().replace(":","")) < int("093000"):
+            HuaXinL1TargetCodesManager.set_level_1_codes_datas(datas, request_id=request_id)
+        else:
+            cls.__process_l1_data_thread_pool.submit(
+                lambda: HuaXinL1TargetCodesManager.set_level_1_codes_datas(datas, request_id=request_id))
 
     @classmethod
     def set_l1_trade_codes_info(cls, data_json):
@@ -543,6 +547,7 @@
                     timestamp = val.get("time")
                     # 澶т簬10s鐨勬暟鎹斁寮冨鐞�
                     if type_ == "set_target_codes":
+                        async_log_util.info(logger_l2_codes_subscript, f"绛栫暐鎺ユ敹鍒版暟鎹�")
                         if time.time() * 1000 - timestamp > 10 * 1000:
                             continue
                         TradeServerProcessor.set_target_codes(val)

--
Gitblit v1.8.0