Administrator
2024-08-04 fe1b515c6286f80a244e044236fb140ab7090495
third_data/kpl_limit_up_data_manager.py
@@ -35,6 +35,55 @@
    return kpl_data_manager.KPLLimitUpDataRecordManager.total_datas
class CodeLimitUpSequenceManager:
    """
    代码身位管理
    """
    # 首板身位
    __first_block_sequence_dict = {}
    def set_current_limit_up_datas(self, current_limit_up_datas):
        """
        设置目前的涨停代码
        @param current_limit_up_datas:
        @return:
        """
        records = get_today_history_limit_up_datas_cache()
        # 按代码排序
        # {"代码":(代码,涨停原因, 涨停时间, 几版)}
        current_code_block_dict = {x[0]: (x[0], x[2], x[5], x[4]) for x in current_limit_up_datas}
        record_code_block_dict = {x[3]: (x[3], x[2], x[5], x[12]) for x in records}
        # 根据涨停原因统计
        # {"板块":{代码}}
        block_codes = {}
        limit_up_codes = set()
        for code in current_code_block_dict:
            b = current_code_block_dict[code][1]
            if b not in block_codes:
                block_codes[b] = set()
            block_codes[b].add(code)
            limit_up_codes.add(code)
        for code in record_code_block_dict:
            b = record_code_block_dict[code][1]
            if b not in block_codes:
                block_codes[b] = set()
            block_codes[b].add(code)
        for code in limit_up_codes:
            # 计算身位
            b = current_code_block_dict[code][1]
            codes = block_codes[b]
            total_count = len(codes)
            # 统计真正涨停数
            limit_up_count = 0
            for c in codes:
                if c in limit_up_codes:
                    limit_up_count += 1
            # TODO 获取首板代码的排位
class LatestLimitUpBlockManager:
    """
    最近涨停的板块管理
@@ -234,5 +283,3 @@
        rate = int((volumes_data[0]["close"] - min_price) * 100 / min_price)
        cls.__k_max_rate[code] = rate
        return cls.__k_datas.get(code)