Administrator
2024-11-04 65afea1ba534b51f947cbe7989d7f4d650bbc9e6
third_data/code_plate_key_manager.py
@@ -293,12 +293,6 @@
    def get_today_limit_up_reason(cls, code):
        return cls.__today_total_limit_up_reason_dict.get(code)
    # 今日涨停原因变化
    def set_today_limit_up_reason_change(self, code, from_reason, to_reason):
        RedisUtils.sadd(self.__get_redis(), f"kpl_limit_up_reason_his-{code}", from_reason)
        RedisUtils.expire(self.__get_redis(), f"kpl_limit_up_reason_his-{code}", tool.get_expire())
        self.__set_total_keys(code)
    # 设置代码的今日涨停原因
    def __set_total_keys(self, code):
        keys = set()
@@ -335,6 +329,8 @@
                if codes:
                    fresult[k] = codes
        return fresult
# 实时开盘啦市场数据
@@ -378,7 +374,7 @@
        """
        blocks = set()
        for i in range(0, len(datas)):
            if i >= 10 and int(tool.get_now_time_str().replace(":","")) < int("100000"):
            if i >= 10 and int(tool.get_now_time_str().replace(":", "")) < int("100000"):
                # 10点前看前10,十点后不看前10
                break
            data = datas[i]
@@ -927,7 +923,8 @@
            current_limit_up_datas = []
        # 获取目标代码板块
        keys, k1, k11, k2, k3, k4 = cls.__TargetCodePlateKeyManager.get_plate_keys(code)
        # keys, k1, k11, k2, k3, k4 = cls.__TargetCodePlateKeyManager.get_plate_keys(code)
        keys, k1 = RadicalBuyBlockManager.get_code_blocks(code)
        # log.logger_kpl_debug.info("{}最终关键词:{}", code, keys)
@@ -936,10 +933,6 @@
        fresults = []
        if not keys:
            return fresults, set()
        # 获取精选流出板块
        jx_out_blocks = RealTimeKplMarketData.get_top_market_jingxuan_out_blocks()
        if jx_out_blocks:
            keys -= jx_out_blocks
        code_limit_up_reasons_dict = {}
        load_code_block()
@@ -1113,7 +1106,7 @@
class RadicalBuyBlockManager:
    """
    激进买板块管理
    扫入买板块管理
    """
    __TargetCodePlateKeyManager = TargetCodePlateKeyManager()
    # 上次的涨停代码
@@ -1206,6 +1199,10 @@
            limit_up_time = time.time()
        for k in LimitUpDataConstant.current_limit_up_datas:
            _code = k[0]
            # 剔除4板以上的板
            if kpl_util.get_high_level_count(k[4]) >= 4:
                continue
            if _code in exclude_codes:
                continue
            blocks = LimitUpDataConstant.get_blocks_with_history(_code)
@@ -1261,6 +1258,11 @@
        limit_up_space_ge_60s_codes = set()
        for k in LimitUpDataConstant.history_limit_up_datas:
            _code = k[3]
            # 剔除4板以上的板
            if kpl_util.get_high_level_count(k[12]) >= 4:
                continue
            if _code in exclude_codes:
                continue
            blocks = LimitUpDataConstant.get_blocks_with_history(_code)
@@ -1365,8 +1367,8 @@
            if RedicalBuyDataManager.can_buy(history_before_codes_info[0][0],
                                             DealAndDelegateWithBuyModeDataManager().get_deal_codes())[0]:
                return False, f"开1数量:{count},前排代码可买:{history_before_codes_info[0]}"
            return True, f"开1数量:{count},前排代码不可买:{history_before_codes_info[0]}"
        return True, f"开1数量:{count},历史-{history_index + 1} 实时-{current_index + 1}"
            return True, f"开1数量:{count},前排代码不可买:{history_before_codes_info[0]},历史前排-{history_before_codes_info},开1代码-{open_limit_up_block_codes}"
        return True, f"开1数量:{count},历史-{history_index + 1} 实时-{current_index + 1}, 前排代码-{current_before_codes_info}, 开1代码-{open_limit_up_block_codes}"
    @classmethod
    def __is_radical_buy_with_block_up(cls, code, block, yesterday_limit_up_codes):
@@ -1447,12 +1449,12 @@
            else:
                # 距离上个代码涨停5分钟以内
                if tool.trade_time_sub(tool.timestamp_format(limit_up_timestamp, '%H:%M:%S'),
                                       tool.timestamp_format(current_before_codes_info[-1][1], '%H:%M:%S')) >= 5 * 60:
                    return False, f"距离上个代码涨停已过去5分钟({current_before_codes_info[-1]})"
                                       tool.timestamp_format(current_before_codes_info[-1][1], '%H:%M:%S')) >= 10 * 60:
                    return False, f"距离上个代码涨停已过去10分钟({current_before_codes_info[-1]})"
        else:
            if tool.trade_time_sub(tool.timestamp_format(limit_up_timestamp, '%H:%M:%S'),
                                   tool.timestamp_format(current_before_codes_info[-1][1], '%H:%M:%S')) >= 5 * 60:
                return False, f"距离上个代码涨停已过去5分钟({current_before_codes_info[-1]})"
                                   tool.timestamp_format(current_before_codes_info[-1][1], '%H:%M:%S')) >= 10 * 60:
                return False, f"距离上个代码涨停已过去10分钟({current_before_codes_info[-1]})"
        return True, f"满足买入需求: 前排代码-{current_before_codes_info}"
@@ -1547,7 +1549,7 @@
            fblocks |= BlockMapManager().filter_blocks(kpl_history_blocks)
        jx_out_blocks = RealTimeKplMarketData.get_top_market_jingxuan_out_blocks()
        if jx_out_blocks:
            fblocks-=jx_out_blocks
            fblocks -= jx_out_blocks
        return fblocks, match_blocks