From c4ed4da4ac8b8bc24e0a3ed0e782e9248b4a511c Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期二, 03 六月 2025 19:00:07 +0800
Subject: [PATCH] bug修复

---
 l2/l2_transaction_data_processor.py |  381 +++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 289 insertions(+), 92 deletions(-)

diff --git a/l2/l2_transaction_data_processor.py b/l2/l2_transaction_data_processor.py
index fd6f162..aac5019 100644
--- a/l2/l2_transaction_data_processor.py
+++ b/l2/l2_transaction_data_processor.py
@@ -1,12 +1,14 @@
 import logging
 import time
 
+import dask
+
 import constant
 from cancel_strategy.s_l_h_cancel_strategy import HourCancelBigNumComputer
 from cancel_strategy.s_l_h_cancel_strategy import LCancelBigNumComputer, LCancelRateManager
 from cancel_strategy.s_l_h_cancel_strategy import SCancelBigNumComputer
 from code_attribute import gpcode_manager
-from l2 import l2_data_util, l2_data_manager, transaction_progress
+from l2 import l2_data_util, l2_data_manager, transaction_progress, l2_log, data_callback
 from l2.cancel_buy_strategy import FCancelBigNumComputer, \
     NewGCancelBigNumComputer, \
     NBCancelBigNumComputer
@@ -16,8 +18,10 @@
 from l2.l2_data_util import L2DataUtil
 from l2.l2_limitup_sell_data_manager import L2LimitUpSellDataManager
 from l2.l2_transaction_data_manager import HuaXinBuyOrderManager, HuaXinSellOrderStatisticManager, BigOrderDealManager
+from l2.place_order_single_data_manager import L2TradeSingleDataProcessor
 from log_module import async_log_util
-from log_module.log import hx_logger_l2_debug, logger_l2_trade_buy_queue, logger_debug, hx_logger_l2_upload
+from log_module.log import hx_logger_l2_debug, logger_l2_trade_buy_queue, logger_debug, hx_logger_l2_upload, \
+    logger_trade, logger_l2_trade
 from trade import current_price_process_manager, trade_constant
 import concurrent.futures
 
@@ -29,14 +33,19 @@
 class HuaXinTransactionDatasProcessor:
     __statistic_thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=constant.HUAXIN_L2_MAX_CODES_COUNT + 2)
     __TradeBuyQueue = transaction_progress.TradeBuyQueue()
+    # 闈炴定鍋滄垚浜ゆ椂闂�
+    __not_limit_up_time_dict = {}
 
     # 璁$畻鎴愪氦杩涘害
     @classmethod
-    def __compute_latest_trade_progress(cls, code, buyno_map, datas):
+    def __compute_latest_trade_progress(cls, code, fdatas):
+        buyno_map = l2_data_util.local_today_buyno_map.get(code)
+        if not buyno_map:
+            return None
         buy_progress_index = None
-        for i in range(len(datas) - 1, -1, -1):
-            d = datas[i]
-            buy_no = f"{d[6]}"
+        for i in range(len(fdatas) - 1, -1, -1):
+            d = fdatas[i]
+            buy_no = f"{d[0][6]}"
             if buyno_map and buy_no in buyno_map:
                 # 鎴愪氦杩涘害浣嶅繀椤绘槸娑ㄥ仠涔�
                 if L2DataUtil.is_limit_up_price_buy(buyno_map[buy_no]["val"]):
@@ -45,64 +54,122 @@
         return buy_progress_index
 
     @classmethod
-    def statistic_big_order_infos(cls, code, datas, order_begin_pos: OrderBeginPosInfo):
+    def statistic_big_order_infos(cls, code, fdatas, order_begin_pos: OrderBeginPosInfo):
         """
         缁熻澶у崟鎴愪氦
         @param code:
-        @param datas:
+        @param fdatas: 鏍煎紡锛歔(鏁版嵁鏈韩, 鏄惁涓诲姩涔�, 鏄惁娑ㄥ仠, 鎬绘垚浜ら, 涓嶅惈ms鏃堕棿锛屽惈ms鏃堕棿)]
         @return:
         """
