From 75dbfda5782f8e21370663d38d119981f6b45876 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期四, 10 八月 2023 14:30:15 +0800
Subject: [PATCH] bug修复

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

diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py
index 77054f5..cd2232f 100644
--- a/l2/l2_data_manager_new.py
+++ b/l2/l2_data_manager_new.py
@@ -23,7 +23,7 @@
     local_latest_datas
 import l2.l2_data_util
 from log_module.log import logger_l2_trade_buy, logger_l2_process, \
-    logger_place_order_score, logger_l2_error
+    logger_place_order_score, logger_l2_error, logger_profile
 
 # TODO l2鏁版嵁绠$悊
 from trade.trade_data_manager import CodeActualPriceProcessor
@@ -419,10 +419,7 @@
             output = io.StringIO()
             lp.print_stats(stream=output)
             lp.disable()
-            with open(
-                    f"/home/logs/profile/{code}_start_compute_buy_{start_index}_{end_index}.txt",
-                    'w') as f:
-                f.write(output.getvalue())
+            logger_profile.info(output.getvalue())
 
     # 娴嬭瘯涓撶敤
     @classmethod
@@ -505,14 +502,14 @@
             _start_time = round(t.time() * 1000)
             try:
                 b_need_cancel, b_cancel_data = HourCancelBigNumComputer().need_cancel(code, buy_single_index,
-                                                                                    buy_exec_index, start_index,
-                                                                                    end_index, total_data,
-                                                                                    local_today_num_operate_map.get(
-                                                                                        code),
-                                                                                    code_volumn_manager.get_volume_rate_index(
-                                                                                        buy_volume_rate),
-                                                                                    cls.volume_rate_info[code][1],
-                                                                                    is_first_code)
+                                                                                      buy_exec_index, start_index,
+                                                                                      end_index, total_data,
+                                                                                      local_today_num_operate_map.get(
+                                                                                          code),
+                                                                                      code_volumn_manager.get_volume_rate_index(
+                                                                                          buy_volume_rate),
+                                                                                      cls.volume_rate_info[code][1],
+                                                                                      is_first_code)
                 if b_need_cancel and b_cancel_data:
                     return b_cancel_data, "H鎾ら攢姣斾緥瑙﹀彂闃堝��"
             except Exception as e:
@@ -527,10 +524,10 @@
             _start_time = round(t.time() * 1000)
             try:
                 b_need_cancel, b_cancel_data = LCancelBigNumComputer().need_cancel(code,
-                                                                                 buy_exec_index, start_index,
-                                                                                 end_index, total_data,
-                                                                                 local_today_num_operate_map.get(
-                                                                                     code), is_first_code)
+                                                                                   buy_exec_index, start_index,
+                                                                                   end_index, total_data,
+                                                                                   local_today_num_operate_map.get(
+                                                                                       code), is_first_code)
                 if b_need_cancel and b_cancel_data:
                     return b_cancel_data, "L鎾ら攢姣斾緥瑙﹀彂闃堝��"
             except Exception as e:
@@ -1108,7 +1105,8 @@
                                                                                                              max_num_set)
         _start_time = l2_data_log.l2_time(code, tool.get_now_timestamp() - _start_time, "绾拱棰濈粺璁℃椂闂�")
 
-        l2_log.debug(code, "m鍊�-{} 閲忔瘮:{} rebegin_buy_pos:{}", threshold_money, cls.volume_rate_info[code][0], rebegin_buy_pos)
+        l2_log.debug(code, "m鍊�-{} 閲忔瘮:{} rebegin_buy_pos:{}", threshold_money, cls.volume_rate_info[code][0],
+                     rebegin_buy_pos)
 
         # 涔板叆淇″彿浣嶄笌璁$畻浣嶇疆闂撮殧2s鍙婁互涓婁簡
         if rebegin_buy_pos is not None:
@@ -1186,7 +1184,17 @@
                 # 鏁版嵁灏氭湭澶勭悊瀹屾瘯锛岃繘琛屼笅涓�姝ュ鐞�
                 l2_log.debug(code, "鏁版嵁灏氭湭澶勭悊瀹屾瘯锛岃繘琛屼笅涓�姝ュ鐞嗭紝澶勭悊杩涘害锛歿}", compute_index)
                 # 澶勭悊鎾ゅ崟姝ラ
-                cls.__process_order(code, compute_index + 1, compute_end_index, capture_time, is_first_code, False)
+                # cls.__process_order(code, compute_index + 1, compute_end_index, capture_time, is_first_code, False)
+                lp = LineProfiler()
+                lp.enable()
+                lp_wrap = lp(cls.__process_order)
+                lp_wrap(code, compute_index + 1, compute_end_index, capture_time, is_first_code, False)
+                output = io.StringIO()
+                lp.print_stats(stream=output)
+                lp.disable()
+                logger_profile.info(output.getvalue())
+
+
                 _start_time = l2_data_log.l2_time(code, tool.get_now_timestamp() - _start_time,
                                                   f"澶勭悊鎾ゅ崟姝ラ鑰楁椂锛岃寖鍥达細{compute_index + 1}-{compute_end_index}", force=True)
 

--
Gitblit v1.8.0