Administrator
2023-12-05 e024032194fc44350fea977cd8d82b6ab898f9ea
l2/cancel_buy_strategy.py
@@ -1688,6 +1688,7 @@
    __db = 0
    __redis_manager = redis_manager.RedisManager(0)
    __cancel_real_order_index_cache = {}
    __SecondCancelBigNumComputer = SecondCancelBigNumComputer()
    __instance = None
@@ -1706,7 +1707,8 @@
        return cls.__redis_manager.getRedis()
    # 是否可以撤单
    def need_cancel(self, code, order_begin_pos: OrderBeginPosInfo, current_limit_up_block_codes_dict, volume_rate):
    def need_cancel(self, code, transaction_index, order_begin_pos: OrderBeginPosInfo,
                    current_limit_up_block_codes_dict, volume_rate):
        if not order_begin_pos or not order_begin_pos.buy_exec_index or order_begin_pos.buy_exec_index < 0:
            return False, "尚未下单"
        if not current_limit_up_block_codes_dict:
@@ -1724,9 +1726,27 @@
        total_datas = local_today_datas.get(code)
        time_sub = tool.trade_time_sub(tool.get_now_time_str(),
                                       total_datas[order_begin_pos.buy_exec_index]["val"]["time"])
        # if time_sub > 15 * 60:
        #     if len(current_limit_up_block_codes_dict[block]) == 1:
        #         return True, "独苗下单15分钟无后排"
        if 2 < time_sub < 30 * 60:
            real_place_order_index = self.__SecondCancelBigNumComputer.get_real_place_order_index_cache(code)
            if not real_place_order_index:
                return False, "尚未找到真实下单位置"
            total_left_count = 0
            for i in range(transaction_index, real_place_order_index):
                data = total_datas[i]
                val = data["val"]
                if float(val['price']) * val['num'] < 50 * 100:
                    continue
                left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, i,
                                                                                                         total_datas,
                                                                                                         local_today_canceled_buyno_map.get(
                                                                                                             code))
                if left_count > 0:
                    total_left_count += 1
                    if total_left_count > 5:
                        break
            # 成交进度变化
            if len(current_limit_up_block_codes_dict[block]) == 1 and volume_rate < 0.6 and total_left_count <= 5:
                return True, "独苗下单30分钟无后排且成交位离我们很近且量小于60%"
        # if time_sub > 10 * 60:
        #     if len(current_limit_up_block_codes_dict[block]) == 1 and volume_rate < 0.7:
        #         return True, f"独苗下单10分钟无后排且量({volume_rate})小于70%"