-        limit_up_price = gpcode_manager.get_limit_up_price_as_num(code)
-        buy_datas, bigger_buy_datas = HuaXinBuyOrderManager.statistic_big_buy_data(code, datas, limit_up_price)
-        if buy_datas:
-            BigOrderDealManager().add_buy_datas(code, buy_datas)
-            active_big_buy_orders = []
+
+        def statistic_big_buy_data():
+            use_time_list = []
+            __start_time = time.time()
+            buy_datas, bigger_buy_datas = HuaXinBuyOrderManager.statistic_big_buy_data(code, fdatas, limit_up_price)
+            use_time_list.append((time.time() - __start_time, "涔板崟缁熻"))
             if buy_datas:
-                for x in buy_datas:
-                    if x[0] > x[6]:
-                        # (涔板崟鍙�, 鎴愪氦閲戦, 鏈�鍚庢垚浜ゆ椂闂�)
-                        active_big_buy_orders.append((x[0], x[2], x[4]))
-            EveryLimitupBigDealOrderManager.add_big_buy_order_deal(code, active_big_buy_orders)
-        try:
-            is_placed_order = l2_data_manager.TradePointManager.is_placed_order(order_begin_pos)
-            if is_placed_order:
-                if order_begin_pos and order_begin_pos.mode == OrderBeginPosInfo.MODE_RADICAL:
-                    RadicalBuyDataManager.big_order_deal(code)
+                BigOrderDealManager().add_buy_datas(code, buy_datas)
+                active_big_buy_orders = []
+                if buy_datas:
+                    for x in buy_datas:
+                        if x[0] > x[6]:
+                            # (涔板崟鍙�, 鎴愪氦閲戦, 鏈�鍚庢垚浜ゆ椂闂�)
+                            active_big_buy_orders.append((x[0], x[2], x[4]))
+                EveryLimitupBigDealOrderManager.add_big_buy_order_deal(code, active_big_buy_orders)
+                use_time_list.append((time.time() - __start_time, "涔板崟缁熻缁撴灉澶勭悊"))
+            try:
+                is_placed_order = l2_data_manager.TradePointManager.is_placed_order(order_begin_pos)
+                if is_placed_order:
+                    if order_begin_pos and order_begin_pos.mode == OrderBeginPosInfo.MODE_RADICAL:
+                        RadicalBuyDataManager.big_order_deal(code)
 
-            if is_placed_order and bigger_buy_datas:
-                # 鏈夊ぇ浜�50w鐨勫ぇ鍗曟垚浜�
-                buyno_map = l2_data_util.local_today_buyno_map.get(code)
-                if buyno_map:
-                    for buy_data in bigger_buy_datas:
-                        order_no = f"{buy_data[0]}"
-                        if order_no in buyno_map:
-                            LCancelBigNumComputer().add_deal_index(code, buyno_map[order_no]["index"],
-                                                                   order_begin_pos.buy_single_index)
-        except Exception as e:
-            logger_debug.exception(e)
+                    if bigger_buy_datas:
+                        # 鏈夊ぇ浜�50w鐨勫ぇ鍗曟垚浜�
+                        buyno_map = l2_data_util.local_today_buyno_map.get(code)
+                        if buyno_map:
+                            for buy_data in bigger_buy_datas:
+                                order_no = f"{buy_data[0]}"
+                                if order_no in buyno_map:
+                                    LCancelBigNumComputer().add_deal_index(code, buyno_map[order_no]["index"],
+                                                                           order_begin_pos.buy_single_index)
+            except Exception as e:
+                logger_debug.exception(e)
+            if use_time_list and use_time_list[-1][0] > 0.005:
+                l2_log.info(code, hx_logger_l2_upload,
+                            f"涔板崟缁熻+澶勭悊鑰楁椂锛歿use_time_list[-1][0]}  璇︽儏:{use_time_list}")
 
-        sell_datas = HuaXinSellOrderStatisticManager.statistic_big_sell_data(code, datas)
-        if sell_datas:
-            BigOrderDealManager().add_sell_datas(code, sell_datas)
+            return buy_datas
 
