From 81f328532e366eef171b71810b221a9294dda78f Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期四, 21 十二月 2023 14:31:58 +0800
Subject: [PATCH] 买入条件调整/L撤调整

---
 trade/trade_result_manager.py                      |   12 ++
 third_data/history_k_data_util.py                  |   32 ++++++
 third_data/block_info.py                           |    2 
 code_attribute/code_nature_analyse.py              |   23 +++-
 code_attribute/first_target_code_data_processor.py |    2 
 trade/huaxin/huaxin_trade_server.py                |   12 --
 test/test_code_attribute.py                        |   16 ++-
 code_attribute/gpcode_manager.py                   |    6 +
 l2/cancel_buy_strategy.py                          |   91 +++++++++++-------
 l2/l2_data_manager_new.py                          |   55 +++++++++--
 server.py                                          |    2 
 11 files changed, 177 insertions(+), 76 deletions(-)

diff --git a/code_attribute/code_nature_analyse.py b/code_attribute/code_nature_analyse.py
index 1328355..f5c0d23 100644
--- a/code_attribute/code_nature_analyse.py
+++ b/code_attribute/code_nature_analyse.py
@@ -218,7 +218,8 @@
     # 鏄惁鍏锋湁杈ㄨ瘑搴�
     p9 = is_special(record_datas)
     p10 = is_latest_10d_max_volume_at_latest_2d(record_datas)
-    p11 = __is_yesterday_open_limit_up(record_datas)
+    # 鏈�杩�5澶╂槸鍚﹁穼鍋�/鐐告澘
+    p11 = __is_latest_open_limit_up_or_limit_down(record_datas, 5)
     # 30澶╁唴鏄惁鏈夋定鍋�
     p12 = __has_limit_up(record_datas, 30)
 
@@ -476,15 +477,21 @@
     return False, ''
 
 
-# 鏄ㄥぉ鏄惁鐐告澘
-def __is_yesterday_open_limit_up(datas):
+# 鏈�杩戝嚑澶╂槸鍚︽湁鐐告澘鎴栬穼鍋�
+def __is_latest_open_limit_up_or_limit_down(datas, day_count):
     datas = copy.deepcopy(datas)
     datas.sort(key=lambda x: x["bob"])
-    item = datas[-1]
-    limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(item["pre_close"]))
-    if abs(limit_up_price - item["high"]) < 0.001 and abs(limit_up_price - item["close"]) > 0.001:
-        # 鐐告澘
-        return True
+    items = datas[0-day_count]
+    for item in items:
+        limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(item["pre_close"]))
+        if abs(limit_up_price - item["high"]) < 0.001 and abs(limit_up_price - item["close"]) > 0.001:
+            # 鐐告澘
+            return True
+        # 鏄惁鏈夎穼鍋�
+        limit_down_price = float(gpcode_manager.get_limit_down_price_by_preprice(item["pre_close"]))
+        if abs(limit_down_price - item["close"]) < 0.001:
+            # 璺屽仠
+            return True
     return False
 
 
diff --git a/code_attribute/first_target_code_data_processor.py b/code_attribute/first_target_code_data_processor.py
index 544d9b7..b7db9e6 100644
--- a/code_attribute/first_target_code_data_processor.py
+++ b/code_attribute/first_target_code_data_processor.py
@@ -22,6 +22,8 @@
 def process_first_codes_datas(dataList, request_id=None):
     logger_l2_codes_subscript.info(f"{request_id}鍔犺浇l2浠g爜鐩稿叧鏁版嵁")
     print("棣栨澘浠g爜鏁伴噺锛�", len(dataList))
+    # 鑾峰彇鏈�杩�5澶╃殑浜ゆ槗鏃ユ湡锛屼负鍚庨潰鐨勬暟鎹绠楀仛鍑嗗
+    HistoryKDatasUtils.get_latest_trading_date_cache(5)
     limit_up_price_dict = {}
     temp_codes = []
     codes = []
