From 1176a493039ded49d888b451793bc272e18a9b5a Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期二, 02 四月 2024 14:16:05 +0800
Subject: [PATCH] 激进买

---
 l2/l2_data_manager.py               |    1 
 l2/l2_transaction_data_processor.py |    3 
 constant.py                         |    2 
 l2/cancel_buy_strategy.py           |   57 +++++++-
 l2/l2_data_manager_new.py           |  269 +++++++++++++++++++++++++++++++++++---
 trade/trade_record_log_util.py      |    6 
 l2/l2_transaction_data_manager.py   |   32 ++++
 output/code_info_output.py          |    7 
 8 files changed, 341 insertions(+), 36 deletions(-)

diff --git a/constant.py b/constant.py
index a77211e..0109af0 100644
--- a/constant.py
+++ b/constant.py
@@ -157,7 +157,7 @@
 ########鍗庨懌閰嶇疆########
 if not is_windows() or True:
     # 涓嬪崟1鎵�
-    BUY_MONEY_PER_CODE = 500 if constant.IS_A else 20000
+    BUY_MONEY_PER_CODE = 500 if constant.IS_A else 500
     L2_SOURCE_TYPE = L2_SOURCE_TYPE_HUAXIN
     JUEJIN_LOCAL_API = False
     TRADE_WAY = TRADE_WAY_HUAXIN
diff --git a/l2/cancel_buy_strategy.py b/l2/cancel_buy_strategy.py
index 82308bd..698af81 100644
--- a/l2/cancel_buy_strategy.py
+++ b/l2/cancel_buy_strategy.py
@@ -234,11 +234,54 @@
             self.__s_down_watch_indexes_dict[code] = (latest_deal_time, watch_indexes)
 
     # 鏄惁鏈夊ぇ鍗栧崟闇�瑕佹挙
-    def __need_cancel_for_big_sell_order(self, code, big_sell_order_info):
+    def __need_cancel_for_big_sell_order(self, code, big_sell_order_info, order_begin_pos: OrderBeginPosInfo):
         total_deal_money = sum([x[1] * x[2] for x in big_sell_order_info[1]])
-        if total_deal_money >= 299 * 10000:
-            return True, f"杩�1s鏈夊ぇ鍗栧崟({round(total_deal_money / 10000, 1)}涓�/299涓�)"
-        return False, "鏃�299澶у崟"
+        # 鍒ゆ柇鏄惁涓烘縺杩涗笅鍗�
+        threash_money_w = 299
+        if order_begin_pos.mode == OrderBeginPosInfo.MODE_ACTIVE:
+            try:
+                total_datas = local_today_datas.get(code)
+                # 鐪熷疄鎴愪氦浣嶈窛绂荤湡瀹炰笅鍗曚綅锛�10绗斾互鍐呬笖閲戦鈮�1000涓� , 涓斿湪180s鍐�
+                trade_index, is_default = TradeBuyQueue().get_traded_index(code)
+                if trade_index is None:
+                    trade_index = 0
+                real_order_index_info = self.__get_real_place_order_index_info_cache(code)
+                limit_up_price = gpcode_manager.get_limit_up_price(code)
+                if real_order_index_info and not real_order_index_info[1]:
+                    real_order_index = real_order_index_info[0]
+                    start_order_no = big_sell_order_info[1][-1][4][1]
+                    sell_time_str = l2_huaxin_util.convert_time(big_sell_order_info[1][-1][4][0], with_ms=False)
+                    if tool.trade_time_sub(sell_time_str, total_datas[real_order_index]["val"]["time"]) < 180:
+                        total_num = 0
+                        total_count = 0
+                        # 鑾峰彇姝e湪鎴愪氦鐨勬暟鎹�
+                        dealing_info = HuaXinBuyOrderManager.get_dealing_order_info(code)
+                        for i in range(trade_index, real_order_index):
+                            data = total_datas[i]
+                            val = data['val']
+                            if int(val['orderNo']) < start_order_no:
+                                continue
+                            if i == trade_index and dealing_info and str(
+                                    total_datas[trade_index]["val"]["orderNo"]) == str(
+                                dealing_info[0]):
+                                # 鍑忓幓褰撳墠姝e湪鎴愪氦鐨勬暟鎹腑宸茬粡鎴愪氦浜嗙殑鏁版嵁
+                                total_num -= dealing_info[1] // 100
+                            left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(
+                                code,
+                                i,
+                                total_datas,
+                                local_today_canceled_buyno_map.get(
+                                    code))
+                            if left_count > 0:
+                                total_num += val["num"]
+                                total_count += 1
+                        if total_count <= 10 and total_num * float(limit_up_price) < 1000 * 100:
+                            threash_money_w = 200
+            except Exception as e:
+                l2_log.s_cancel_debug(code, f"S鎾ゆ縺杩涗笅鍗曡绠楀ぇ鍗曞崠闃堝�煎嚭閿欙細{str(e)}")
+        if total_deal_money >= threash_money_w * 10000:
+            return True, f"杩�1s鏈夊ぇ鍗栧崟({round(total_deal_money / 10000, 1)}涓�/{threash_money_w}涓�)"
+        return False, f"鏃爗threash_money_w}澶у崟"
 
     #  big_sell_order_info鏍煎紡锛歔鎬诲叡鐨勫崠鍗曢噾棰�, 澶у崠鍗曡鎯呭垪琛╙
     def set_big_sell_order_info_for_cancel(self, code, big_sell_order_info, order_begin_pos: OrderBeginPosInfo):
