Administrator
2023-11-09 13663fc5a29800ab0036e6f2dcdc79ef726f8035
错误日志定位
2个文件已修改
37 ■■■■ 已修改文件
l2/cancel_buy_strategy.py 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py
@@ -807,7 +807,8 @@
                if temp_rate >= 1:
                    if temp_rate > 3:
                        temp_rate = 3
                    deal_rate = round((temp_rate * 3.5 - 2.5) / 100, 4) if is_up else round((temp_rate * 10.5 - 7.5) / 100, 4)
                    deal_rate = round((temp_rate * 3.5 - 2.5) / 100, 4) if is_up else round(
                        (temp_rate * 10.5 - 7.5) / 100, 4)
            base_rate += block_rate
            base_rate += deal_rate
@@ -905,7 +906,8 @@
        if indexes:
            trade_record_log_util.add_cancel_watch_indexes_log(code,
                                                               trade_record_log_util.CancelWatchIndexesInfo(
                                                                   trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_L_DOWN,buy_single_index,
                                                                   trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_L_DOWN,
                                                                   buy_single_index,
                                                                   list(indexes)))
    def __get_watch_indexes(self, code):
@@ -921,7 +923,8 @@
        if indexes:
            trade_record_log_util.add_cancel_watch_indexes_log(code,
                                                               trade_record_log_util.CancelWatchIndexesInfo(
                                                                   trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_L_UP,buy_single_index,
                                                                   trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_L_UP,
                                                                   buy_single_index,
                                                                   list(indexes)))
        self.__near_by_trade_progress_index_cache[code] = indexes
        RedisUtils.setex_async(self.__db, f"l_cancel_near_by_index-{code}", tool.get_expire(),
@@ -960,6 +963,8 @@
    # 计算观察索引,倒序计算
    def compute_watch_index(self, code, buy_single_index, start_index, end_index):
        try:
            l2_log.l_cancel_debug(code, f"计算L后囊括范围:{start_index}-{end_index}")
        total_datas = local_today_datas.get(code)
        if total_datas:
            # 计算的上截至位距离下截至位纯买额要小于2.5倍m值
@@ -1009,7 +1014,8 @@
                        # 小金额过滤
                        if float(val['price']) * val['num'] < min_money * 100:
                            continue
                        left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code,
                            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(
@@ -1044,7 +1050,8 @@
                        # 小金额过滤
                        if float(val['price']) * val['num'] < 100 * 100:
                            continue
                        left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code,
                            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(
@@ -1054,14 +1061,19 @@
                            break
                self.__set_watch_indexes(code,buy_single_index, watch_indexes)
                l2_log.l_cancel_debug(code, f"设置监听范围, 数据范围:{re_start_index}-{end_index} 监听范围-{watch_indexes}")
        except Exception as e:
            l2_log.l_cancel_debug(code, f"计算L后囊括范围出错:{str(e)}")
            async_log_util.exception(logger_l2_l_cancel, e)
    # 设置真实下单位置
    def set_real_place_order_index(self, code, index, buy_single_index=None):
        l2_log.l_cancel_debug(code, f"设置真实下单位-{index},buy_single_index-{buy_single_index}")
        self.__real_place_order_index_dict[code] = index
        if buy_single_index:
            self.compute_watch_index(code, buy_single_index, buy_single_index, index)
        if self.__last_trade_progress_dict.get(code):
            self.__compute_trade_progress_near_by_indexes(code,buy_single_index, self.__last_trade_progress_dict.get(code) + 1, index)
            self.__compute_trade_progress_near_by_indexes(code, buy_single_index,
                                                          self.__last_trade_progress_dict.get(code) + 1, index)
        else:
            self.__compute_trade_progress_near_by_indexes(code, buy_single_index, buy_single_index, index)
@@ -1072,7 +1084,8 @@
        if code not in self.__real_place_order_index_dict:
            return
        if code not in self.__last_l_up_compute_info or time.time() - self.__last_l_up_compute_info[code][0] >= 3:
            self.__compute_trade_progress_near_by_indexes(code,buy_single_index, self.__last_trade_progress_dict.get(code) + 1,
            self.__compute_trade_progress_near_by_indexes(code, buy_single_index,
                                                          self.__last_trade_progress_dict.get(code) + 1,
                                                          self.__real_place_order_index_dict.get(code))
    # 计算范围内的成交位临近未撤大单
@@ -1121,7 +1134,8 @@
        self.__last_trade_progress_dict[code] = index
        # 重新计算成交位置临近大单撤单
        self.__compute_trade_progress_near_by_indexes(code, buy_single_index, index + 1, self.__real_place_order_index_dict.get(code))
        self.__compute_trade_progress_near_by_indexes(code, buy_single_index, index + 1,
                                                      self.__real_place_order_index_dict.get(code))
        # 成交进度与L下撤无关
        # try:
@@ -1140,7 +1154,6 @@
    def __compute_need_cancel(self, code, buy_exec_index, start_index, end_index, total_data, is_first_code):
        watch_indexes = self.__get_watch_indexes_cache(code)
        if not watch_indexes:
            return False, None
        watch_indexes = set([int(i) for i in watch_indexes])
        # 计算监听的总条数
l2/l2_data_manager_new.py
@@ -295,6 +295,7 @@
                l2_log.debug(code, "触发撤单,撤单位置:{} ,撤单原因:{}", index, "F撤不够2笔触发撤单")
                cls.cancel_buy(code, msg="F撤不够2笔触发撤单")
                return
        l2_log.debug(code, "设置真实下单位:{}",index)
        cancel_buy_strategy.set_real_place_position(code, index, order_begin_pos.buy_single_index)
    # 处理华鑫L2数据
@@ -485,7 +486,8 @@
                    logging.exception(e)
                async_log_util.error(logger_l2_error,
                                     f"H撤出错 参数:buy_single_index-{_buy_single_index} buy_exec_index-{_buy_exec_index} {str(e)}")
                async_log_util.exception(logger_l2_error, e)
                # async_log_util.exception(logger_l2_error, e)
                logger_l2_error.exception(e)
            finally:
                # l2_data_log.l2_time(code, round(t.time() * 1000) - _start_time, "已下单-H撤大单计算")
                pass
@@ -520,7 +522,7 @@
            except Exception as e:
                async_log_util.error(logger_l2_error,
                                     f"L撤出错 参数:buy_single_index-{_buy_single_index} buy_exec_index-{_buy_exec_index} 错误原因:{str(e)}")
                logger_l2_error.exception(e)
                # logger_l2_error.exception(e)
                async_log_util.exception(logger_l2_error, e)
            finally:
                # l2_data_log.l2_time(code, round(t.time() * 1000) - _start_time, "已下单-L撤大单计算")