diff --git a/code_attribute/gpcode_manager.py b/code_attribute/gpcode_manager.py
index 0bef2bf..5f119e3 100644
--- a/code_attribute/gpcode_manager.py
+++ b/code_attribute/gpcode_manager.py
@@ -763,6 +763,12 @@
     return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal("1.1"))
 
 
+def get_limit_down_price_by_preprice(price):
+    if price is None:
+        return None
+    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal("0.9"))
+
+
 # 鑾峰彇璺屽仠浠�
 def get_limit_down_price(code):
     price = CodePrePriceManager.get_price_pre_cache(code)
diff --git a/l2/cancel_buy_strategy.py b/l2/cancel_buy_strategy.py
index f2c7814..c7f3ab8 100644
--- a/l2/cancel_buy_strategy.py
+++ b/l2/cancel_buy_strategy.py
@@ -35,6 +35,7 @@
     SecondCancelBigNumComputer().set_real_place_order_index(code, index)
     LCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index=buy_single_index)
     HourCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index)
+    GCancelBigNumComputer().set_real_place_order_index(code, index)
 
 
 class SecondCancelBigNumComputer:
@@ -686,7 +687,7 @@
                                                                                                              code))
                 cancel_num += val['num'] * (data['re'] - left_count)
             rate = round(cancel_num / total_num, 4)
-            must_buy_cancel_rate =  constant.H_CANCEL_RATE
+            must_buy_cancel_rate = constant.H_CANCEL_RATE
             try:
                 temp_rate = gpcode_manager.MustBuyCodesManager().get_cancel_rate_cache(code)
                 if temp_rate:
@@ -834,7 +835,7 @@
             if must_buy_cancel_rate is not None:
                 return must_buy_cancel_rate
         except Exception as e:
-            async_log_util.error(logger_l2_l_cancel,str(e))
+            async_log_util.error(logger_l2_l_cancel, str(e))
 
         base_rate = constant.L_CANCEL_RATE
         if is_up:
@@ -913,8 +914,6 @@
     __near_by_trade_progress_index_cache = {}
 
     __SecondCancelBigNumComputer = SecondCancelBigNumComputer()
-
-
 
     __last_l_up_compute_info = {}
 
@@ -1286,8 +1285,11 @@
         watch_indexes = set([int(i) for i in watch_indexes_info[2]])
         # 璁$畻鐩戝惉鐨勬�绘潯鏁�
         total_num = 0
+        max_num = 0
         for wi in watch_indexes:
             total_num += total_data[wi]["val"]["num"] * total_data[wi]["re"]
+            if total_data[wi]["val"]["num"] > max_num:
+                max_num = total_data[wi]["val"]["num"]
         # 鍒ゆ柇鎾ゅ崟涓槸鍚︽湁鐩戝惉涓殑绱㈠紩
         need_compute = False
         for i in range(start_index, end_index + 1):
@@ -1324,6 +1326,9 @@
 
             rate = round(canceled_num / total_num, 3)
             thresh_hold_rate = LCancelRateManager.get_cancel_rate(code)
+            # 闄ゅ紑鏈�澶у崟鐨勫奖鍝嶆潈閲�
+            temp_thresh_hold_rate = round((total_num - max_num)*0.9/total_num, 2)
+            thresh_hold_rate = min(thresh_hold_rate, temp_thresh_hold_rate)
             l2_log.l_cancel_debug(code, f"璁$畻鑼冨洿锛歿start_index}-{end_index},宸叉挙鍗曟瘮渚嬶細{rate}/{thresh_hold_rate}")
             if rate >= thresh_hold_rate:
                 canceled_indexes.sort()
@@ -1452,7 +1457,7 @@
 
     def need_cancel(self, code, buy_exec_index, start_index, end_index, total_data, is_first_code):
         if buy_exec_index is None:
-            return False, "灏氭湭鎵惧埌涓嬪崟浣嶇疆", ""
+            return False, None, "灏氭湭鎵惧埌涓嬪崟浣嶇疆"
         # 瀹堟姢S鎾や互澶栫殑鏁版嵁
         if int(tool.get_now_time_str().replace(":", "")) > int("145700") and not constant.TEST:
             return False, None, ""