@@ -248,7 +291,7 @@
         if big_sell_order_info[0] < 500000 or not big_sell_order_info[1]:
             return False, "鏃犲ぇ鍗曞崠"
         try:
-            need_cancel, cancel_msg = self.__need_cancel_for_big_sell_order(code, big_sell_order_info)
+            need_cancel, cancel_msg = self.__need_cancel_for_big_sell_order(code, big_sell_order_info, order_begin_pos)
             if need_cancel:
                 return need_cancel, cancel_msg
 
@@ -1952,7 +1995,7 @@
             return False, None, "娌℃湁鐪熷疄涓嬪崟浣嶇疆"
         trade_index, is_default = TradeBuyQueue().get_traded_index(code)
         if trade_index is None:
-            return False,None, "鏈幏鍙栧埌鎴愪氦杩涘害浣�"
+            return False, None, "鏈幏鍙栧埌鎴愪氦杩涘害浣�"
         total_datas = local_today_datas.get(code)
         buyno_map = local_today_buyno_map.get(code)
         cancel_half_index = None
@@ -1973,7 +2016,7 @@
                 cancel_half_index = i
                 break
         if cancel_half_index is None:
-            return False,None, "娌℃湁鎾ゅ崐鎴�"
+            return False, None, "娌℃湁鎾ゅ崐鎴�"
         # 鏈夊ぇ鍗曟挙鍗婃埅妗�
         # 璁$畻鏄惁杩樺墿涓嬪ぇ鍗�
         total_big_num_count = 0
diff --git a/l2/l2_data_manager.py b/l2/l2_data_manager.py
index eda05d7..6d119a1 100644
--- a/l2/l2_data_manager.py
+++ b/l2/l2_data_manager.py
@@ -16,6 +16,7 @@
 class OrderBeginPosInfo(object):
     MODE_NORMAL = 0
     MODE_FAST = 1
+    MODE_ACTIVE = 2
 
     # mode: 0-鏅�氫氦鏄�  1-蹇�熶氦鏄�
     def __init__(self, buy_single_index=None, buy_exec_index=-1, buy_compute_index=None, num=0, count=0,
diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py
index 4b99ef7..64f08e2 100644
--- a/l2/l2_data_manager_new.py
+++ b/l2/l2_data_manager_new.py
@@ -10,6 +10,7 @@
 from db.redis_manager_delegate import RedisUtils
 from l2.huaxin import l2_huaxin_util, huaxin_delegate_postion_manager
 from l2.l2_sell_manager import L2MarketSellManager, L2LimitUpSellManager
+from l2.l2_transaction_data_manager import HuaXinSellOrderStatisticManager
 from l2.transaction_progress import TradeBuyQueue
 from log_module import async_log_util, log_export
 from third_data import kpl_data_manager, block_info, history_k_data_util
@@ -677,6 +678,7 @@
                     info = cls.__trade_log_placr_order_info_dict[code]
                     info.mode = order_begin_pos.mode
                     info.set_buy_index(order_begin_pos.buy_single_index, order_begin_pos.buy_exec_index)
+                    info.set_sell_info(order_begin_pos.sell_info)
                     if jx_blocks:
                         info.set_kpl_blocks(list(jx_blocks))
                     elif jx_blocks_by:
@@ -690,7 +692,11 @@
                         elif not can_buy_result[0] and not can_buy_result[1]:
                             info.set_kpl_match_blocks(["闈炵嫭鑻椾笉婊¤冻韬綅"])
                         else:
-                            info.set_kpl_match_blocks(can_buy_result[0])
+                            temps = []
+                            temps.extend(can_buy_result[0])
+                            if can_buy_result[5]:
+                                temps.append(f"婵�杩涗拱鍏ワ細{can_buy_result[5]}")
+                            info.set_kpl_match_blocks(temps)
                     trade_record_log_util.add_place_order_log(code, info)
                 except Exception as e:
                     async_log_util.error(logger_l2_error, f"鍔犲叆涔板叆璁板綍鏃ュ織鍑洪敊锛歿str(e)}")
@@ -1295,24 +1301,36 @@
         new_get_single = False
         buy_single_index = order_begin_pos.buy_single_index
         if buy_single_index is None:
-            # 灏濊瘯璁$畻蹇�熸垚浜や俊鍙�
-            has_single, _index, sell_info = cls.__compute_fast_order_begin_pos(code, compute_start_index,
-                                                                               compute_end_index)
+            # ------------------------------纭畾淇″彿绉嶇被----------------------------------
+            # 绗竴姝ワ細鑾峰彇婵�杩涗笅鍗曚俊鍙�
+            continue_count = cls.__l2PlaceOrderParamsManagerDict[code].get_begin_continue_buy_count()
+            has_single, _index, sell_info = cls.__compute_active_order_begin_pos(code, continue_count, max(
+                (compute_start_index - continue_count - 1) if new_add else compute_start_index, 0), compute_end_index)
             fast_msg = None
             if has_single:
-                order_begin_pos.mode = OrderBeginPosInfo.MODE_FAST
+                order_begin_pos.mode = OrderBeginPosInfo.MODE_ACTIVE
                 order_begin_pos.sell_info = sell_info
-            elif _index is not None and _index < 0:
                 fast_msg = sell_info
-                continue_count = cls.__l2PlaceOrderParamsManagerDict[code].get_begin_continue_buy_count()
-                # 鏈変拱鍏ヤ俊鍙�
-                has_single, _index = cls.__compute_order_begin_pos(code, max(
-                    (compute_start_index - continue_count - 1) if new_add else compute_start_index, 0), continue_count,
-                                                                   compute_end_index)
-                order_begin_pos.mode = OrderBeginPosInfo.MODE_NORMAL
-                # 鑾峰彇鏈�鏂扮殑涔颁俊鎭�
-                sell_info = cls.__L2MarketSellManager.get_current_total_sell_data(code)
-                order_begin_pos.sell_info = sell_info
+
+            if not has_single:
+                # 绗簩姝ワ細璁$畻闂數涓嬪崟淇″彿
+                has_single, _index, sell_info = cls.__compute_fast_order_begin_pos(code, compute_start_index,
+                                                                                   compute_end_index)
+                fast_msg = None
+                if has_single:
+                    order_begin_pos.mode = OrderBeginPosInfo.MODE_FAST
+                    order_begin_pos.sell_info = sell_info
+                elif _index is not None and _index < 0:
+                    fast_msg = sell_info
+                    # 绗笁姝�: 璁$畻甯歌涔板叆淇″彿
+                    has_single, _index = cls.__compute_order_begin_pos(code, max(
+                        (compute_start_index - continue_count - 1) if new_add else compute_start_index, 0),
+                                                                       continue_count,
+                                                                       compute_end_index)
+                    order_begin_pos.mode = OrderBeginPosInfo.MODE_NORMAL
+                    # 鑾峰彇鏈�鏂扮殑涔颁俊鎭�
+                    sell_info = cls.__L2MarketSellManager.get_current_total_sell_data(code)
+                    order_begin_pos.sell_info = sell_info
             # 濡傛灉涔板叆淇″彿涓庝笂娆$殑涔板叆淇″彿涓�鏍峰氨涓嶈兘绠楁柊鐨勪俊鍙�
             if cls.__last_buy_single_dict.get(code) == _index:
                 has_single = None
@@ -1350,20 +1368,14 @@
                                          f"鑾峰彇鐨勪俊鍙蜂綅鏃犳晥锛堟澘涓婁拱锛岃寖鍥达細{trade_index + 1}-{order_begin_pos.buy_single_index} 鏈垚浜ゆ�绘墜{total_num}/闃堝�納thresh_hold_num}锛�")
                             return None
 
+                # -----------------------------涔板叆璁$畻鍒濆鍖�,璁$畻绾拱棰濋槇鍊�-----------------------
                 cls.__last_buy_single_dict[code] = buy_single_index
                 new_get_single = True
                 order_begin_pos.num = 0
                 order_begin_pos.count = 0
                 order_begin_pos.buy_single_index = buy_single_index
+                # 璋冩暣闂數涓嬪崟鐨勪拱鍏ラ槇鍊�
                 if order_begin_pos.sell_info and order_begin_pos.mode == OrderBeginPosInfo.MODE_FAST:
-                    # k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code)
-                    # if k_format and (k_format[1][0] or k_format[3][0]):
-                    #     # 鑲′环鏂伴珮鎴栬�呴�艰繎鍓嶉珮
-                    #     order_begin_pos.threshold_money = int(sell_info[1])
-                    # else:
-                    # if float(total_datas[buy_single_index]["val"]["price"]) >= 3 and cls.volume_rate_info[code][
-                    #     0] > 0.3 and sell_info[1] > 2000 * 10000 and int(
-                    #     tool.get_now_time_str().replace(":", "")) < int("100000"):
                     situation = cls.__MarketSituationManager.get_situation_cache()
                     if sell_info[1] > 2000 * 10000 and situation != MarketSituationManager.SITUATION_GOOD:
                         # 甯傚満琛屾儏濂芥椂涓嶆墦鎶�
@@ -1379,6 +1391,10 @@
                             order_begin_pos.threshold_money = int(sell_info[1] * 0.8)
                     else:
                         order_begin_pos.threshold_money = int(sell_info[1])
+                if order_begin_pos.sell_info and order_begin_pos.mode == OrderBeginPosInfo.MODE_ACTIVE:
+                    # 鎬诲崠棰濈殑1.5鍊�
+                    order_begin_pos.threshold_money = int(sell_info[1] * 1.5)
+
                 l2_log.debug(code, "鑾峰彇鍒颁拱鍏ヤ俊鍙疯捣濮嬬偣锛歿} ,璁$畻鑼冨洿锛歿}-{} 锛岄噺姣旓細{}锛屾槸鍚︽澘涓婁拱锛歿}锛屾暟鎹細{} 妯″紡锛歿}锛坽}锛�", buy_single_index,
                              compute_start_index,
                              compute_end_index, cls.volume_rate_info[code], order_begin_pos.at_limit_up,
@@ -1404,7 +1420,19 @@
 
         # 涔板叆绾拱棰濈粺璁�
         new_buy_exec_index, buy_nums, buy_count, rebegin_buy_pos, max_num_set_new, not_buy_msg = None, None, None, None, [], ""
-        if order_begin_pos.mode == OrderBeginPosInfo.MODE_FAST:
+        if order_begin_pos.mode == OrderBeginPosInfo.MODE_ACTIVE:
+            threshold_money = order_begin_pos.threshold_money
+            new_buy_exec_index, buy_nums, buy_count, rebegin_buy_pos, threshold_money_new, max_num_set_new, not_buy_msg = cls.__sum_buy_num_for_order_active(
+                code,
+                start_process_index,
+                compute_end_index,
+                order_begin_pos.num,
+                order_begin_pos.count,
+                threshold_money,
+                order_begin_pos.buy_single_index, order_begin_pos.max_num_set)
+            threshold_money = threshold_money_new
+            order_begin_pos.threshold_money = threshold_money
+        elif order_begin_pos.mode == OrderBeginPosInfo.MODE_FAST:
 
             threshold_money = order_begin_pos.threshold_money
             new_buy_exec_index, buy_nums, buy_count, rebegin_buy_pos, threshold_money_new, max_num_set_new, not_buy_msg = cls.__sum_buy_num_for_order_fast(
@@ -1604,6 +1632,71 @@
             if is_first_limit_up:
                 return True, i, [refer_sell_data[0], threshold_money]
         return False, None, None
+
+    # 璁$畻婵�杩涗拱鐨勪笅鍗曚俊鍙�
+    @classmethod
+    def __compute_active_order_begin_pos(cls, code, continue_count, start_index, end_index):
+        total_datas = local_today_datas[code]
+        start_time_str = total_datas[start_index]["val"]["time"]
+        # 鑾峰彇鏈�杩戠殑鎬诲崠淇℃伅
+        refer_sell_data = cls.__L2MarketSellManager.get_refer_sell_data(code, start_time_str)
+        if refer_sell_data is None:
+            return False, -1, "鎬诲崠涓虹┖"
+        # 鑾峰彇褰撳墠鏄惁鍙縺杩涗拱
+        # 鑾峰彇鏉垮潡鏄惁鍙互婵�杩涗拱
+        # 鍙拱鐨勬澘鍧�, 鏄惁鐙嫍, 娑堟伅, 鍙拱鐨勫己鍔挎澘鍧�, 鍏抽敭璇�, 婵�杩涗拱鐨勬澘鍧�
+        can_buy_result = CodePlateKeyBuyManager.can_buy(code)
+        if can_buy_result and can_buy_result[0] and can_buy_result[5]:
+            # 鏈夊彲涔版澘鍧楋紝鏈夋縺杩涗拱鏉垮潡
+            # 绗竴姝ワ細 璁$畻鎬诲崠棰�
+            threshold_money = refer_sell_data[1]
+            for i in range(start_index - 1, -1, -1):
+                val = total_datas[i]["val"]
+                if tool.compare_time(val["time"], refer_sell_data[0]) <= 0:
+                    break
+                if L2DataUtil.is_sell(val):
+                    threshold_money += val["num"] * int(float(val["price"]) * 100)
+                elif L2DataUtil.is_sell_cancel(val):
+                    threshold_money -= val["num"] * int(float(val["price"]) * 100)
+            # 绗簩姝ワ細璁$畻璧峰淇″彿
+            second_930 = 9 * 3600 + 30 * 60 + 0
+            total_datas = local_today_datas.get(code)
+            if end_index - start_index + 1 < continue_count:
+                return False, -1, "淇″彿涓嶈繛缁�"
+            last_index = None
+            count = 0
+            start = None
+            for i in range(start_index, end_index + 1):
+                _val = total_datas[i]["val"]
+                time_s = L2DataUtil.get_time_as_second(_val["time"])
+                # 鏃堕棿瑕�>=09:30:00
+                if time_s < second_930:
+                    continue
+                if L2DataUtil.is_limit_up_price_buy(_val):
+                    # 閲戦瑕佸ぇ浜�50涓�
+                    if _val["num"] * float(_val["price"]) < 5000:
+                        continue
+                    if last_index is None or (total_datas[last_index]["val"]["time"] == total_datas[i]["val"]["time"]):
+                        if start is None:
+                            start = i
+                        last_index = i
+                        count += total_datas[i]["re"]
+                        if count >= continue_count:
+                            return True, start, [refer_sell_data[0], threshold_money]
+                    else:
+                        # 鏈潯鏁版嵁浣滀负璧风偣
+                        last_index = i
+                        count = datas[i]["re"]
+                        start = i
+
+                elif not L2DataUtil.is_sell(_val) and not L2DataUtil.is_sell_cancel(_val):
+                    # 鍓旈櫎鍗栦笌鍗栨挙
+                    last_index = None
+                    count = 0
+                    start = None
+            return False, -1, "鏈幏鍙栧埌婵�杩涗拱鐨勮捣濮嬩俊鍙�"
+        else:
+            return False, -1, "涓嶅彲婵�杩涗拱"
 
     @classmethod
     def __get_threshmoney(cls, code):
@@ -1949,6 +2042,134 @@
 
         return None, buy_nums, buy_count, None, threshold_money, max_buy_num_set, not_buy_msg
 
+    # 杩斿洖(涔板叆鎵ц鐐�, 鎬绘墜, 鎬荤瑪鏁�, 浠庢柊璁$畻璧风偣, 绾拱棰濋槇鍊�)
+    # 璁$畻婵�杩涗拱鍏�
+    @classmethod
+    def __sum_buy_num_for_order_active(cls, code, compute_start_index, compute_end_index, origin_num, origin_count,
+                                       threshold_money_origin, buy_single_index, max_num_set):
+        _start_time = t.time()
+        total_datas = local_today_datas[code]
+        # is_first_code = gpcode_manager.FirstCodeManager().is_in_first_record_cache(code)
+
+        buy_nums = origin_num
+        buy_count = origin_count
+        limit_up_price = gpcode_manager.get_limit_up_price(code)
+        if limit_up_price is None:
+            raise Exception("娑ㄥ仠浠锋棤娉曡幏鍙�")
+        limit_up_price = float(limit_up_price)
+
+        threshold_money = threshold_money_origin
+        # 鐩爣鎵嬫暟
+        threshold_num = round(threshold_money / (limit_up_price * 100))
+
+        # buy_single_time_seconds = L2DataUtil.get_time_as_second(total_datas[buy_single_index]["val"]["time"])
+
+        # 鍙互瑙﹀彂涔帮紝褰撴湁娑ㄥ仠涔颁俊鍙锋椂鎵嶄細瑙﹀彂涔�
+        trigger_buy = True
+        # 闂撮殧鏈�澶ф椂闂翠负3s
+        max_space_time_ms = 3 * 1000
+        # 涓嶄笅鍗曠殑淇℃伅
+        not_buy_msg = ""
+        max_buy_num_set = set(max_num_set)
+        for i in range(compute_start_index, compute_end_index + 1):
+            data = total_datas[i]
+            _val = total_datas[i]["val"]
+            trigger_buy = False
+            # 蹇呴』涓鸿繛缁�2绉掑唴鐨勬暟鎹�
+            if L2DataUtil.time_sub_as_ms(_val, total_datas[buy_single_index]["val"]) > max_space_time_ms:
+                cls.__TradePointManager.delete_buy_point(code)
+                if i == compute_end_index:
+                    # 鏁版嵁澶勭悊瀹屾瘯
+                    return None, buy_nums, buy_count, None, threshold_money, max_buy_num_set, f"銆恵i}銆戜俊鍙蜂笉杩炵画锛屽泭鎷椂闂�-{max_space_time_ms}ms"
+                else:
+                    # 璁$畻涔板叆淇″彿锛屼笉鑳藉悓涓�鏃堕棿寮�濮嬭绠�
+                    for ii in range(buy_single_index + 1, compute_end_index + 1):
+                        if total_datas[buy_single_index]["val"]["time"] != total_datas[ii]["val"]["time"]:
+                            return None, buy_nums, buy_count, ii, threshold_money, max_buy_num_set, f"銆恵i}銆戜俊鍙蜂笉杩炵画锛屽泭鎷椂闂�-{max_space_time_ms}ms"
+            if L2DataUtil.is_sell(_val):
+                threshold_money += _val["num"] * int(float(_val["price"]) * 100)
+                threshold_num = round(threshold_money / (limit_up_price * 100))
+            elif L2DataUtil.is_sell_cancel(_val):
+                threshold_money -= _val["num"] * int(float(_val["price"]) * 100)
+                threshold_num = round(threshold_money / (limit_up_price * 100))
+            # 娑ㄥ仠涔�
+            elif L2DataUtil.is_limit_up_price_buy(_val):
+                if l2_data_util.is_big_money(_val):
+                    max_buy_num_set.add(i)
+                trigger_buy = True
+                # 鍙粺璁�59涓囦互涓婄殑閲戦
+                buy_nums += int(_val["num"]) * int(total_datas[i]["re"])
+                buy_count += int(total_datas[i]["re"])
+                if buy_nums >= threshold_num:
+                    l2_log.info(code, logger_l2_trade_buy,
+                                f"{code}鑾峰彇鍒颁拱鍏ユ墽琛岀偣(婵�杩涗笅鍗�)锛歿i} 缁熻绾拱鎵嬫暟锛歿buy_nums} 鐩爣绾拱鎵嬫暟锛歿threshold_num} 缁熻绾拱鍗曟暟锛歿buy_count}")
+            elif L2DataUtil.is_limit_up_price_buy_cancel(_val):
+                # 鍒ゆ柇涔板叆浣嶇疆鏄惁鍦ㄤ拱鍏ヤ俊鍙蜂箣鍓�
+                buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data_v2(total_datas[i],
+                                                                                                    local_today_buyno_map.get(
+                                                                                                        code))
+                if buy_index is not None:
+
+                    # 鎵惧埌涔版挙鏁版嵁鐨勪拱鍏ョ偣
+                    if buy_index >= buy_single_index:
+                        max_buy_num_set.discard(buy_index)
+                        buy_nums -= int(_val["num"]) * int(data["re"])
+                        buy_count -= int(data["re"])
+                        l2_log.buy_debug(code, "{}鏁版嵁鍦ㄤ拱鍏ヤ俊鍙蜂箣鍚� 鎾や拱绾拱鎵嬫暟锛歿} 鐩爣鎵嬫暟锛歿}", i, buy_nums, threshold_num)
+                    else:
+                        l2_log.buy_debug(code, "{}鏁版嵁鍦ㄤ拱鍏ヤ俊鍙蜂箣鍓嶏紝涔板叆浣嶏細{}", i, buy_index)
+                        if total_datas[buy_single_index]["val"]["time"] == total_datas[buy_index]["val"]["time"]:
+                            # 鍚屼竴绉�,褰撲綔涔板叆淇″彿涔嬪悗澶勭悊
+                            buy_nums -= int(_val["num"]) * int(data["re"])
+                            buy_count -= int(data["re"])
+                            max_buy_num_set.discard(buy_index)
+                            # 澶у崟鎾ら攢
+                            l2_log.buy_debug(code, "{}鏁版嵁涔板叆浣嶄笌棰勪及涔板叆浣嶅湪鍚屼竴绉�", i)
+                else:
+                    # 鏈壘鍒颁拱鎾ゆ暟鎹殑涔板叆鐐�
+                    l2_log.buy_debug(code, "鏈壘鍒颁拱鎾ゆ暟鎹殑涔板叆鐐�: 浣嶇疆-{} 鏁版嵁-{}", i, data)
+                    buy_nums -= int(_val["num"]) * int(total_datas[i]["re"])
+                    buy_count -= int(total_datas[i]["re"])
+            l2_log.buy_debug(code, "浣嶇疆-{}锛屾�绘墜鏁帮細{}锛岀洰鏍囨墜鏁帮細{}", i,
+                             buy_nums, threshold_num)
+
+            # 璁$畻淇″彿浣嶇疆涔嬪悗鐨勪富鍔ㄥ崠锛屽姞鍏ュ埌闃堝�间箣涓�
+            sell_orders = HuaXinSellOrderStatisticManager.get_latest_transaction_datas(code, min_sell_order_no=int(
+                total_datas[buy_single_index]['val']['orderNo']))
+            sell_order_num = sum([x[1] for x in sell_orders]) // 100
+            # 绾拱棰濊冻澶燂紝涓旂瑪鏁板ぇ浜�2绗�
+            if buy_nums < threshold_num + sell_order_num:
+                not_buy_msg = f"銆恵i}銆戠函涔伴涓嶅锛寋buy_nums}/{threshold_num}"
+                continue
+            if not trigger_buy:
+                not_buy_msg = f"銆恵i}銆戞病鏈変拱鍗曡Е鍙�"
+                continue
+            if buy_count < 2:
+                not_buy_msg = f"銆恵i}銆戝畨鍏ㄧ瑪鏁颁笉瓒筹紝{buy_count}/{2}"
+                continue
+
+            # max_buy_num_set = cls.__filter_not_deal_indexes(code, max_buy_num_set)
+            # big_money_count_threshhold = cls.__l2PlaceOrderParamsManagerDict[code].get_big_num_count()
+            # if len(max_buy_num_set) < big_money_count_threshhold:
+            #     not_buy_msg = f"銆恵i}銆戝ぇ鍗曚笉婊¤冻瑕佹眰锛岄渶瑕侊細{big_money_count_threshhold} 鎬伙細{len(max_buy_num_set)}"
+            #     continue
+
+            try:
+                info = cls.__trade_log_placr_order_info_dict[code]
+                info.set_trade_factor(threshold_money, 0, [])
+            except Exception as e:
+                async_log_util.error(logger_l2_error, f"璁板綍浜ゆ槗鍥犲瓙鍑洪敊锛歿str(e)}")
+            l2_log.buy_debug(code, f"婵�杩涗拱涓诲姩鍗栨墜鏁帮細{sell_order_num}")
+
+            return i, buy_nums, buy_count, None, threshold_money, max_buy_num_set, "鍙互涓嬪崟"
+
+        l2_log.buy_debug(code, "灏氭湭鑾峰彇鍒颁拱鍏ユ墽琛岀偣(婵�杩涗拱鍏�)锛岃捣濮嬭绠椾綅缃細{} 缁熻绾拱鎵嬫暟锛歿} 鐩爣绾拱鎵嬫暟锛歿}  缁熻绾拱鍗曟暟锛歿} ",
+                         compute_start_index,
+                         buy_nums,
+                         threshold_num, buy_count)
+
+        return None, buy_nums, buy_count, None, threshold_money, max_buy_num_set, not_buy_msg
+
 
 def test_trade_record():
     code = "000333"
diff --git a/l2/l2_transaction_data_manager.py b/l2/l2_transaction_data_manager.py
index 9efb94d..147463e 100644
--- a/l2/l2_transaction_data_manager.py
+++ b/l2/l2_transaction_data_manager.py
@@ -101,6 +101,8 @@
 
     # 鏈�杩戠殑鍗栧崟, 鏍煎紡{code:[鍗栧崟鍙�,鎬绘墜鏁�,浠锋牸,锛�'寮�濮嬫椂闂�',涔板崟鍙凤級,锛�'缁撴潫鏃堕棿',涔板崟鍙凤級]}
     __latest_sell_order_dict = {}
+    # 鏈�杩戞墍鏈夌殑鍗栧崟
+    __latest_all_sell_orders_dict = {}
 
     # 杩斿洖鏈�杩�1s鐨勫ぇ鍗曞崠锛�(鎬诲崠閲戦,[(鍗栧崟鍙�,鎬绘墜鏁�,浠锋牸,锛�'寮�濮嬫椂闂�',涔板崟鍙凤級,锛�'缁撴潫鏃堕棿',涔板崟鍙凤級),...])
     @classmethod
@@ -125,6 +127,9 @@
         if code not in cls.__big_sell_order_info_list_dict:
             cls.__big_sell_order_info_list_dict[code] = []
 
+        if code not in cls.__latest_all_sell_orders_dict:
+            cls.__latest_all_sell_orders_dict[code] = []
+
         sell_no_map = local_today_sellno_map.get(code)
         total_datas = local_today_datas.get(code)
         if not sell_no_map:
@@ -140,17 +145,23 @@
                     cls.__latest_sell_order_dict[code][4] = (d[3], d[6])
                 else:
                     info = cls.__latest_sell_order_dict[code]
+
                     # 涓婁釜鍗栧崟鎴愪氦瀹屾垚
                     # 灏佸瓨鏁版嵁锛岃绠楁柊璧风偣
                     # 澶т簬50w鐨勫崠鍗曟墠浼氫繚瀛�
                     # 澶т簬50w鍔犲叆鍗栧崟
-                    if info[1] * info[2] >= 500000:
+                    cls.__latest_all_sell_orders_dict[code].append(info)
+                    money = info[1] * info[2]
+                    if money >= 500000:
                         if is_active_sell(info[0]):
                             l2_log.info(code, hx_logger_l2_transaction_sell_order,
                                         f"{cls.__latest_sell_order_dict[code]}")
                             cls.__big_sell_order_ids_dict[code].add(info[0])
                             cls.__big_sell_order_info_dict[code][info[0]] = info
                             cls.__big_sell_order_info_list_dict[code].append(info)
+                    # 鍙繚鐣�10w浠ヤ笂鐨勫崟
+                    if money > 100000:
+                        cls.__latest_all_sell_orders_dict[code].append(info)
 
                     cls.__latest_sell_order_dict[code] = [d[7], d[2], d[1], (d[3], d[6]), (d[3], d[6])]
         latest_time = l2_huaxin_util.convert_time(datas[-1][3], with_ms=True)
@@ -200,3 +211,22 @@
         big_sell_orders.reverse()
         total_sell_info[1] = big_sell_orders
         return total_sell_info
+
+    # 鑾峰彇鏈�杩戞垚浜ゆ暟鎹�
+    @classmethod
+    def get_latest_transaction_datas(cls, code, min_sell_order_no=None):
+        total_orders = []
+        sell_orders = cls.__latest_all_sell_orders_dict.get(code)
+        if sell_orders:
+            for i in range(len(sell_orders) - 1, -1, -1):
+                if min_sell_order_no and min_sell_order_no > sell_orders[i][0]:
+                    break
+                total_orders.append(sell_orders[i])
+            total_orders.extend(sell_orders)
+        if code in cls.__latest_sell_order_dict:
+            if min_sell_order_no :
+                if cls.__latest_sell_order_dict[code][0] >= min_sell_order_no:
+                    total_orders.append(cls.__latest_sell_order_dict[code])
+            else:
+                total_orders.append(cls.__latest_sell_order_dict[code])
+        return total_orders
diff --git a/l2/l2_transaction_data_processor.py b/l2/l2_transaction_data_processor.py
index 3bdd143..4ebc715 100644
--- a/l2/l2_transaction_data_processor.py
+++ b/l2/l2_transaction_data_processor.py
@@ -3,7 +3,7 @@
 
 from l2 import l2_data_util, l2_data_manager, transaction_progress
 from l2.cancel_buy_strategy import FCancelBigNumComputer, LCancelBigNumComputer, LCancelRateManager, \
-    GCancelBigNumComputer, SCancelBigNumComputer, HourCancelBigNumComputer, DCancelBigNumComputer
+    GCancelBigNumComputer, SCancelBigNumComputer, HourCancelBigNumComputer
 from l2.l2_data_manager_new import L2TradeDataProcessor
 from l2.l2_data_util import L2DataUtil
 from l2.l2_transaction_data_manager import HuaXinBuyOrderManager, HuaXinSellOrderStatisticManager
@@ -122,3 +122,4 @@
             use_time = int((time.time() - __start_time) * 1000)
             if use_time > 10:
                 async_log_util.info(hx_logger_l2_upload, f"{code}澶勭悊鎴愪氦鐢ㄦ椂锛歿use_time}")
+
diff --git a/output/code_info_output.py b/output/code_info_output.py
index ebef414..f769935 100644
--- a/output/code_info_output.py
+++ b/output/code_info_output.py
@@ -416,10 +416,15 @@
                         extra_datas.append(f"鍖呭惈澶у崟锛歿' & '.join(big_num_desc)}")
                     extra_datas.append(f"M鍊硷細{money_desc(data['m_val'])}")
                     extra_datas.append(f"瀹夊叏绗旀暟锛歿data['safe_count']}")
+                    extra_datas.append(f"鎬诲崠棰濓細{data.get('sell_info')}")
 
                     records_new_data.append((time_, "", "-------------------------", []))
                     mode = data.get('mode')
-                    if mode == OrderBeginPosInfo.MODE_FAST:
+                    if mode == OrderBeginPosInfo.MODE_ACTIVE:
+                        records_new_data.append((time_, "婵�杩涗笅鍗�",
+                                                 f"銆恵format_l2_data(total_datas[data['buy_single_index']])}銆�-銆恵format_l2_data(total_datas[data['buy_exec_index']])}銆�",
+                                                 extra_datas))
+                    elif mode == OrderBeginPosInfo.MODE_FAST:
                         records_new_data.append((time_, "闂數涓嬪崟",
                                                  f"銆恵format_l2_data(total_datas[data['buy_single_index']])}銆�-銆恵format_l2_data(total_datas[data['buy_exec_index']])}銆�",
                                                  extra_datas))
diff --git a/trade/trade_record_log_util.py b/trade/trade_record_log_util.py
index dd930c9..b68bae6 100644
--- a/trade/trade_record_log_util.py
+++ b/trade/trade_record_log_util.py
@@ -18,7 +18,7 @@
 
 class PlaceOrderInfo(object):
     def __init__(self, buy_single_index=None, buy_exec_index=None, m_val=None, safe_count=None, big_num_indexes=None,
-                 kpl_blocks=None, kpl_match_blocks=None, mode=None):
+                 kpl_blocks=None, kpl_match_blocks=None, mode=None, sell_info = None):
         self.buy_single_index = buy_single_index
         self.buy_exec_index = buy_exec_index
         self.m_val = m_val
@@ -27,11 +27,15 @@
         self.kpl_blocks = kpl_blocks
         self.kpl_match_blocks = kpl_match_blocks
         self.mode = mode
+        self.sell_info = sell_info
 
     def set_buy_index(self, buy_single_index, buy_exec_index):
         self.buy_single_index = buy_single_index
         self.buy_exec_index = buy_exec_index
 
+    def set_sell_info(self, sell_info):
+        self.sell_info = sell_info
+
     def set_trade_factor(self, m_val, safe_count, big_num_indexes):
         self.m_val = m_val
         self.safe_count = safe_count

--
Gitblit v1.8.0