From a35b68c973629017c36cc9339053054167477bd9 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期五, 18 八月 2023 15:11:53 +0800
Subject: [PATCH] 解决交易无限循环的bug

---
 l2/l2_data_manager_new.py |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py
index 0ead99b..5fcf09f 100644
--- a/l2/l2_data_manager_new.py
+++ b/l2/l2_data_manager_new.py
@@ -214,7 +214,8 @@
     __l2PlaceOrderParamsManagerDict = {}
     __last_buy_single_dict = {}
     __TradeBuyQueue = transaction_progress.TradeBuyQueue()
-    __latest_process_unique_keys = {}
+    __latest_process_order_unique_keys = {}
+    __latest_process_not_order_unique_keys = {}
     # 鍒濆鍖�
     __TradePointManager = l2_data_manager.TradePointManager()
     __SecondCancelBigNumComputer = SecondCancelBigNumComputer()
@@ -453,10 +454,10 @@
     def __process_order(cls, code, start_index, end_index, capture_time, is_first_code, new_add=True):
         # 澧炲姞鎺ㄥ嚭鏈哄埗
         unique_key = f"{start_index}-{end_index}"
-        if cls.__latest_process_unique_keys.get(code) == unique_key:
+        if cls.__latest_process_order_unique_keys.get(code) == unique_key:
             logger_l2_error.error(f"閲嶅澶勭悊鏁版嵁锛歝ode-{code} start_index-{start_index} end_index-{end_index}")
             return
-        cls.__latest_process_unique_keys[code] = unique_key
+        cls.__latest_process_order_unique_keys[code] = unique_key
 
         # S鎾�
         def s_cancel(_buy_single_index, _buy_exec_index):
@@ -989,6 +990,13 @@
                             new_add=True):
         if compute_end_index < compute_start_index:
             return
+
+        unique_key = f"{compute_start_index}-{compute_end_index}"
+        if cls.__latest_process_not_order_unique_keys.get(code) == unique_key:
+            logger_l2_error.error(f"閲嶅澶勭悊鏁版嵁锛歝ode-{code} start_index-{compute_start_index} end_index-{compute_end_index}")
+            return
+        cls.__latest_process_not_order_unique_keys[code] = unique_key
+
         _start_time = tool.get_now_timestamp()
         total_datas = local_today_datas[code]
         # 澶勭悊瀹夊叏绗旀暟

--
Gitblit v1.8.0