Administrator
2024-05-28 517f6c8ce6c68bfcd652ceeb7b79f79408dfec76
third_data/code_plate_key_manager.py
@@ -695,14 +695,20 @@
        block_codes = current_limit_up_block_codes_dict.get(block)
        if block_codes is None:
            block_codes = set()
        # 历史涨停代码
        block_codes_records = set()
        if limit_up_record_datas:
            for k in limit_up_record_datas:
                if block in code_limit_up_reasons_dict.get(k[3]):
                    block_codes_records.add(k[3])
        if not block_codes:
            # 高位板泛化板块中无板块
            if not high_level_block_codes.get(block):
                return False, True, f"{block}:板块无涨停", False, False, 0
                return False, True, f"{block}:板块无涨停", False, False, 0, 0, 0
        elif len(block_codes) == 1 and code in block_codes:
            if not high_level_block_codes.get(block):
                return False, True, f"{block}:板块只有当前代码涨停", False, False, 0
                return False, True, f"{block}:板块只有当前代码涨停", False, False, 0, 0, 0
        # 可以买的最大排名
        # open_limit_up_codes = kpl_block_util.get_shsz_open_limit_up_codes(code, block, limit_up_record_datas,
        #                                                                   code_limit_up_reason_dict)
@@ -752,9 +758,11 @@
        is_active_buy = cls.__is_need_active_buy(code, block, current_shsz_rank, len(current_open_limit_up_codes))
        if current_shsz_rank < len(current_open_limit_up_codes) + max_rank:
            return True, False, f"【{block}】前排代码:{current_shsz_rank}", is_strong_block, is_active_buy, current_shsz_rank
            return True, False, f"【{block}】前排代码:{current_shsz_rank}", is_strong_block, is_active_buy, current_shsz_rank, len(
                block_codes), len(block_codes_records)
        else:
            return False, False, f"【{block}】前排代码:{front_current_shsz_rank_codes} 超过{len(current_open_limit_up_codes) + max_rank}个", is_strong_block, is_active_buy, current_shsz_rank
            return False, False, f"【{block}】前排代码:{front_current_shsz_rank_codes} 超过{len(current_open_limit_up_codes) + max_rank}个", is_strong_block, is_active_buy, current_shsz_rank, len(
                block_codes), len(block_codes_records)
    # 获取可以买的板块
    # current_limit_up_datas: 今日实时涨停
@@ -797,15 +805,17 @@
        code_limit_up_reasons_dict = {}
        load_code_block()
        for block in keys:
            can_buy, unique, msg, is_strong, is_active_buy, current_rank = cls.__is_block_can_buy_new(code, block,
                                                                                                      current_limit_up_datas,
                                                                                                      code_limit_up_reasons_dict,
                                                                                                      yesterday_current_limit_up_codes,
                                                                                                      limit_up_record_datas,
                                                                                                      current_limit_up_block_codes_dict,
                                                                                                      high_level_code_blocks=high_level_general_code_blocks,
                                                                                                      high_level_block_codes=high_level_general_block_codes)
            fresults.append((block, can_buy, unique, msg, is_strong, is_active_buy, current_rank))
            can_buy, unique, msg, is_strong, is_active_buy, current_rank, block_limit_up_count, block_limit_up_record_count = cls.__is_block_can_buy_new(
                code, block,
                current_limit_up_datas,
                code_limit_up_reasons_dict,
                yesterday_current_limit_up_codes,
                limit_up_record_datas,
                current_limit_up_block_codes_dict,
                high_level_code_blocks=high_level_general_code_blocks,
                high_level_block_codes=high_level_general_block_codes)
            fresults.append((block, can_buy, unique, msg, is_strong, is_active_buy, current_rank, block_limit_up_count,
                             block_limit_up_record_count))
        return fresults, keys
    # 是否可以下单
@@ -814,7 +824,7 @@
    @classmethod
    def can_buy(cls, code):
        if constant.TEST:
            return ["测试"], True, cls.BLOCK_TYPE_NONE, [], set(), ["化工"]
            return [("测试", 0, 1, 1)], True, cls.BLOCK_TYPE_NONE, [], set(), ["化工"]
        # if True:
        #     # 测试
        #     return True, "不判断板块身位"
@@ -891,16 +901,17 @@
                # 强势主线最多同时挂3只票,最多成交2只票
                MAX_DELEGATE_COUNT = 3 if r[4] else 2
                MAX_DEAL_COUNT = 2 if r[4] else 1
                if r[0] in trade_success_blocks_count and len(trade_success_blocks_count[r[0]]) >= MAX_DEAL_COUNT:
                    msg_list.append(f"【{r[0]}】有成交代码:{trade_success_blocks_count[r[0]]}")
                    continue
                if r[0] in trade_delegate_blocks_count and len(trade_delegate_blocks_count[r[0]]) >= MAX_DELEGATE_COUNT:
                    msg_list.append(f"【{r[0]}】已挂单:{trade_delegate_blocks_count[r[0]]}")
                    continue
                if len(r)>6:
                    can_buy_blocks.append(f"{r[0]}-{r[6]}")
                # if r[0] in trade_success_blocks_count and len(trade_success_blocks_count[r[0]]) >= MAX_DEAL_COUNT:
                #     msg_list.append(f"【{r[0]}】有成交代码:{trade_success_blocks_count[r[0]]}")
                #     continue
                # if r[0] in trade_delegate_blocks_count and len(trade_delegate_blocks_count[r[0]]) >= MAX_DELEGATE_COUNT:
                #     msg_list.append(f"【{r[0]}】已挂单:{trade_delegate_blocks_count[r[0]]}")
                #     continue
                if len(r) > 8:
                    can_buy_blocks.append((r[0], r[6], r[7], r[8]))
                else:
                    can_buy_blocks.append(f"{r[0]}")
                    # (板块名称,身位,板块涨停数量)
                    can_buy_blocks.append((r[0], 0, 1, 1))
                if r[4]:
                    can_buy_strong_blocks.append(r[0])
                if r[3]: