From 73f9f7a558f37cf102b9fadbea86d135ea62899c Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期四, 06 二月 2025 15:48:26 +0800
Subject: [PATCH] L后重新囊括条件修改/真实下单位修改/下单的拆单方式修改

---
 trade/buy_radical/radical_buy_data_manager.py |   10 ++++++++--
 third_data/kpl_limit_up_data_manager.py       |    5 +++++
 l2/huaxin/huaxin_delegate_postion_manager.py  |    9 +++++++--
 l2/l2_data_manager_new.py                     |   16 ++++++++++------
 cancel_strategy/s_l_h_cancel_strategy.py      |    6 ++++--
 trade/buy_money_count_setting.py              |    3 ++-
 6 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/cancel_strategy/s_l_h_cancel_strategy.py b/cancel_strategy/s_l_h_cancel_strategy.py
index 00423b8..87051fb 100644
--- a/cancel_strategy/s_l_h_cancel_strategy.py
+++ b/cancel_strategy/s_l_h_cancel_strategy.py
@@ -14,6 +14,7 @@
 from log_module import async_log_util
 from third_data import code_plate_key_manager
 from trade.buy_radical import radical_buy_data_manager
+from trade.buy_radical.radical_buy_data_manager import BeforeSubDealBigOrderManager
 
 from utils import tool
 from l2.transaction_progress import TradeBuyQueue
@@ -222,8 +223,9 @@
             cancel_result = self.__need_cancel_for_slow_sell(code, total_datas)
             if cancel_result[0]:
                 return True, f"S鎱㈢牳:{cancel_result[1]}"
-
-        if total_deal_money >= 100 * 10000:
+        # 鍗栭噾棰�>=鍧囧ぇ鍗曟墠瑙﹀彂閲嶆柊鍥婃嫭
+        THRESHOLD_MONEY, is_temp_threshold_money = BeforeSubDealBigOrderManager().get_big_order_threshold_info(code)
+        if total_deal_money >= THRESHOLD_MONEY:
             l2_log.s_cancel_debug(code, "鍑嗗鏇存柊L鍚庡泭鎷�")
             start_order_no = big_sell_order_info[1][-1][4][1]
             latest_deal_time_ms = l2_huaxin_util.convert_time(big_sell_order_info[1][-1][4][0], with_ms=True)
diff --git a/l2/huaxin/huaxin_delegate_postion_manager.py b/l2/huaxin/huaxin_delegate_postion_manager.py
index e53683f..629741a 100644
--- a/l2/huaxin/huaxin_delegate_postion_manager.py
+++ b/l2/huaxin/huaxin_delegate_postion_manager.py
@@ -130,10 +130,10 @@
     @classmethod
     def __compute_real_place_order_position(cls, code, exec_data, oredr_info_list, add_datas):
         THRESHOLD_MS = 20 if tool.is_sz_code(code) else 100
+        exec_time_with_ms = L2DataUtil.get_time_with_ms(exec_data["val"])
         # 鑾峰彇涓嬪崟鐨勯噺
         target_volumes = [x[0] // 100 for x in oredr_info_list]
         volumes_info_list = []
-
         current_delegates = huaxin_trade_record_manager.DelegateRecordManager().list_current_delegates(code)
         # 涓嬪崟閲忓搴旂殑濮旀墭鏃堕棿
         current_delegate_place_order_time_dict = {}
@@ -214,7 +214,12 @@
             if max_sub_time > THRESHOLD_MS:
                 continue
             # 鏈�澶х殑鏃堕棿宸�,鏈�澶х殑绱㈠紩宸�, 鏁版嵁
-            match_list.append((max_sub_time, max_sub_index, temp_volumes_info_list[0][2]))
+            # 娣辫瘉涓庢墽琛屼綅缃浉宸椂闂�>=10ms浠ヤ笂锛屼笂璇佷笌鎵ц浣嶇疆鐩稿樊鏃堕棿>=100ms浠ヤ笂
+            data_ = temp_volumes_info_list[0][2]
+            MIN_SPCE_MS = 100 if tool.is_sh_code(code) else 10
+            if tool.trade_time_sub_with_ms(L2DataUtil.get_time_with_ms(data_["val"]), exec_time_with_ms) < MIN_SPCE_MS:
+                continue
+            match_list.append((max_sub_time, max_sub_index, data_))
         if not match_list:
             # 娌℃湁鎵惧埌鐪熷疄涓嬪崟浣�
             return None
diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py
index f6b513d..a11ce79 100644
--- a/l2/l2_data_manager_new.py
+++ b/l2/l2_data_manager_new.py
@@ -18,6 +18,7 @@
 from l2.place_order_single_data_manager import L2TradeSingleDataProcessor
 from log_module import async_log_util, log_export
 from third_data import kpl_data_manager, block_info
+from third_data.kpl_data_constant import LimitUpDataConstant
 from trade.buy_radical.radical_buy_data_manager import EveryLimitupBigDealOrderManager
 from utils import global_util, tool, buy_condition_util, buy_strategy_util, trade_util
 import l2_data_util
@@ -815,12 +816,11 @@
             average_rate = cls.__Buy1PriceManager.get_average_rate(code)
             if average_rate :
                 if tool.is_ge_code(code):
-                    if average_rate <= 0.1:
-                        return False, True, f"鍧囦环娑ㄥ箙({average_rate})灏忎簬10%", True
+                    if average_rate <= 0.07:
+                        return False, True, f"鍧囦环娑ㄥ箙({average_rate})灏忎簬7%", True
                 else:
-                    if average_rate <= 0.05:
-                        return False, True, f"鍧囦环娑ㄥ箙({average_rate})灏忎簬5%", True
-
+                    if average_rate <= 0.03:
+                        return False, True, f"鍧囦环娑ㄥ箙({average_rate})灏忎簬3%", True
         return True, False, f"", False
 
     @classmethod
@@ -919,6 +919,7 @@
     def __buy(cls, code, capture_timestamp, last_data, last_data_index, is_first_code, block_info=None):
         pre_result = cls.__is_pre_can_buy(code)
         if not pre_result[0]:
+            l2_log.debug(code, "涓嶅彲浠ヤ笅鍗曪紝鍘熷洜锛歿}", pre_result[2])
             return False
         # 娣诲姞涔板叆閿�
         if code not in cls.__buy_lock_dict:
@@ -1897,11 +1898,14 @@
             if refer_sell_data:
                 refer_sell_money = refer_sell_data[1]
             # 澶у崟鍒ゆ柇缁撴灉
+            history_limit_up_codes = LimitUpDataConstant.get_history_limit_up_codes()
+            if history_limit_up_codes is None:
+                history_limit_up_codes = set()
             big_order_deal_enough_result = radical_buy_data_manager.is_big_order_deal_enough(code,
                                                                                              code_volumn_manager.CodeVolumeManager().get_volume_rate_refer_in_5days(
                                                                                                  code),
                                                                                              refer_sell_money,
-                                                                                             for_buy=True)
+                                                                                             for_buy=True, is_first_limit_up = code not in history_limit_up_codes)
             # 缂轰箯鐨勫ぇ鍗曢噾棰�
             lack_money = big_order_deal_enough_result[3]
             # 濡傛灉鏈夊ぇ鍗曟垚浜ゅ氨涓嶉渶瑕佺湅澶у崟