@@ -1666,38 +1671,52 @@
 
 # ---------------------------------G鎾�-------------------------------
 class GCancelBigNumComputer:
-    __SecondCancelBigNumComputer = SecondCancelBigNumComputer()
+    __real_place_order_index_dict = {}
+    __instance = None
 
-    # 寮�濮嬫挙鍗�
-    def start_cancel(self, code, buy_no, total_datas, m_val_num):
-        # TODO 鏆傛椂娉ㄩ噴鎺塆鎾�
-        return False, "鏆傛椂涓嶆墽琛孏鎾�"
-        thresh_num = int(m_val_num * 1)
-        place_order_index = self.__SecondCancelBigNumComputer.get_real_place_order_index_cache(code)
-        if place_order_index is None:
-            raise Exception("鏈幏鍙栧埌涓嬪崟鐪熷疄浣嶇疆")
-        buy_data = buy_order_no_map.get(buy_no)
-        if not buy_data:
-            raise Exception(f"灏氭湭鑾峰彇鍒版挙涔板崟璇︽儏鏁版嵁: order_no:{buy_no} map鏁伴噺锛歿len(buy_order_no_map)}")
-        # 浠庢垚浜や綅缃埌涓嬪崟浣嶇疆璁$畻m鍊�
-        transaction_index = buy_data["index"]
-        need_cancel = True
-        buy_nums = 0
-        for index in range(transaction_index + 1, place_order_index):
-            data = total_datas[index]
-            if L2DataUtil.is_limit_up_price_buy(data["val"]):
-                # 鑾峰彇鏄惁鍦ㄤ拱鍏ユ墽琛屼俊鍙峰懆鍥�2s
-                left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, index,
-                                                                                                         total_datas,
-                                                                                                         local_today_canceled_buyno_map.get(
-                                                                                                             code))
-                if left_count > 0:
-                    buy_nums += left_count * data["val"]["num"]
-                    if buy_nums > thresh_num:
-                        break
-        if buy_nums > thresh_num:
-            need_cancel = False
-        return need_cancel, f"鎴愪氦杩涘害浣�({transaction_index})-鐪熷疄涓嬪崟浣�({place_order_index})  绾拱鎵嬫暟:{buy_nums}/1.8鍊峬鍊兼墜鏁�:{thresh_num}"
+    def __new__(cls, *args, **kwargs):
+        if not cls.__instance:
+            cls.__instance = super(GCancelBigNumComputer, cls).__new__(cls, *args, **kwargs)
+        return cls.__instance
+
+    def set_real_place_order_index(self, code, index):
+        self.__real_place_order_index_dict[code] = index
+
+    def clear(self, code=None):
+        if code:
+            if code in self.__real_place_order_index_dict:
+                self.__real_place_order_index_dict.pop(code)
+        else:
+            self.__real_place_order_index_dict.clear()
+
+    def need_cancel(self, code, buy_exec_index, start_index, end_index):
+        if code not in self.__real_place_order_index_dict:
+            return False, None, "娌℃湁鎵惧埌鐪熷疄涓嬪崟浣�"
+        real_place_order_index = self.__real_place_order_index_dict.get(code)
+        total_datas = local_today_datas.get(code)
+        # 30s鍐呮湁鏁�
+        if tool.trade_time_sub(total_datas[end_index]["val"]["time"], total_datas[buy_exec_index]["val"]["time"]) > 30:
+            return False, None, "涓嬪崟30s鍐呮墠鐢熸晥"
+
+        for i in range(start_index, end_index + 1):
+            data = total_datas[i]
+            val = data["val"]
+            if not L2DataUtil.is_limit_up_price_buy_cancel(val):
+                continue
+            if val["num"] * float(val["price"]) < 30000:
+                continue
+            buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data_v2(data,
+                                                                                                local_today_buyno_map.get(
+                                                                                                    code))
+            if buy_index is not None and buy_index < real_place_order_index:
+                return True, data, ""
+        return False, None, ""
+
+    def place_order_success(self, code):
+        self.clear(code)
+
+    def cancel_success(self, code):
+        self.clear(code)
 
 
 # ---------------------------------鐙嫍鎾�-------------------------------
diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py
index 550d20f..e708f6e 100644
--- a/l2/l2_data_manager_new.py
+++ b/l2/l2_data_manager_new.py
@@ -12,7 +12,8 @@
 from l2.l2_sell_manager import L2MarketSellManager, L2LimitUpSellManager
 from l2.transaction_progress import TradeBuyQueue
 from log_module import async_log_util, log_export
-from third_data import kpl_data_manager, block_info
+from third_data import kpl_data_manager, block_info, history_k_data_util
+from third_data.history_k_data_util import HistoryKDatasUtils
 from utils import global_util, ths_industry_util, tool
 import l2_data_util
 from db import redis_manager_delegate as redis_manager
@@ -22,7 +23,7 @@
 from l2 import l2_data_manager, l2_log, l2_data_source_util, code_price_manager, \
     transaction_progress, cancel_buy_strategy, l2_data_log
 from l2.cancel_buy_strategy import SecondCancelBigNumComputer, HourCancelBigNumComputer, DCancelBigNumComputer, \
-    LCancelBigNumComputer, LatestCancelIndexManager, FastCancelBigNumComputer, LCancelRateManager
+    LCancelBigNumComputer, LatestCancelIndexManager, FastCancelBigNumComputer, LCancelRateManager, GCancelBigNumComputer
 from l2.l2_data_manager import L2DataException, OrderBeginPosInfo
 from l2.l2_data_util import local_today_datas, L2DataUtil, local_today_num_operate_map, local_today_buyno_map, \
     local_latest_datas, local_today_canceled_buyno_map
@@ -221,6 +222,7 @@
     __SecondCancelBigNumComputer = SecondCancelBigNumComputer()
     __HourCancelBigNumComputer = HourCancelBigNumComputer()
     __LCancelBigNumComputer = LCancelBigNumComputer()
+    __GCancelBigNumComputer = GCancelBigNumComputer()
     __TradeStateManager = trade_manager.TradeStateManager()
     __CodesTradeStateManager = trade_manager.CodesTradeStateManager()
     __PauseBuyCodesManager = gpcode_manager.PauseBuyCodesManager()
@@ -557,6 +559,25 @@
                 pass
             return None, ""
 
+        # G鎾�
+        def g_cancel(_buy_single_index, _buy_exec_index):
+            try:
+                b_need_cancel, b_cancel_data, extra_msg = cls.__GCancelBigNumComputer.need_cancel(code,
+                                                                                                  _buy_exec_index,
+                                                                                                  start_index,
+                                                                                                  end_index)
+                if b_need_cancel and b_cancel_data:
+                    return b_cancel_data, f"G鎾�({extra_msg})"
+            except Exception as e:
+                async_log_util.error(logger_l2_error,
+                                     f"G鎾ゅ嚭閿� 鍙傛暟锛歜uy_single_index-{_buy_single_index} buy_exec_index-{_buy_exec_index} 閿欒鍘熷洜锛歿str(e)}")
+                # logger_l2_error.exception(e)
+                async_log_util.exception(logger_l2_error, e)
+            finally:
+                # l2_data_log.l2_time(code, round(t.time() * 1000) - _start_time, "宸蹭笅鍗�-L鎾ゅぇ鍗曡绠�")
+                pass
+            return None, ""
+
         if start_index < 0:
             start_index = 0
 
@@ -573,6 +594,9 @@
         cancel_data, cancel_msg = None, ""
         if order_begin_pos.mode == OrderBeginPosInfo.MODE_FAST:
             cancel_data, cancel_msg = f_cancel(order_begin_pos.buy_single_index, order_begin_pos.buy_exec_index)
+
+        if not cancel_data:
+            cancel_data, cancel_msg = g_cancel(order_begin_pos.buy_single_index, order_begin_pos.buy_exec_index)
 
         # 渚濇澶勭悊
         if not cancel_data:
@@ -942,8 +966,6 @@
         # if cls.__TradeTargetCodeModeManager.get_mode_cache() == TradeTargetCodeModeManager.MODE_ONLY_BUY_WANT_CODES:
         #     return False, True, f"鍙拱鎯充拱鍗曚腑鐨勪唬鐮�"
 
-        if HighIncreaseCodeManager().is_in(code):
-            return False, True, f"娑ㄥ箙杩囬珮锛�5澶╁唴3娆℃定鍋�"
         return cls.can_buy_first(code, limit_up_price)
         # else:
         #     return True, False, "鍦ㄦ兂涔板悕鍗曚腑"
@@ -980,15 +1002,29 @@
             if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6:
                 return False, True, f"鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮涓�30澶╁唴鏈夋定鍋�,褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.6"
 
-        # 鍓嶄竴澶╃偢鏉夸箣鍚庯紝浠婃棩10:00涔嬪墠鎵嶈兘涓嬪崟
+        # 涓�5涓氦鏄撴棩鏈夌偢鏉�/璺屽仠涔嬪悗
         if k_format and len(k_format) >= 11 and k_format[10]:
-            if now_timestamp > int("100000"):
-                return False, True, f"涓婁釜浜ゆ槗鏃ョ偢鏉�,褰撴棩10鐐逛互鍚庝笉涓嬪崟"
+            if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6:
+                return False, True, f"涓�5涓氦鏄撴棩鐐告澘/璺屽仠,閲忔湭杈惧埌60%({cls.volume_rate_info[code][0]})"
+
+        # 鑾峰彇閲忕殑鍙傝�冩棩鏈�
+        if code in global_util.max60_volumn:
+            day = global_util.max60_volumn[code][1]
+            if day in HistoryKDatasUtils.get_latest_trading_date_cache(5):
+                if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6:
+                    return False, True, f"鍙傝�冮噺鍦ㄦ渶杩�5澶�,閲忔湭杈惧埌60%({cls.volume_rate_info[code][0]})"
+
+        zyltgb = global_util.zyltgb_map.get(code)
+        if zyltgb >= 40 * 100000000:
+            return False, True, f"40浜夸互涓婄殑閮戒笉涔帮紙{zyltgb}锛�"
+
+        if HighIncreaseCodeManager().is_in(code):
+            if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.8:
+                return False, True, f"5澶╁唴3娆℃定鍋滐紝閲忔湭杈惧埌80%锛坽cls.volume_rate_info[code][0]}锛�"
 
         msg_list = []
-        if can_buy_result[3] and now_timestamp <= int("094000"):
+        if now_timestamp <= int("094000"):
             msg_list.append("寮哄娍10鍒嗛挓")
-            zyltgb = global_util.zyltgb_map.get(code)
             # 鐙嫍
             if not can_buy_result[0] and can_buy_result[1]:
                 msg_list.append("鐙嫍")
@@ -1019,7 +1055,6 @@
                     return True, False, can_buy_result[2]
             return True, False, can_buy_result[2]
         else:
-            zyltgb = global_util.zyltgb_map.get(code)
             # 闈炲己鍔�10鍒嗛挓鍙拱涓荤嚎
             if not can_buy_result[0] and can_buy_result[1]:
                 return False, True, f"闈炲己鍔�10鍒嗛挓锛岀嫭鑻椾笉涓嬪崟"
diff --git a/server.py b/server.py
index 455701d..211b373 100644
--- a/server.py
+++ b/server.py
@@ -593,7 +593,7 @@
                     day = tool.get_now_date_str()
                     data_dict = {}
                     for i in range(0, 2):
-                        day = HistoryKDatasUtils.get_previous_trading_date(day)
+                        day = HistoryKDatasUtils.get_previous_trading_date_cache(day)
                         data_list = list(block_info.KPLLimitUpDataRecordManager.list_all(day))
                         codes_set = set()
                         if data_list:
