From d2a4dd9c837f8df2a19e58f7fb4c81a91c114b67 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期五, 15 八月 2025 13:15:32 +0800
Subject: [PATCH] 自动加想接口

---
 l2/l2_transaction_data_processor.py |   32 ++++++++++++++++++++++++++------
 1 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/l2/l2_transaction_data_processor.py b/l2/l2_transaction_data_processor.py
index 2a62378..e7fa00b 100644
--- a/l2/l2_transaction_data_processor.py
+++ b/l2/l2_transaction_data_processor.py
@@ -22,12 +22,12 @@
 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, \
     logger_trade, logger_l2_trade
-from trade import current_price_process_manager, trade_constant
+from trade import current_price_process_manager, trade_constant, trade_manager
 import concurrent.futures
 
 from trade.buy_radical import radical_buy_strategy
 from trade.buy_radical.radical_buy_data_manager import RadicalBuyDataManager, EveryLimitupBigDealOrderManager
-from utils import tool
+from utils import tool, trade_util
 
 
 class HuaXinTransactionDatasProcessor:
@@ -35,6 +35,8 @@
     __TradeBuyQueue = transaction_progress.TradeBuyQueue()
     # 闈炴定鍋滄垚浜ゆ椂闂�
     __not_limit_up_time_dict = {}
+    # 鏈�杩戞垚浜ゆ暟鎹瓧鍏�
+    __latest_transaction_data_dict = {}
 
     # 璁$畻鎴愪氦杩涘害
     @classmethod
@@ -178,6 +180,8 @@
         # q.append((data['SecurityID'], data['TradePrice'], data['TradeVolume'],
         #                   data['OrderTime'], data['MainSeq'], data['SubSeq'], data['BuyNo'],
         #                   data['SellNo'], data['ExecType']))
+        if o_datas:
+            cls.__latest_transaction_data_dict[code] = o_datas[-1]
         fdatas = [
             [d, d[6] > d[7], limit_up_price == d[1], d[1] * d[2], '', '']
             for d in o_datas]
@@ -288,13 +292,17 @@
             # if big_money_count > 0:
             #     LCancelRateManager.compute_big_num_deal_rate(code)
 
+            trade_state = trade_manager.CodesTradeStateManager().get_trade_state_cache(code)
+            # 璁$畻鎴愪氦杩涘害
             buy_progress_index, is_similar = cls.__compute_latest_trade_progress(code, fdatas,
-                                                                                 order_begin_pos.buy_exec_index)
+                                                                                 order_begin_pos.buy_exec_index if trade_util.is_delegated(
+                                                                                     trade_state) else -1)
 
             if buy_progress_index is not None:
                 buy_progress_index_changed = cls.__TradeBuyQueue.set_traded_index(code, buy_progress_index,
                                                                                   total_datas)
-                l2_log.info(code, logger_l2_trade_buy_queue, "鑾峰彇鎴愪氦浣嶇疆鎴愬姛锛� code-{} index-{} is_similar-{}", code, buy_progress_index, is_similar)
+                l2_log.info(code, logger_l2_trade_buy_queue, "鑾峰彇鎴愪氦浣嶇疆鎴愬姛锛� code-{} index-{} is_similar-{}", code,
+                            buy_progress_index, is_similar)
                 if is_placed_order:
                     # NewGCancelBigNumComputer().set_trade_progress(code, order_begin_pos.buy_single_index,
                     #                                               buy_progress_index)
@@ -376,9 +384,11 @@
                 L2TradeDataProcessor.cancel_buy(code, cancel_msg, cancel_type=cancel_type)
             # 缁熻娑ㄥ仠涓诲姩鍗栨垚浜わ紝涓轰簡F鎾ゅ噯澶囨暟鎹�
             HuaXinSellOrderStatisticManager.statistic_active_sell_deal_volume(code, fdatas, limit_up_price)
+            trade_state = trade_manager.CodesTradeStateManager().get_trade_state_cache(code)
             # 璁$畻鎴愪氦杩涘害
             _buy_progress_index, _is_similar = cls.__compute_latest_trade_progress(code, fdatas,
-                                                                                   order_begin_pos.buy_exec_index)
+                                                                                   order_begin_pos.buy_exec_index if trade_util.is_delegated(
+                                                                                       trade_state) else -1)
             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,
@@ -394,6 +404,8 @@
                         L2TradeDataProcessor.cancel_buy(code, f"F鎾�:{cancel_result[1]}",
                                                         cancel_type=trade_constant.CANCEL_TYPE_F)
 
+        if o_datas:
+            cls.__latest_transaction_data_dict[code] = o_datas[-1]
         limit_up_price = gpcode_manager.get_limit_up_price_as_num(code)
         # =====鏍煎紡鍖栨暟鎹�=====
         # 鏁村舰鏁版嵁锛屾牸寮忥細[(鏁版嵁鏈韩, 鏄惁涓诲姩涔�, 鏄惁娑ㄥ仠, 鎬绘垚浜ら, 涓嶅惈ms鏃堕棿锛屽惈ms鏃堕棿)]
@@ -457,7 +469,11 @@
 
                 # 濡傛灉鏄鍔ㄤ拱灏辨洿鏂版垚浜よ繘搴�
                 if not fdatas[-1][1]:
-                    buy_progress_index, is_similar = cls.__compute_latest_trade_progress(code, fdatas)
+                    trade_state = trade_manager.CodesTradeStateManager().get_trade_state_cache(code)
+                    # 璁$畻鎴愪氦杩涘害
+                    buy_progress_index, is_similar = cls.__compute_latest_trade_progress(code, fdatas,
+                                                                                         order_begin_pos.buy_exec_index if trade_util.is_delegated(
+                                                                                             trade_state) else -1)
                     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,
@@ -477,3 +493,7 @@
             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}")
+
+    @classmethod
+    def get_latest_transaction_data(cls, code):
+        return cls.__latest_transaction_data_dict.get(code)
\ No newline at end of file

--
Gitblit v1.8.0