Administrator
2023-11-24 d6b6be5eb2ae00a8ccf46bd7d53cd7d0c1e59c72
third_data/code_plate_key_manager.py
@@ -6,6 +6,7 @@
import json
import constant
from code_attribute.code_nature_analyse import HighIncreaseCodeManager
from db.redis_manager_delegate import RedisUtils
from third_data import kpl_block_util, kpl_api
from utils import global_util, tool
@@ -89,14 +90,13 @@
                if not self.get_jx_blocks_cache(code):
                    blocks = kpl_api.getCodeJingXuanBlocks(code)
                    self.save_jx_blocks(code, blocks)
                    async_log_util.info(logger_kpl_block_can_buy,f"{code}:获取到精选板块-{blocks}")
                    async_log_util.info(logger_kpl_block_can_buy, f"{code}:获取到精选板块-{blocks}")
            elif price_rate > 0.03:
                # 添加备用板块
                if not self.get_jx_blocks_cache(code, by=True):
                    blocks = kpl_api.getCodeJingXuanBlocks(code)
                    self.save_jx_blocks(code, blocks, by=True)
                    async_log_util.info(logger_kpl_block_can_buy, f"{code}:获取到精选板块(备用)-{blocks}")
# 开盘啦禁止交易板块管理
@@ -467,26 +467,36 @@
        # msg_list.append(f"\n实时top10(涨停数量:{len(current_limit_up_datas)})")
        # msg_list.append(f"历史top20(涨停数量:{len(top_8_record)})")
        # 需要排除的老大的代码
        exclude_first_codes = HighIncreaseCodeManager().list_all()
        # 获取主板开1的代码
        open_limit_up_codes = kpl_block_util.get_shsz_open_limit_up_codes(code, block, limit_up_record_datas,
                                                                          code_limit_up_reason_dict)
        # 剔除高位板
        if open_limit_up_codes and yesterday_current_limit_up_codes:
            open_limit_up_codes -= yesterday_current_limit_up_codes
        # 获取主板实时身位,剔除高位板
        current_shsz_rank, front_current_shsz_rank_codes = kpl_block_util.get_code_current_rank(code, block,
                                                                                                current_limit_up_datas,
                                                                                                code_limit_up_reason_dict,
                                                                                                yesterday_current_limit_up_codes,
                                                                                                exclude_first_codes,
                                                                                                len(open_limit_up_codes),
                                                                                                shsz=True)
        record_shsz_rank, record_shsz_rank_codes = kpl_block_util.get_code_record_rank(code, block,
                                                                                       limit_up_record_datas,
                                                                                       code_limit_up_reason_dict,
                                                                                       yesterday_current_limit_up_codes,
                                                                                       shsz=True)
        # 获取主板历史身位
        open_limit_up_codes = kpl_block_util.get_shsz_open_limit_up_codes(code, block, limit_up_record_datas,
                                                                          code_limit_up_reason_dict)
        if open_limit_up_codes:
            # 主板开1
            if current_shsz_rank < len(open_limit_up_codes) + 1 and record_shsz_rank < len(open_limit_up_codes) + 2:
                # 属于龙1,龙2
                return True, f"{tool.get_now_time_str()} {block}:top10涨停板块,主板开1({open_limit_up_codes}),属于主板前龙{len(open_limit_up_codes) + 1}(实时身位-{current_shsz_rank}/{len(current_limit_up_datas)})"
                return True, f"{tool.get_now_time_str()} {block}:top10涨停板块,主板开1({open_limit_up_codes}),属于主板前龙{len(open_limit_up_codes) + 1}(实时身位-{current_shsz_rank}:{front_current_shsz_rank_codes}/{len(current_limit_up_datas)})"
            else:
                if record_shsz_rank >= len(open_limit_up_codes) + 1:
                    cls.__remove_from_l2(code, f"{code}根据身位禁止买入:【{block}】历史身位{record_shsz_rank}")
@@ -511,11 +521,12 @@
                          before_blocks_dict):
        # 加载涨停代码的目标板块
        def load_code_block():
            for d in limit_up_record_datas:
                if d[2] in constant.KPL_INVALID_BLOCKS and d[3] in before_blocks_dict:
                    code_limit_up_reason_dict[d[3]] = list(before_blocks_dict.get(d[3]))[0]
                else:
                    code_limit_up_reason_dict[d[3]] = d[2]
            if limit_up_record_datas:
                for d in limit_up_record_datas:
                    if d[2] in constant.KPL_INVALID_BLOCKS and d[3] in before_blocks_dict:
                        code_limit_up_reason_dict[d[3]] = list(before_blocks_dict.get(d[3]))[0]
                    else:
                        code_limit_up_reason_dict[d[3]] = d[2]
            return code_limit_up_reason_dict
        if current_limit_up_datas is None: