From bfbcb5aefb4eb7b235628728d150dfd7ade50442 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期三, 02 八月 2023 10:59:36 +0800
Subject: [PATCH] redis缓存加入内存缓存

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

diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py
index ea0ef89..186eae7 100644
--- a/l2/l2_data_manager_new.py
+++ b/l2/l2_data_manager_new.py
@@ -235,7 +235,7 @@
             _start_index = 0
             total_datas = local_today_datas.get(code)
             if total_datas:
-                _start_index =total_datas[-1]["index"] + 1
+                _start_index = total_datas[-1]["index"] + 1
             datas = l2_huaxin_util.get_format_l2_datas(code, origin_datas,
                                                        gpcode_manager.get_limit_up_price(code), _start_index)
             # 鑾峰彇涓嬪崟浣嶇疆
@@ -294,7 +294,7 @@
 
         if len(add_datas) > 0:
             # 鏄惁涓洪鏉夸唬鐮�
-            is_first_code = True #gpcode_manager.FirstCodeManager.is_in_first_record(code)
+            is_first_code = True  # gpcode_manager.FirstCodeManager.is_in_first_record(code)
             # 璁$畻閲�
             volume_rate = code_volumn_manager.get_volume_rate(code)
             volume_rate_index = code_volumn_manager.get_volume_rate_index(volume_rate)
@@ -324,7 +324,7 @@
                 end_index = len(total_datas) - 1
                 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:
                     # 宸叉寕鍗�
-                    if True: #len(add_datas) < 10:
+                    if True:  # len(add_datas) < 10:
                         cls.__process_order(code, start_index, end_index, capture_timestamp, is_first_code)
                     else:
                         pass
@@ -342,9 +342,7 @@
                 else:
                     # 鏈寕鍗�,鏃堕棿鐩稿樊涓嶅ぇ鎵嶈兘鎸傚崟
                     if l2.l2_data_util.L2DataUtil.is_same_time(now_time_str, latest_time):
-
                         cls.__process_not_order(code, start_index, end_index, capture_timestamp, is_first_code)
-
 
             logger_l2_process.info("code:{} 澶勭悊鏁版嵁鑼冨洿: {}-{} 澶勭悊鏃堕棿:{} 鎴浘鏃堕棿鎴筹細{}", code, add_datas[0]["index"],
                                    add_datas[-1]["index"], round(t.time() * 1000) - __start_time,
@@ -361,7 +359,7 @@
         if round(t.time() * 1000) - __start_time > 10:
             __start_time = l2_data_log.l2_time(code, round(t.time() * 1000) - __start_time,
                                                "鑾峰彇m鍊兼暟鎹�楁椂")
-        if True: #end_index - start_index < 10:
+        if True:  # end_index - start_index < 10:
             cls.__start_compute_buy(code, start_index, end_index, threshold_money, capture_time, is_first_code)
         else:
             pass
@@ -575,7 +573,17 @@
         if not is_first_code:
             can, need_clear_data, reason = cls.__can_buy(code)
         else:
-            can, need_clear_data, reason = cls.__can_buy_first(code)
+            # can, need_clear_data, reason = cls.__can_buy_first(code)
+            lp = LineProfiler()
+            lp.enable()
+            lp_wrap = lp(cls.__can_buy_first)
+            can, need_clear_data, reason = lp_wrap(code)
+            output = io.StringIO()
+            lp.print_stats(stream=output)
+            lp.disable()
+            with open(f"/home/logs/profile/{code}_can_buy_first.txt", 'w') as f:
+                f.write(output.getvalue())
+
         __start_time = l2_data_log.l2_time(code, tool.get_now_timestamp() - __start_time, "鏈�鍚庡垽鏂槸鍚﹁兘涓嬪崟", force=True)
         # 鍒犻櫎铏氭嫙涓嬪崟
         if code in cls.unreal_buy_dict:

--
Gitblit v1.8.0