Administrator
2023-12-28 6ebf3a8a4a1b48547633de879a26014b77feec46
l2/cancel_buy_strategy.py
@@ -827,13 +827,13 @@
    __big_num_deal_rate_dict = {}
    __MustBuyCodesManager = gpcode_manager.MustBuyCodesManager()
    # 获取撤单比例
    # 获取撤单比例,返回(撤单比例,是否必买)
    @classmethod
    def get_cancel_rate(cls, code, is_up=False):
        try:
            must_buy_cancel_rate = cls.__MustBuyCodesManager.get_cancel_rate_cache(code)
            if must_buy_cancel_rate is not None:
                return must_buy_cancel_rate
                return must_buy_cancel_rate, True
        except Exception as e:
            async_log_util.error(logger_l2_l_cancel, str(e))
@@ -864,7 +864,7 @@
            base_rate += deal_rate
        except Exception as e:
            l2_log.l_cancel_debug(code, f"计算撤单比例出错:{e}")
        return round(base_rate, 2)
        return round(base_rate, 2), False
    # 设置板块涨停数量(除开自己)
    @classmethod
@@ -1325,10 +1325,11 @@
                #     return True, total_data[-1]
            rate = round(canceled_num / total_num, 3)
            thresh_hold_rate = LCancelRateManager.get_cancel_rate(code)
            thresh_hold_rate, must_buy = 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)
            if not must_buy:
                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()
@@ -1390,7 +1391,7 @@
                    else:
                        canceled_count_weight += WATCH_INDEX_WEIGHTS[-1]
            rate = round(canceled_count_weight / total_count_weight, 3)
            thresh_cancel_rate = LCancelRateManager.get_cancel_rate(code, is_up=True)
            thresh_cancel_rate, must_buy = LCancelRateManager.get_cancel_rate(code, is_up=True)
            l2_log.l_cancel_debug(code, f"计算范围:{start_index}-{end_index},成交位临近已撤单比例:{rate}/{thresh_cancel_rate}")
            if rate >= thresh_cancel_rate:
                # 计算成交进度位置到当前下单位置的纯买额
@@ -1450,7 +1451,7 @@
            total_nums += val["num"]
            if left_count > 0 and index < trade_index:
                total_deal_nums += val["num"]
        thresh_hold_rate = LCancelRateManager.get_cancel_rate(code)
        thresh_hold_rate, must_buy = LCancelRateManager.get_cancel_rate(code)
        if total_deal_nums / total_nums > 1 - thresh_hold_rate - 0.05:
            return False
        return True