From 7cd10cd4896bd15345968cde6c76cee33b367533 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期四, 29 八月 2024 13:48:15 +0800
Subject: [PATCH] bug修复

---
 l2/l2_data_manager_new.py |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py
index cbf0509..3f9ca9b 100644
--- a/l2/l2_data_manager_new.py
+++ b/l2/l2_data_manager_new.py
@@ -32,7 +32,7 @@
     local_latest_datas, local_today_canceled_buyno_map, local_today_sellno_map
 import l2.l2_data_util
 from log_module.log import logger_l2_trade_buy, logger_l2_process, logger_l2_error, logger_debug, \
-    logger_l2_not_buy_reasons, logger_real_place_order_position
+    logger_l2_not_buy_reasons, logger_real_place_order_position, logger_l2_trade_buy_queue
 
 from trade.trade_data_manager import CodeActualPriceProcessor, PlaceOrderCountManager, AccountMoneyManager
 
@@ -391,6 +391,8 @@
     @classmethod
     def process_add_datas(cls, code, add_datas, capture_timestamp, __start_time):
         now_time_str = tool.get_now_time_str()
+        # 灏嗘湰娆′腑鏂缃负
+        cls.__break_current_batch_data_for_buy_dict[code] = False
         if len(add_datas) > 0:
             # 璁板綍褰撳墠鎵规暟鎹殑绱㈠紩
             cls.__processing_data_indexes[code] = (add_datas[0]["index"], add_datas[-1]["index"])
@@ -453,6 +455,7 @@
         #                                    "l2鏁版嵁棰勫鐞嗘椂闂�")
 
         # 9:29:55寮�濮嬪鐞嗘暟鎹�
+        place_ordered_desc = ""
         if len(add_datas) > 0 and int(tool.get_now_time_str().replace(":", "")) > int("092955"):
             # 鏄惁涓洪鏉夸唬鐮�
             is_first_code = True  # gpcode_manager.FirstCodeManager().is_in_first_record(code)
@@ -504,24 +507,29 @@
                 state = cls.__CodesTradeStateManager.get_trade_state_cache(code)
                 start_index = len(total_datas) - len(add_datas)
                 end_index = len(total_datas) - 1
+
                 if state == trade_constant.TRADE_STATE_BUY_DELEGATED or state == trade_constant.TRADE_STATE_BUY_PLACE_ORDER or state == trade_constant.TRADE_STATE_BUY_SUCCESS:
                     # 宸叉寕鍗�
+                    place_ordered_desc = "宸蹭笅鍗�"
                     cls.__process_order(code, start_index, end_index, capture_timestamp, is_first_code)
                 else:
+                    place_ordered_desc = "鏈笅鍗�"
                     # 鏈寕鍗�,鏃堕棿鐩稿樊涓嶅ぇ鎵嶈兘鎸傚崟
                     # tool.trade_time_sub(latest_time, "09:32:00") < 0
                     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)
-            l2_log.info(code, logger_l2_process, "code:{} 澶勭悊鏁版嵁鑼冨洿: {}-{} 澶勭悊鏃堕棿:{} 绾跨▼ID锛歿}", code,
+                    else:
+                        place_ordered_desc += ":鏁版嵁寤惰繜"
+
+            l2_log.info(code, logger_l2_process, "code:{} 澶勭悊鏁版嵁鑼冨洿: {}-{} 澶勭悊鏃堕棿:{} 绾跨▼ID锛歿} 澶勭悊鎯呭喌锛歿}", code,
                         add_datas[0]["index"],
                         add_datas[-1]["index"], round(t.time() * 1000) - __start_time,
-                        l2_log.threadIds.get(code))
+                        l2_log.threadIds.get(code), place_ordered_desc)
 
     # 澶勭悊鏈寕鍗�
     @classmethod
     def __process_not_order(cls, code, start_index, end_index, capture_time, is_first_code):
-        cls.__break_current_batch_data_for_buy_dict[code] = False
         __start_time = round(t.time() * 1000)
         # 鑾峰彇闃堝��
         threshold_money, msg = cls.__get_threshmoney(code)
@@ -1020,6 +1028,7 @@
             # 鍙湁鏉垮潡婊¤冻涓嬪崟涔嬪悗鎵嶈兘鍒ゆ柇鍏跺畠鏉′欢
             range_indexes = cls.__processing_data_indexes.get(code)
             if range_indexes:
+                # 鏄惁鏄噺鍖栧崟
                 is_quantization_result = buy_strategy_util.is_quantization(code, range_indexes[0], range_indexes[1])
                 if is_quantization_result[0]:
                     cls.__next_buy_time_dict[code] = is_quantization_result[1]
@@ -1341,6 +1350,7 @@
 
         # 鍒ゆ柇涓嬫涔板叆鏃堕棿鏄惁姝g‘
         if code in cls.__next_buy_time_dict and t.time() < cls.__next_buy_time_dict[code]:
+            l2_log.debug(code, f"涓嬫鍙笅鍗曟椂闂达紙{compute_start_index}-{compute_end_index}锛夛細{cls.__next_buy_time_dict[code]}")
             return
         if code in cls.__next_buy_time_dict:
             cls.__next_buy_time_dict.pop(code)
@@ -1377,6 +1387,12 @@
             has_single, _index, sell_info, single_msg, mode = cls.__compute_active_order_begin_pos(code, continue_count,
                                                                                                    compute_start_index,
                                                                                                    compute_end_index)
+            if not has_single:
+                # 娌℃湁淇″彿锛屽鏋滃綋鍓嶆暟鎹槸娑ㄥ仠涔板氨璁板綍鏃ュ織锛岄槻姝㈣褰曡繃澶氱殑鏃ュ織
+                if L2DataUtil.is_limit_up_price_buy(
+                        total_datas[compute_start_index]["val"]) and L2DataUtil.is_limit_up_price_buy(total_datas[compute_end_index]["val"]):
+                    async_log_util.info(logger_l2_trade_buy_queue, "灏氭湭鑾峰彇鍒颁拱鍏ヤ俊鍙凤細 code-{} start_index-{}  end_index-{} msg-{}", code,
+                                        compute_start_index, compute_end_index, sell_info)
             fast_msg = None
             if has_single:
                 order_begin_pos.mode = mode
@@ -1677,6 +1693,14 @@
     # 璁$畻婵�杩涗拱鐨勪笅鍗曚俊鍙�
     @classmethod
     def __compute_active_order_begin_pos(cls, code, continue_count, start_index, end_index):
+        """
+        璁$畻涔板叆淇″彿
+        @param code:
+        @param continue_count:
+        @param start_index:
+        @param end_index:
+        @return:
+        """
         total_datas = local_today_datas[code]
         start_time_str = total_datas[start_index]["val"]["time"]
         if end_index - start_index + 1 < continue_count:

--
Gitblit v1.8.0