Administrator
2024-04-23 3794839eb5e8b3e6ccfaa14e948126dfbc5a1cc1
bug修复
2个文件已修改
42 ■■■■ 已修改文件
constant.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constant.py
@@ -81,6 +81,8 @@
# H撤比例
H_CANCEL_RATE = 0.80
# L撤无法生效的撤单比例
H_CANCEL_RATE_WITH_LDOWN_CANT_INVALID = 0.69
H_CANCEL_MIN_MONEY = 98
H_CANCEL_MIN_COUNT = 40
H_CANCEL_MIN_BIG_NUM_COUNT = 3
l2/cancel_buy_strategy.py
@@ -458,6 +458,9 @@
    # 缓存
    __cancel_watch_indexs_cache = {}
    # L撤触发的代码
    __l_cancel_triggered_codes = set()
    __instance = None
    def __new__(cls, *args, **kwargs):
@@ -531,6 +534,7 @@
        CodeDataCacheUtil.clear_cache(self.__cancel_watch_indexs_cache, code)
        CodeDataCacheUtil.clear_cache(self.__transaction_progress_index_dict, code)
        CodeDataCacheUtil.clear_cache(self.__start_compute_index_dict, code)
        self.__l_cancel_triggered_codes.discard(code)
        ks = [f"h_cancel_watch_indexs-{code}", f"h_cancel_transaction_index-{code}"]
        for key in ks:
            RedisUtils.delete_async(self.__db, key)
@@ -538,6 +542,11 @@
        # 计算观察索引,倒序计算
    def __compute_watch_index(self, code, buy_single_index):
        """
        @param code:
        @param buy_single_index:
        @return:
        """
        if buy_single_index is None:
            return
        if self.__cancel_watch_indexs_cache.get(code):
@@ -556,9 +565,9 @@
            start_compute_index = transaction_index + 1  # max(transaction_index + 1, start_compute_index)
        total_datas = local_today_datas.get(code)
        # h撤计算必须超过5s
        if tool.trade_time_sub(total_datas[-1]["val"]["time"], total_datas[buy_single_index]["val"]["time"]) < 5:
            l2_log.h_cancel_debug(code, "5s内囊括计算H撤")
        # h撤计算必须超过3分钟
        if tool.trade_time_sub(total_datas[-1]["val"]["time"], total_datas[real_place_order_index]["val"]["time"]) < 180:
            l2_log.h_cancel_debug(code, "180s内囊括计算H撤")
            return
        # -----------------计算H上-------------------
        watch_indexes_up = set()
@@ -577,6 +586,7 @@
            if left_count > 0:
                watch_indexes_up.add(i)
                if len(watch_indexes_up) >= 3:
                    # 最多取3笔
                    break
        # ------------------计算H下-----------------------
@@ -587,7 +597,8 @@
        total_num = 0
        # 获取m值数据
        thresh_hold_money = Buy1PriceManager().get_latest_buy1_money(code)
        thresh_hold_money = thresh_hold_money
        # 封单额的1/10
        thresh_hold_money = thresh_hold_money/10
        thresh_hold_num = thresh_hold_money // (float(limit_up_price) * 100)
        end_index = real_place_order_index + 1
        watch_indexes = set()
@@ -617,6 +628,15 @@
        # 设置真实下单位置
    def __need_compute_watch_indexes(self, code, transaction_index):
        """
        1.成交进度位距离真实下单位置<=5笔触发囊括
        2.成交到(下单那一刻的成交进度位)到(真实下单位置)的后1/10处也要触发囊括
        3.L撤无法生效触发囊括
        @param code:
        @param transaction_index:
        @return:
        """
        start_compute_index = self.__start_compute_index_dict.get(code)
        if start_compute_index is None:
            return False
@@ -756,7 +776,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_WITH_LDOWN_CANT_INVALID if code in self.__l_cancel_triggered_codes else constant.H_CANCEL_RATE
            try:
                temp_rate = gpcode_manager.MustBuyCodesManager().get_cancel_rate_cache(code)
                if temp_rate:
@@ -778,6 +798,13 @@
        return {}, set()
    def start_compute_watch_indexes(self, code, buy_single_index):
        """
        L后撤无法生效触发的囊括
        @param code:
        @param buy_single_index:
        @return:
        """
        self.__l_cancel_triggered_codes.add(code)
        self.__compute_watch_index(code, buy_single_index)
@@ -2019,6 +2046,9 @@
            self.__commpute_watch_indexes(code, index, self.__real_place_order_index_dict.get(code))
    def need_cancel(self, code, buy_exec_index, start_index, end_index):
        if 1>0:
            return False, None, "G撤被注释掉"
        if code not in self.__real_place_order_index_dict:
            return False, None, "没有找到真实下单位"
        expire_time = self.__expire_time_dict.get(code)