From 6a0d3ff5832e57ee1b1374d086f24b3c1679b332 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期五, 05 九月 2025 18:22:24 +0800
Subject: [PATCH] bug修复/降低测撤单率

---
 trade/l2_trade_factor.py |   46 ++++++++++++++++++++++++++++------------------
 1 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/trade/l2_trade_factor.py b/trade/l2_trade_factor.py
index 99dd2c2..602d8fe 100644
--- a/trade/l2_trade_factor.py
+++ b/trade/l2_trade_factor.py
@@ -6,6 +6,7 @@
 
 from code_attribute import big_money_num_manager, limit_up_time_manager, global_data_loader, gpcode_manager
 import constant
+from trade import trade_manager, deal_big_money_manager, trade_constant
 from utils import global_util, tool
 
 
@@ -114,6 +115,11 @@
         self.now_time = now_time
         self.buy_rank = self.get_buy_rank()
 
+    # 鏄惁鏄垵娆′笅鍗�
+    @classmethod
+    def is_first_place_order(cls, code):
+        return trade_manager.CodesTradeStateManager().get_trade_state_cache(code) == trade_constant.TRADE_STATE_NOT_TRADE
+
     # 璁剧疆鍒嗘暟
     def set_score(self, score):
         score_ranks = [constant.BUY_SCORE_RANK_3, constant.BUY_SCORE_RANK_2, constant.BUY_SCORE_RANK_1,
@@ -129,7 +135,6 @@
         self.score_index = score_index
 
     # 鑾峰彇淇″彿杩炵画涔扮瑪鏁�
-
     def get_begin_continue_buy_count(self):
         counts = [3, 3, 3, 2, 2, 2, 2]
         volume_rate_index = self.volume_rate_index
@@ -140,29 +145,31 @@
     # 鑾峰彇鏃堕棿璁$畻鑼冨洿锛岃繑鍥瀞
     def get_time_range(self):
         # ts = [pow(3, 1), pow(3, 1), pow(3, 1), pow(3, 2), pow(3, 2), pow(3, 3), pow(3, 3), pow(3, 3)]
-        ts = [pow(2, 1), pow(2, 1), pow(2, 1), pow(2, 1), pow(2, 2), pow(2, 2), pow(2, 2), pow(2, 2)]
+        ts = [pow(2, 1), pow(2, 1), pow(2, 1), pow(2, 1), pow(2, 1), pow(2, 1), pow(2, 1), pow(2, 1)]
         # 鏆傛椂鍘婚櫎鍒嗙殑褰卞搷
         # if -1 < self.score_index < 3:
         #     return ts[0]
         volume_rate_index = self.volume_rate_index
         if self.volume_rate_index >= len(ts):
             volume_rate_index = -1
+        # 棣栨涓嬪崟蹇呴』鍚�1s
+        if self.is_first_place_order(self.code):
+            return 1
         return ts[volume_rate_index]
 
     # 鑾峰彇闇�瑕佺殑澶у崟涓暟
     def get_big_num_count(self):
-        # if self.is_first_code:
-        #     if self.buy_rank < 2:
-        #         return 0
-        #     elif self.buy_rank == 2:
-        #         return 1
-        #     elif self.buy_rank == 3:
-        #         return 2
-        counts = [1, 1, 1, 1, 0, 0, 0, 0]
-        volume_rate_index = self.volume_rate_index
-        if self.volume_rate_index >= len(counts):
-            volume_rate_index = -1
-        return counts[volume_rate_index]
+        # counts = [1, 1, 1, 1, 0, 0, 0, 0]
+        # volume_rate_index = self.volume_rate_index
+        # if self.volume_rate_index >= len(counts):
+        #     volume_rate_index = -1
+        # return counts[volume_rate_index]
+        # 鏈夊ぇ鍗曟垚浜ゅ氨涓嶉渶瑕佸ぇ鍗曚簡锛屾病鏈夊ぇ鍗曟垚浜ゅ氨闇�瑕佸ぇ鍗�
+        deal_big_money_count = deal_big_money_manager.get_deal_big_money_count(self.code)
+        if deal_big_money_count > 0:
+            return 0
+        else:
+            return 1
 
     # 鑾峰彇瀹夊叏绗旀暟褰卞搷姣斾緥
     def get_safe_count_rate(self):
@@ -179,12 +186,13 @@
         base_count, min_count, max_count = L2TradeFactorUtil.get_safe_buy_count(self.code, True)
         rate = self.get_safe_count_rate()
         count = int(round(base_count * (1 + rate)))
-        return count
+        # 鏈�灏�8绗�
+        return max(count, 8)
 
     # 鑾峰彇m鍊煎奖鍝嶆瘮渚�
     @classmethod
     def get_m_val_rate(cls, volume_rate_index):
-        rates = [0.0, -0.1, -0.2, -0.3, -0.4, -0.5, -0.6, -0.7]
+        rates = [0.0, -0.1, -0.15, -0.2, -0.25, -0.3, -0.35, -0.4]
         if volume_rate_index >= len(rates):
             volume_rate_index = -1
         return rates[volume_rate_index]
@@ -201,6 +209,8 @@
     # 鑾峰彇m鍊�
     def get_m_val(self):
         base_m = self.get_base_m_val(self.code)
+        if self.is_first_place_order(self.code) and tool.is_sz_code(self.code):
+            base_m = int(base_m * 2)
         rate = self.get_m_val_rate(self.volume_rate_index)
         m = round(base_m * (1 + rate))
         return m, ""
@@ -532,8 +542,8 @@
     # print(L2TradeFactorUtil.get_rate_factors("003004"))
     # print(L2TradeFactorUtil.factors_to_string("003004"))
 
-    for i in range(2, 150):
-        print(i, L2TradeFactorUtil.get_base_safe_val(100000000 * i))
+    # for i in range(2, 150):
+    print(22, L2TradeFactorUtil.get_base_safe_val(100000000 * 22))
     # print(L2TradeFactorUtil.get_limit_up_time_rate("11:30:00"))
     # print(L2TradeFactorUtil.get_limit_up_time_rate("13:00:00"))
     # print(L2TradeFactorUtil.get_limit_up_time_rate("13:48:00"))

--
Gitblit v1.8.0