-        if buy_datas or sell_datas:
-            buy_money = BigOrderDealManager().get_total_buy_money(code)
-            sell_money = BigOrderDealManager().get_total_sell_money(code)
-            LCancelRateManager.set_big_num_deal_info(code, buy_money, sell_money)
+        def statistic_big_sell_data():
+            use_time_list = []
+            __start_time = time.time()
+            sell_datas = HuaXinSellOrderStatisticManager.statistic_big_sell_data(code, fdatas)
+            if sell_datas:
+                BigOrderDealManager().add_sell_datas(code, sell_datas)
+            use_time_list.append((time.time() - __start_time, "鍗栧崟缁熻"))
+            if use_time_list and use_time_list[-1][0] > 0.005:
+                l2_log.info(code, hx_logger_l2_upload,
+                            f"鍗栧崟缁熻+澶勭悊鑰楁椂锛歿use_time_list[-1][0]}  璇︽儏:{use_time_list}")
+            return sell_datas
+
+        def statistic_big_data(f1_, f2_):
+            temp_data = f1_, f2_
+            return temp_data
+
+        limit_up_price = gpcode_manager.get_limit_up_price_as_num(code)
+
+        if False and len(fdatas) > 100:
+            # 骞惰澶勭悊涔板崟涓庡崠鍗�
+            # 瓒呰繃100鏉℃暟鎹墠闇�瑕佸苟琛屽鐞�
+            f1 = dask.delayed(statistic_big_buy_data)()
+            f2 = dask.delayed(statistic_big_sell_data)()
+            dask_result = dask.delayed(statistic_big_data)(f1, f2)
+            buy_datas, sell_datas = dask_result.compute()
+        else:
+            buy_datas = statistic_big_buy_data()
+            sell_datas = statistic_big_sell_data()
+        # L鎾ょ殑姣斾緥涓庝拱鍗栧ぇ鍗曟棤鐩存帴鍏崇郴浜�
+        # if buy_datas or sell_datas:
+        #     buy_money = BigOrderDealManager().get_total_buy_money(code)
+        #     sell_money = BigOrderDealManager().get_total_sell_money(code)
+        #     LCancelRateManager.set_big_num_deal_info(code, buy_money, sell_money)
 
     @classmethod
-    def process_huaxin_transaction_datas(cls, code, datas):
-        __start_time = time.time()
+    def process_huaxin_transaction_datas(cls, code, o_datas):
+        # 鏁村舰鏁版嵁锛屾牸寮忥細[(鏁版嵁鏈韩, 鏄惁涓诲姩涔�, 鏄惁娑ㄥ仠, 鎬绘垚浜ら, 涓嶅惈ms鏃堕棿锛屽惈ms鏃堕棿)]
         limit_up_price = gpcode_manager.get_limit_up_price_as_num(code)
+        # q.append((data['SecurityID'], data['TradePrice'], data['TradeVolume'],
+        #                   data['OrderTime'], data['MainSeq'], data['SubSeq'], data['BuyNo'],
+        #                   data['SellNo'], data['ExecType']))
+        fdatas = [
+            [d, d[6] > d[7], limit_up_price == d[1], d[1] * d[2], '', '']
+            for d in o_datas]
+        temp_time_dict = {}
+        for d in fdatas:
+            if d[0][3] not in temp_time_dict:
+                temp_time_dict[d[0][3]] = l2_huaxin_util.convert_time(d[0][3], with_ms=True)
+            d[5] = temp_time_dict.get(d[0][3])
+            d[4] = d[5][:8]
+        temp_time_dict.clear()
+
+        __start_time = time.time()
         # 璁剧疆鎴愪氦浠�
         try:
-            current_price_process_manager.set_trade_price(code, datas[-1][1])
-            if limit_up_price > datas[-1][1]:
-                # 娌℃湁娑ㄥ仠
-                EveryLimitupBigDealOrderManager.open_limit_up(code)
-                radical_buy_strategy.clear_data(code)
-        except:
-            pass
+            current_price_process_manager.set_trade_price(code, fdatas[-1][0][1])
+            if not fdatas[-1][2]:
+                if code not in cls.__not_limit_up_time_dict:
+                    cls.__not_limit_up_time_dict[code] = fdatas[-1][5]
+                last_time = cls.__not_limit_up_time_dict[code]
+                # 鐐告澘鏃堕棿鎸佺画500ms浠ヤ笂绠楃偢鏉�
+                if tool.trade_time_sub_with_ms(fdatas[-1][5], last_time) > 500:
+                    # 娌℃湁娑ㄥ仠
+                    EveryLimitupBigDealOrderManager.open_limit_up(code, f"鏈�鏂版垚浜や环锛歿fdatas[-1][0][1]}")
+                    radical_buy_strategy.clear_data(code, msg=f"娌℃湁娑ㄥ仠锛歿fdatas[-1][0]}")
+            else:
+                if code in cls.__not_limit_up_time_dict:
+                    cls.__not_limit_up_time_dict.pop(code)
+        except Exception as e:
+            async_log_util.error(logger_debug, f"L2鎴愪氦寮�鏉胯绠楅敊璇細{str(e)}")
 
         total_datas = l2_data_util.local_today_datas.get(code)
         use_time_list = []