diff --git a/test/test_code_attribute.py b/test/test_code_attribute.py
index 26689ca..e3732e7 100644
--- a/test/test_code_attribute.py
+++ b/test/test_code_attribute.py
@@ -10,15 +10,21 @@
 
 
 if __name__ == "__main__":
-    code_str = "603178"
+    code_str = "002861"
     codes = code_str.split(",")
     for code in codes:
         if not tool.is_shsz_code(code):
             continue
         try:
-            datas = init_data_util.get_volumns_by_code(code, 120)
-            result = is_too_high(datas)
-            if result:
-                print(code, result)
+            limit_up_price = 16.96
+            volumes_data = init_data_util.get_volumns_by_code(code, 150)
+            volumes_data = volumes_data[1:]
+            volumes = init_data_util.parse_max_volume(volumes_data[:90],
+                                                      code_nature_analyse.is_new_top(
+                                                          limit_up_price,
+                                                          volumes_data[:90]) or code_nature_analyse.is_near_top(
+                                                          limit_up_price,
+                                                          volumes_data[:90]))
+            print(volumes)
         except:
             print(code, "鍑洪敊")
diff --git a/third_data/block_info.py b/third_data/block_info.py
index 7682066..b492143 100644
--- a/third_data/block_info.py
+++ b/third_data/block_info.py
@@ -69,7 +69,7 @@
     if now_day in __blocks_dict:
         return __blocks_dict[now_day]
     now_date = datetime.datetime.now()
-    end_date = HistoryKDatasUtils.get_previous_trading_date(tool.get_now_date_str())
+    end_date = HistoryKDatasUtils.get_previous_trading_date_cache(tool.get_now_date_str())
     start_date = now_date - datetime.timedelta(days=(day_count * 2 + 10))
     start_date = start_date.strftime("%Y-%m-%d")
     days = HistoryKDatasUtils.get_trading_dates(start_date, end_date)
diff --git a/third_data/history_k_data_util.py b/third_data/history_k_data_util.py
index bfc77b7..26208f5 100644
--- a/third_data/history_k_data_util.py
+++ b/third_data/history_k_data_util.py
@@ -11,6 +11,8 @@
 from db.redis_manager_delegate import RedisUtils
 from utils import tool, middle_api_protocol
 from db import redis_manager_delegate as redis_manager
+
+
 # import gm.api as gmapi
 
 
@@ -194,7 +196,8 @@
 
 
 class HistoryKDatasUtils(object):
-    __previous_trading_date_cache={}
+    __previous_trading_date_cache = {}
+    __latest_trading_date_cache = {}
 
     @classmethod
     def get_gp_latest_info(cls, codes, fields=None):
@@ -221,6 +224,26 @@
         if fdata:
             cls.__previous_trading_date_cache[date] = fdata
         return fdata
+
+    # 鑾峰彇鏈�杩戠殑浜ゆ槗鏃�
+    @classmethod
+    def get_latest_trading_date(cls, day_count):
+        now_day = tool.get_now_date_str()
+        days = []
+        for i in range(day_count):
+            pday = cls.get_previous_trading_date_cache(now_day)
+            days.append(pday)
+            now_day = pday
+        return days
+
+    @classmethod
+    def get_latest_trading_date_cache(cls, day_count):
+        key = f"{tool.get_now_date_str()}-{day_count}"
+        if key in cls.__latest_trading_date_cache:
+            return cls.__latest_trading_date_cache[key]
+        days = cls.get_latest_trading_date(day_count)
+        cls.__latest_trading_date_cache[key] = days
+        return days
 
     # 杩斿洖鎸囧畾鏃ユ湡鐨勪笅涓氦鏄撴棩
     @classmethod
@@ -285,4 +308,9 @@
 
 if __name__ == "__main__":
     constant.JUEJIN_LOCAL_API = False
