Administrator
2023-10-11 826084fc7c11c5e2776b73342e6c1ed2f1a99b02
l2/cancel_buy_strategy.py
@@ -408,8 +408,9 @@
    # 保存成交位置到执行位置的揽括范围数据
    def __save_watch_index_set(self, code, indexes):
        trade_record_log_util.add_cancel_watch_indexes_log(code,
                                                           CancelWatchIndexesInfo(CancelWatchIndexesInfo.CANCEL_TYPE_H,
                                                                                  list(indexes)))
                                                           trade_record_log_util.CancelWatchIndexesInfo(
                                                               trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_H,
                                                               list(indexes)))
        CodeDataCacheUtil.set_cache(self.__cancel_watch_indexs_cache, code, indexes)
        key = f"h_cancel_watch_indexs-{code}"
        RedisUtils.setex_async(self.__db, key, tool.get_expire(),
@@ -752,9 +753,7 @@
    def __add_watch_indexes(self, code, indexes):
        if not indexes:
            return
        trade_record_log_util.add_cancel_watch_indexes_log(code,
                                                           trade_record_log_util.CancelWatchIndexesInfo(trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_L_DOWN,
                                                                                  list(indexes)))
        if code not in self.__cancel_watch_index_cache:
            self.__cancel_watch_index_cache[code] = set()
        for index in indexes:
@@ -775,6 +774,11 @@
        RedisUtils.delete_async(self.__db, f"l_cancel_watch_index-{code}")
        for index in indexes:
            RedisUtils.srem_async(self.__db, f"l_cancel_watch_index-{code}", index)
        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,
                                                                   list(indexes)))
    def __get_watch_indexes(self, code):
        return RedisUtils.smembers(self.__get_redis(), f"l_cancel_watch_index-{code}")
@@ -1036,7 +1040,8 @@
        # 下单位临近撤
        can_cancel, cancel_data = False, None
        try:
            can_cancel, cancel_data = self.__compute_need_cancel(code, buy_exec_index, start_index, end_index, total_data,
            can_cancel, cancel_data = self.__compute_need_cancel(code, buy_exec_index, start_index, end_index,
                                                                 total_data,
                                                                 is_first_code)
        except Exception as e:
            logger_l2_l_cancel.exception(e)