Administrator
2023-10-17 918cf8f252cc5b959f177acdb64395e0ad67cc47
H撤异常保护
1个文件已修改
64 ■■■■ 已修改文件
l2/cancel_buy_strategy.py 64 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py
@@ -564,38 +564,44 @@
    # 设置成交进度
    def set_transaction_index(self, code, index):
        if index == self.__transaction_progress_index_dict.get(code):
            return
        self.__transaction_progress_index_dict[code] = index
        if self.__need_compute_watch_indexes(code, index):
            self.__compute_watch_index(code)
        try:
            if index == self.__transaction_progress_index_dict.get(code):
                return
            self.__transaction_progress_index_dict[code] = index
            if self.__need_compute_watch_indexes(code, index):
                self.__compute_watch_index(code)
        except Exception as e:
            l2_log.h_cancel_debug(code, "设置成交进度位置出错:{}", str(e))
    # 设置真实下单位置
    def set_real_place_order_index(self, code, index, buy_single_index):
        # 计算触发位置
        min_num = int(5000 / (float(gpcode_manager.get_limit_up_price(code))))
        # 统计净涨停买的数量
        not_cancel_indexes = []
        total_datas = local_today_datas.get(code)
        for j in range(buy_single_index, index):
            data = total_datas[j]
            val = data['val']
            if not L2DataUtil.is_limit_up_price_buy(val):
                continue
            if val["num"] < min_num:
                continue
            left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code,
                                                                                                     j,
                                                                                                     total_datas,
                                                                                                     local_today_canceled_buyno_map.get(
                                                                                                         code))
            if left_count > 0:
                not_cancel_indexes.append(j)
        if not_cancel_indexes:
            temp_count = len(not_cancel_indexes)
            # 取后1/3的数据
            temp_index = int(temp_count * 9 / 10)
            self.__start_compute_index_dict[code] = not_cancel_indexes[temp_index]
        try:
            # 计算触发位置
            min_num = int(5000 / (float(gpcode_manager.get_limit_up_price(code))))
            # 统计净涨停买的数量
            not_cancel_indexes = []
            total_datas = local_today_datas.get(code)
            for j in range(buy_single_index, index):
                data = total_datas[j]
                val = data['val']
                if not L2DataUtil.is_limit_up_price_buy(val):
                    continue
                if val["num"] < min_num:
                    continue
                left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code,
                                                                                                         j,
                                                                                                         total_datas,
                                                                                                         local_today_canceled_buyno_map.get(
                                                                                                             code))
                if left_count > 0:
                    not_cancel_indexes.append(j)
            if not_cancel_indexes:
                temp_count = len(not_cancel_indexes)
                # 取后1/3的数据
                temp_index = int(temp_count * 9 / 10)
                self.__start_compute_index_dict[code] = not_cancel_indexes[temp_index]
        except Exception as e:
            l2_log.h_cancel_debug(code, "设置真实下单位置出错:{}", str(e))
    def need_cancel(self, code, buy_single_index, buy_exec_index, start_index, end_index, total_data,
                    buy_volume_index, volume_index,