@@ -116,46 +183,43 @@
             is_placed_order = l2_data_manager.TradePointManager.is_placed_order(order_begin_pos)
 
             _start_time = time.time()
-            L2LimitUpSellDataManager.set_deal_datas(code, datas)
+            # 璁剧疆娑ㄥ仠鍗栨垚浜ゆ暟鎹�
+            L2LimitUpSellDataManager.set_deal_datas(code, fdatas)
+            use_time_list.append(("缁熻娑ㄥ仠鍗栨垚浜�", time.time() - _start_time))
+            _start_time = time.time()
             #  澶у崟缁熻
             # cls.__statistic_thread_pool.submit(cls.statistic_big_order_infos, code, datas, order_begin_pos)
             try:
-                cls.statistic_big_order_infos(code, datas, order_begin_pos)
+                cls.statistic_big_order_infos(code, fdatas, order_begin_pos)
             except Exception as e:
-                hx_logger_l2_debug.error(f"缁熻澶у崟鍑洪敊锛歿str(e)}")
-            use_time_list.append(("缁熻涔板崟鏁版嵁", time.time() - _start_time))
+                async_log_util.error(hx_logger_l2_debug, f"缁熻澶у崟鍑洪敊锛歿str(e)}")
+            use_time_list.append(("缁熻澶у崟鏁版嵁", time.time() - _start_time))
             _start_time = time.time()
 
-            big_sell_order_info = None
             try:
+                last_data = fdatas[-1]
                 # 缁熻涓婃澘鏃堕棿
-                try:
-                    for d in datas:
-                        if d[6] > d[7]:
-                            # 涓诲姩涔�
-                            if d[1] == limit_up_price:
-                                # 娑ㄥ仠
-                                current_price_process_manager.set_latest_not_limit_up_time(code,
-                                                                                           l2_huaxin_util.convert_time(
-                                                                                               d[3], with_ms=True))
-                        else:
-                            # 涓诲姩鍗栵紙鏉夸笂锛�
-                            if d[1] == limit_up_price:
-                                L2LimitUpSellDataManager.clear_data(code)
-                                break
-                except:
-                    pass
-
+                if last_data[1] and last_data[2]:
+                    current_price_process_manager.set_latest_not_limit_up_time(code, last_data[5])
+                if not last_data[1] and last_data[2]:
+                    L2LimitUpSellDataManager.clear_data(code)
+                big_sell_order_info = None
                 # 缁熻鍗栧崟
-                big_sell_order_info = HuaXinSellOrderStatisticManager.add_transaction_datas(code, datas, limit_up_price)
+                big_sell_order_info = HuaXinSellOrderStatisticManager.statistic_continue_limit_up_sell_transaction_datas(
+                    code, fdatas,
+                    limit_up_price)
 
+                use_time_list.append(("澶勭悊鍗栧崟鎴愪氦鏁版嵁", time.time() - _start_time))
                 _start_time = time.time()
-                use_time_list.append(("澶勭悊鍗栧崟鎴愪氦鏁版嵁", _start_time - __start_time))
+
                 if is_placed_order:
 
-                    need_cancel, cancel_msg = SCancelBigNumComputer().set_big_sell_order_info_for_cancel(code,
-                                                                                                         big_sell_order_info,
-                                                                                                         order_begin_pos)
+                    LCancelBigNumComputer().set_big_sell_order_info(code, big_sell_order_info)
+
+                    # need_cancel, cancel_msg = SCancelBigNumComputer().set_big_sell_order_info_for_cancel(code,
+                    #                                                                                      big_sell_order_info,
+                    #                                                                                      order_begin_pos)
+                    need_cancel, cancel_msg = False, ""
                     cancel_type = None
                     if need_cancel:
                         cancel_msg = f"S鎾�:{cancel_msg}"
@@ -165,10 +229,10 @@
                                                                                             order_begin_pos)
                         cancel_type = trade_constant.CANCEL_TYPE_P
                     # 鍒ゆ柇鏃堕棿鏄惁涓庢湰鍦版椂闂寸浉宸�5s浠ヤ笂