-    print(HistoryKDatasUtils.get_lowest_price_rate("000725", 30))
+    print(tool.get_now_time_str())
+    print(HistoryKDatasUtils.get_latest_trading_date(5))
+    print(tool.get_now_time_str())
+    print(HistoryKDatasUtils.get_latest_trading_date(5))
+    print(tool.get_now_time_str())
+    print(HistoryKDatasUtils.get_latest_trading_date(5))
diff --git a/trade/huaxin/huaxin_trade_server.py b/trade/huaxin/huaxin_trade_server.py
index c2a737c..05e4d07 100644
--- a/trade/huaxin/huaxin_trade_server.py
+++ b/trade/huaxin/huaxin_trade_server.py
@@ -464,18 +464,6 @@
         if limit_up_price:
             rate = round(total_deal_nums / (thresh_hold_money // (float(limit_up_price) * 100)), 2)
             LCancelRateManager().set_big_num_deal_rate(code, rate)
-        try:
-            need_cancel, msg = cls.__GCancelBigNumComputer.start_cancel(code, f"{order_no}",
-                                                                        l2_data_util.local_today_datas.get(
-                                                                            code), m_val_num)
-            if need_cancel:
-                # 闇�瑕佹挙鍗�
-                l2_data_manager_new.L2TradeDataProcessor.cancel_buy(code, "G鎾ゆ挙鍗�", "G鎾�")
-                async_log_util.info(logger_l2_g_cancel, f"{code}-闇�瑕佹挙鍗曪細{msg}")
-            else:
-                async_log_util.info(logger_l2_g_cancel, f"{code}-涓嶉渶瑕佹挙鍗曪細{msg}")
-        except Exception as e:
-            async_log_util.error(logger_l2_g_cancel, f"{code}-鎾ゅ崟寮傚父锛歿str(e)}")
 
     @classmethod
     def test_sell(cls):
diff --git a/trade/trade_result_manager.py b/trade/trade_result_manager.py
index efeca7e..f36a3c3 100644
--- a/trade/trade_result_manager.py
+++ b/trade/trade_result_manager.py
@@ -3,7 +3,7 @@
 
 from l2 import l2_data_manager
 from l2.cancel_buy_strategy import HourCancelBigNumComputer, SecondCancelBigNumComputer, \
-    LCancelBigNumComputer, DCancelBigNumComputer, FastCancelBigNumComputer
+    LCancelBigNumComputer, DCancelBigNumComputer, FastCancelBigNumComputer, GCancelBigNumComputer
 from l2.l2_data_manager import OrderBeginPosInfo
 from l2.l2_data_util import local_today_datas, local_today_num_operate_map
 from l2.l2_sell_manager import L2MarketSellManager
@@ -29,6 +29,7 @@
     SecondCancelBigNumComputer().cancel_success(code)
     DCancelBigNumComputer().cancel_success(code)
     LCancelBigNumComputer().cancel_success(code)
+    GCancelBigNumComputer().cancel_success(code)
     # dask.compute(f1, f2, f5, f6, f7, f8)
 
 
@@ -67,6 +68,13 @@
             logging.exception(e)
             logger_l2_error.exception(e)
 
+    def g_cancel(code):
+        try:
+            GCancelBigNumComputer().place_order_success(code)
+        except Exception as e:
+            logging.exception(e)
+            logger_l2_error.exception(e)
+
     order_begin_pos = tradePointManager.get_buy_compute_start_data_cache(
         code)
 
@@ -75,6 +83,7 @@
     # H鎾ゆ殏鏃朵笉鐢熸晥
     h_cancel(code, order_begin_pos.buy_single_index, order_begin_pos.buy_exec_index)
     l_cancel(code)
+    g_cancel(code)
     if order_begin_pos.mode == OrderBeginPosInfo.MODE_FAST:
         f_cancel(code)
         # 璁板綍鍗栫洏缁熻鏃堕棿琚敤
@@ -92,6 +101,7 @@
     DCancelBigNumComputer().cancel_success(code)
     LCancelBigNumComputer().cancel_success(code)
     FastCancelBigNumComputer().cancel_success(code)
+    GCancelBigNumComputer().cancel_success(code)
 
 
 if __name__ == "__main__":

--
Gitblit v1.8.0