diff --git a/third_data/kpl_limit_up_data_manager.py b/third_data/kpl_limit_up_data_manager.py
index 731516c..d106874 100644
--- a/third_data/kpl_limit_up_data_manager.py
+++ b/third_data/kpl_limit_up_data_manager.py
@@ -327,3 +327,8 @@
         rate = int((volumes_data[0]["close"] - min_price) * 100 / min_price)
         cls.__k_max_rate[code] = rate
         return cls.__k_datas.get(code)
+
+
+if __name__ == "__main__":
+    datas = LatestLimitUpBlockManager().statistics_limit_up_block_infos()
+    print(datas)
\ No newline at end of file
diff --git a/trade/buy_money_count_setting.py b/trade/buy_money_count_setting.py
index e27dfe5..570123b 100644
--- a/trade/buy_money_count_setting.py
+++ b/trade/buy_money_count_setting.py
@@ -257,7 +257,8 @@
         if total_volume_unit_100 % 2 == 0:
             return 100 * (total_volume_unit_100 // 2 - 1), 100 * (total_volume_unit_100 // 2 + 1)
         else:
-            return 100 * (total_volume_unit_100 // 2), 100 * (total_volume_unit_100 // 2 + 1)
+            # 闃叉涓庡悓鑺遍『绛変氦鏄撳钩鍙版媶鍗曠浉浼�
+            return 100 * (total_volume_unit_100 // 2 - 1), 100 * (total_volume_unit_100 // 2 + 1 + 1)
 
 
 if __name__ == '__main__':
diff --git a/trade/buy_radical/radical_buy_data_manager.py b/trade/buy_radical/radical_buy_data_manager.py
index 3838a45..7fb101a 100644
--- a/trade/buy_radical/radical_buy_data_manager.py
+++ b/trade/buy_radical/radical_buy_data_manager.py
@@ -1553,12 +1553,14 @@
     return total_lack_money, deal_big_order_money, TOTAL_BIG_DEAL_MONEY_THRESHOLD_MONEY
 
 
-def is_big_order_deal_enough(code, volume_rate, refer_total_sell_money, for_buy=False):
+def is_big_order_deal_enough(code, volume_rate, refer_total_sell_money, for_buy=False, is_first_limit_up=False):
     """
     澶у崟鎴愪氦鏄惁瓒冲
     @param refer_total_sell_money: 寮曠敤鐨勬�诲崠棰�
     @param code:
     @param volume_rate:
+    @param for_buy: 鏄惁鏄笅鍗�
+    @param is_first_limit_up: 鏄惁鏄灏佷笅鍗�
     @return: 澶у崟鏄惁瓒冲, 鍘熷洜, 鏄惁鏄煭鏃剁敓鏁�, 杩樺樊鐨勯噾棰�
     """
     limit_up_price = gpcode_manager.get_limit_up_price_as_num(code)
@@ -1597,7 +1599,11 @@
     current_lack_money = max(0, int(current_threshold_money - current_big_order_deal_money))
     if for_buy and not tool.is_ge_code(code):
         # 瑕佷笅鍗曠殑涓斾笉鏄垱涓氱増鐨勭洰鏍囦唬鐮佸ぇ鍗曟暟閲忔墦8鎶�
-        total_lack_money = int(total_threshold_money * 0.8 - total_deal_money)
+        if is_first_limit_up:
+            # 棣栧皝涓嶆墦鎶�
+            total_lack_money = int(total_threshold_money - total_deal_money)
+        else:
+            total_lack_money = int(total_threshold_money * 0.8 - total_deal_money)
         if total_lack_money < 0:
             total_lack_money = 0
     if current_lack_money == 0 and total_lack_money == 0:

--
Gitblit v1.8.0