-                    if tool.trade_time_sub(tool.get_now_time_str(), l2_huaxin_util.convert_time(datas[-1][3])) > 10:
+                    if tool.trade_time_sub(tool.get_now_time_str(), fdatas[-1][4]) > 10:
                         now_seconds = int(tool.get_now_time_str().replace(":", ""))
                         if now_seconds < int("093100"):  # or int("130000") <= now_seconds < int("130200"):
-                            need_cancel, cancel_msg = True, f"鎴愪氦鏃堕棿涓庢湰鍦版椂闂寸浉宸�10S浠ヤ笂锛寋l2_huaxin_util.convert_time(datas[-1][3])}"
+                            need_cancel, cancel_msg = True, f"鎴愪氦鏃堕棿涓庢湰鍦版椂闂寸浉宸�10S浠ヤ笂锛寋fdatas[-1][4]}"
                             cancel_type = trade_constant.CANCEL_TYPE_L2_DELAY
                     if need_cancel:
                         L2TradeDataProcessor.cancel_buy(code, cancel_msg, cancel_type=cancel_type)
@@ -177,7 +241,7 @@
                     use_time_list.append(("澶勭悊鍗栧崟鐩稿叧鎾ゆ暟鎹�", time.time() - _start_time))
                     _start_time = time.time()
                 # 缁熻娑ㄥ仠鍗栨垚浜�
-                HuaXinSellOrderStatisticManager.statistic_total_deal_volume(code, datas, limit_up_price)
+                HuaXinSellOrderStatisticManager.statistic_active_sell_deal_volume(code, fdatas, limit_up_price)
                 use_time_list.append(("缁熻鎴愪氦閲忔暟鎹�", time.time() - _start_time))
             except Exception as e:
                 async_log_util.error(logger_debug, f"鍗栧崟缁熻寮傚父锛歿big_sell_order_info}")
@@ -187,16 +251,15 @@
             # if big_money_count > 0:
             #     LCancelRateManager.compute_big_num_deal_rate(code)
 
-            buy_progress_index = cls.__compute_latest_trade_progress(code, buyno_map, datas)
+            buy_progress_index = cls.__compute_latest_trade_progress(code, fdatas)
 
             if buy_progress_index is not None:
                 buy_progress_index_changed = cls.__TradeBuyQueue.set_traded_index(code, buy_progress_index,
                                                                                   total_datas)
-                async_log_util.info(logger_l2_trade_buy_queue, "鑾峰彇鎴愪氦浣嶇疆鎴愬姛锛� code-{} index-{}", code,
-                                    buy_progress_index)
+                l2_log.info(code, logger_l2_trade_buy_queue, "鑾峰彇鎴愪氦浣嶇疆鎴愬姛锛� code-{} index-{}", code, buy_progress_index)
                 if is_placed_order:
-                    NewGCancelBigNumComputer().set_trade_progress(code, order_begin_pos.buy_single_index,
-                                                                  buy_progress_index)
+                    # NewGCancelBigNumComputer().set_trade_progress(code, order_begin_pos.buy_single_index,
+                    #                                               buy_progress_index)
                     LCancelBigNumComputer().set_trade_progress(code, order_begin_pos.buy_single_index,
                                                                buy_progress_index,
                                                                total_datas)
@@ -221,11 +284,10 @@
                                                                 cancel_type=trade_constant.CANCEL_TYPE_W)
                         except:
                             pass
-
-                    SCancelBigNumComputer().set_transaction_index(code, order_begin_pos.buy_single_index,
-                                                                  buy_progress_index)
-                    HourCancelBigNumComputer().set_transaction_index(code, order_begin_pos.buy_single_index,
-                                                                     buy_progress_index)
+                    # SCancelBigNumComputer().set_transaction_index(code, order_begin_pos.buy_single_index,
+                    #                                               buy_progress_index)
+                    # HourCancelBigNumComputer().set_transaction_index(code, order_begin_pos.buy_single_index,
+                    #                                                  buy_progress_index)
             else:
                 pass
             if is_placed_order:
@@ -239,5 +301,140 @@
         finally:
             use_time = int((time.time() - __start_time) * 1000)
             if use_time > 5:
-                async_log_util.info(hx_logger_l2_upload,
-                                    f"{code}澶勭悊鎴愪氦鐢ㄦ椂锛歿use_time} 鏁版嵁鏁伴噺锛歿len(datas)}  璇︽儏:{use_time_list}")
+                l2_log.info(code, hx_logger_l2_upload,
+                            f"{code}澶勭悊鎴愪氦鐢ㄦ椂锛歿use_time} 鏁版嵁鏁伴噺锛歿len(fdatas)}  璇︽儏:{use_time_list}")
+
+    @classmethod
+    def process_huaxin_transaction_datas_v2(cls, code, o_datas):
+        """
+        鏂扮増澶勭悊鍗庨懌鎴愪氦鏁版嵁锛�
+        灏氭湭涓嬪崟鐨勬椂鍊欏紓姝ョ粺璁℃垚浜わ紝鍚屾閬嶅巻鑾峰彇鏈�鍚庝竴涓定鍋滃崠濮旀墭鏁版嵁锛屽綋鏈�鍚庝竴涓定鍋滃崠鎴愪氦鐨勬椂鍊欏氨鏄笅鍗曟椂鏈�
+        @param code:
+        @param o_datas:
+        @return:
+        """
+
+        def __process_placed_order():
+            """
+            澶勭悊澶勪簬涓嬪崟鐘舵�佺殑鏁版嵁
+            @return:
+            """
+            try:
+                cls.statistic_big_order_infos(code, fdatas, order_begin_pos)
+            except Exception as e:
+                async_log_util.error(hx_logger_l2_debug, f"缁熻澶у崟鍑洪敊锛歿str(e)}")
+            # 缁熻杩炵画鐨勫崠鍗曟暟鎹紝鐢ㄤ簬鎾ゅ崟锛屽彧鏈夊綋涓嬪崟涔嬪悗鎵嶄細鎵ц
+            big_sell_order_info = HuaXinSellOrderStatisticManager.statistic_continue_limit_up_sell_transaction_datas(
+                code, fdatas,
+                limit_up_price)
+            LCancelBigNumComputer().set_big_sell_order_info(code, big_sell_order_info)
+            need_cancel, cancel_msg = False, ""
+            cancel_type = None
+            if not need_cancel:
+                need_cancel, cancel_msg = FCancelBigNumComputer().need_cancel_for_p(code,
+                                                                                    order_begin_pos)
+                cancel_type = trade_constant.CANCEL_TYPE_P
+            if need_cancel:
+                L2TradeDataProcessor.cancel_buy(code, cancel_msg, cancel_type=cancel_type)
+            # 缁熻娑ㄥ仠涓诲姩鍗栨垚浜わ紝涓轰簡F鎾ゅ噯澶囨暟鎹�
+            HuaXinSellOrderStatisticManager.statistic_active_sell_deal_volume(code, fdatas, limit_up_price)
+            # 璁$畻鎴愪氦杩涘害
+            buy_progress_index = cls.__compute_latest_trade_progress(code, fdatas)
+            if buy_progress_index is not None:
+                total_datas = l2_data_util.local_today_datas.get(code)
+                buy_progress_index_changed = cls.__TradeBuyQueue.set_traded_index(code, buy_progress_index,
+                                                                                  total_datas)
+                async_log_util.info(logger_l2_trade_buy_queue, "鑾峰彇鎴愪氦浣嶇疆鎴愬姛锛� code-{} index-{}", code,
+                                    buy_progress_index)
+                if is_placed_order:
+                    LCancelBigNumComputer().set_trade_progress(code, order_begin_pos.buy_single_index,
+                                                               buy_progress_index,
+                                                               total_datas)
+                    cancel_result = FCancelBigNumComputer().need_cancel_for_deal_fast(code, buy_progress_index)
+                    if cancel_result[0]:
+                        L2TradeDataProcessor.cancel_buy(code, f"F鎾�:{cancel_result[1]}",
+                                                        cancel_type=trade_constant.CANCEL_TYPE_F)
+
+        limit_up_price = gpcode_manager.get_limit_up_price_as_num(code)
+        # =====鏍煎紡鍖栨暟鎹�=====
+        # 鏁村舰鏁版嵁锛屾牸寮忥細[(鏁版嵁鏈韩, 鏄惁涓诲姩涔�, 鏄惁娑ㄥ仠, 鎬绘垚浜ら, 涓嶅惈ms鏃堕棿锛屽惈ms鏃堕棿)]
+        use_time_list = []
+        __start_time = int(time.time() * 1000)
+        fdatas = [
+            [d, d[6] > d[7], limit_up_price == d[1], d[1] * d[2], '', '']
+            for d in o_datas]
+        temp_time_dict = {}
+        for d in fdatas:
+            if d[0][3] not in temp_time_dict:
+                temp_time_dict[d[0][3]] = l2_huaxin_util.convert_time(d[0][3], with_ms=True)
+            d[5] = temp_time_dict.get(d[0][3])
+            d[4] = d[5][:8]
+        temp_time_dict.clear()
+        _start_time = int(time.time() * 1000)
+        use_time_list.append((_start_time - __start_time, "鏁版嵁鏁村舰"))
+
+        try:
+
+            # ======闇�瑕佸悓姝ュ鐞嗙殑鏁版嵁========
+            # 璁剧疆鎴愪氦浠�
+            try:
+                current_price_process_manager.set_trade_price(code, fdatas[-1][0][1])
+                if not fdatas[-1][2]:
+                    # 娌℃湁娑ㄥ仠
+                    EveryLimitupBigDealOrderManager.open_limit_up(code, f"鏈�鏂版垚浜や环锛歿fdatas[-1][0][1]}")
+                    radical_buy_strategy.clear_data(code)
+            except:
+                pass
+
+            # 缁熻涓婃澘鏃堕棿
+            try:
+                last_data = fdatas[-1]
+                if last_data[1] and last_data[2]:
+                    # 娑ㄥ仠涓诲姩涔�
+                    current_price_process_manager.set_latest_not_limit_up_time(code, last_data[5])
+                elif not last_data[1] and last_data[2]:
+                    # 娑ㄥ仠涓诲姩鍗�
+                    L2LimitUpSellDataManager.clear_data(code)
+            except:
+                pass
+
+            # ==========澶勪簬濮旀墭鐘舵�佸氨鍚屾澶勭悊鏁版嵁锛屾病鏈変笅杩囧崟灏卞紓姝ュ鐞嗘暟鎹�==========
+            order_begin_pos = l2_data_manager.TradePointManager().get_buy_compute_start_data_cache(code)
+            is_placed_order = l2_data_manager.TradePointManager.is_placed_order(order_begin_pos)
+            if is_placed_order:
+                # 涓嬭繃鍗曚簡
+                __process_placed_order()
+            else:
+                filter_datas = L2TradeSingleDataProcessor.filter_last_limit_up_sell_data(code, fdatas)
+                _start_time = int(time.time() * 1000)
+                use_time_list.append((_start_time - __start_time, "澶勭悊娑ㄥ仠鍗�"))
+                # 鍥炶皟鏁版嵁
+                if filter_datas is not None:
+                    l2_log.info(code, logger_l2_trade, f"鏈�鍚庝竴绗旀定鍋滃崠琚悆锛歿filter_datas[0]}")
+                    data_callback.l2_trade_single_callback.OnLastLimitUpSellDeal(code, filter_datas[0][0])
+
+                    _start_time = int(time.time() * 1000)
+                    use_time_list.append((_start_time - __start_time, "澶勭悊涔板叆淇″彿"))
+
+                # 濡傛灉鏄鍔ㄤ拱灏辨洿鏂版垚浜よ繘搴�
+                if not fdatas[-1][1]:
+                    buy_progress_index = cls.__compute_latest_trade_progress(code, fdatas)
+                    if buy_progress_index is not None:
+                        total_datas = l2_data_util.local_today_datas.get(code)
+                        cls.__TradeBuyQueue.set_traded_index(code, buy_progress_index,
+                                                             total_datas)
+                # 濡傛灉鏁版嵁閲忓ぇ浜�20鏉″氨閲囩敤绾跨▼姹犳洿鏂版暟鎹�
+                if len(fdatas) >= 20:
+                    cls.__statistic_thread_pool.submit(cls.statistic_big_order_infos, code, fdatas, order_begin_pos)
+                else:
+                    cls.statistic_big_order_infos(code, fdatas, order_begin_pos)
+
+                _start_time = int(time.time() * 1000)
+                use_time_list.append((_start_time - __start_time, "缁熻澶у崟"))
+        except Exception as e:
+            hx_logger_l2_debug.exception(e)
+        finally:
+            _start_time = int(time.time() * 1000)
+            if _start_time - __start_time > 5:
+                l2_log.info(code, hx_logger_l2_upload,
+                            f"{code}澶勭悊鎴愪氦鐢ㄦ椂锛歿_start_time - __start_time} 鏁版嵁鏁伴噺锛歿len(fdatas)}  璇︽儏:{use_time_list}")

--
Gitblit v1.8.0