Administrator
2024-01-16 1128f9b16dbf6d3ff8083cb2a6a5a860c1ada57d
l2/cancel_buy_strategy.py
@@ -1736,7 +1736,7 @@
        watch_indexes_by = self.__watch_indexes_by_dict.get(code)
        if watch_indexes_by is None:
            watch_indexes_by = set()
        need_compute = False
        for i in range(start_index, end_index + 1):
            data = total_datas[i]
            val = data["val"]
@@ -1749,7 +1749,28 @@
                                                                                                    code))
            if buy_index is not None and buy_index < real_place_order_index and (
                    buy_index in watch_indexes or buy_index in watch_indexes_by):
                if buy_index in watch_indexes_by:
                    # 备用撤单,直接撤
                return True, data, ""
                elif buy_index in watch_indexes:
                    # 大单撤需要重新计算大单撤单比例
                    need_compute = True
                    break
        if need_compute:
            canceled_indexes = set()
            for index in watch_indexes:
                cancel_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2(code, index,
                                                                                                      total_datas,
                                                                                                      local_today_canceled_buyno_map.get(
                                                                                                          code))
                if cancel_data:
                    canceled_indexes.add(cancel_data["index"])
            cancel_rate = len(canceled_indexes) / len(watch_indexes)
            if cancel_rate > 0.2:
                canceled_indexes_list = list(canceled_indexes)
                canceled_indexes_list.sort()
                return True, total_datas[canceled_indexes_list[-1]], f"撤单比例:{cancel_rate}"
        return False, None, ""
    def place_order_success(self, code):