| | |
| | | BUY_SCORE_RANK_3 = 260 |
| | | |
| | | # 开盘啦 |
| | | KPL_INVALID_BLOCKS = ["一季报增长", "二季报增长", "三季报增长", "四季报增长", "业绩增长", "中报增长", "年报增长", "年报预增", "无", "次新股", "ST摘帽", "超跌", |
| | | "股权转让", "并购重组", "再融资", "年报预增", " 专精特新", "壳资源", "行业龙头", "参股金融", "科创板"] |
| | | KPL_INVALID_BLOCKS = {"一季报增长", "二季报增长", "三季报增长", "四季报增长", "业绩增长", "中报增长", "年报增长", "年报预增", "无", "次新股", "ST摘帽", "超跌", |
| | | "股权转让", "并购重组", "再融资", "年报预增", " 专精特新", "壳资源", "行业龙头", "参股金融", "科创板"} |
| | | # 是否开启API交易 |
| | | API_TRADE_ENABLE = True |
| | | # 每只票买的金额 |
| | |
| | | limit_up_time_manager, global_data_loader, gpcode_manager |
| | | import constant |
| | | from l2.huaxin import l2_huaxin_util, huaxin_delegate_postion_manager |
| | | from third_data import kpl_data_manager |
| | | from third_data import kpl_data_manager, block_info |
| | | from utils import global_util, ths_industry_util, tool |
| | | import l2_data_util |
| | | from db import redis_manager |
| | |
| | | zyltgb = global_util.zyltgb_map.get(code) |
| | | if zyltgb >= 80 * 100000000: |
| | | return True, False, "{9:30:00-9:35:00}自由市值≥80亿" |
| | | |
| | | # 获取涨停 |
| | | latest_2_day_limit_up_datas_temp = kpl_data_manager.get_current_limit_up_data_records(2) |
| | | latest_2_day_limit_up_datas = [] |
| | | for d in latest_2_day_limit_up_datas_temp: |
| | | latest_2_day_limit_up_datas.extend(d[1]) |
| | | # 判断板块 |
| | | plate_can_buy, msg, block_type = CodePlateKeyBuyManager.can_buy(code, |
| | | plate_can_buy, msg = CodePlateKeyBuyManager.can_buy(code, |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.latest_origin_datas, |
| | | latest_2_day_limit_up_datas, |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.total_datas) |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.total_datas,block_info.get_before_blocks_dict()) |
| | | if not plate_can_buy: |
| | | return False, True, msg |
| | | |
| | | has_k_format = is_has_k_format(score_info) |
| | | # 独苗 |
| | | if block_type == CodePlateKeyBuyManager.BLOCK_TYPE_START_UP: |
| | | # 必须满足(分数≥150且上板时量≥40 % 且有K线形态)或(具有辨识度)的才能买 |
| | | if has_k_format and score_index >= 0 and volume_rate_info[0] >= 0.4: |
| | | return True, False, "独苗:分数≥150且上板时量≥40% 且有K线形态" |
| | | elif score_info[1][3][8][0]: |
| | | return True, False, "独苗:具有辨识度" |
| | | else: |
| | | return False, True, f"独苗:不满足买入条件" |
| | | else: |
| | | return True, False, msg |
| | | |
| | | # if volume_rate_info[0] < 0.4: |
| | |
| | | return __before_block_dict.get(code) |
| | | |
| | | |
| | | # 获取之前的板块 |
| | | def get_before_blocks(code): |
| | | return __before_block_dict.get(code) |
| | | |
| | | |
| | | # 获取之前的代码-板块字典 |
| | | def get_before_blocks_dict(): |
| | | return __before_block_dict |
| | | |
| | | |
| | | def __get_code_from_code_info(code_info): |
| | | code = code_info[0][1].split(".")[0] |
| | | return code |
| | |
| | | from third_data import kpl_data_manager |
| | | from third_data import kpl_data_manager, block_info |
| | | from third_data.code_plate_key_manager import CodePlateKeyBuyManager, LimitUpCodesPlateKeyManager |
| | | from third_data.kpl_util import KPLDataType |
| | | from utils import tool |
| | | |
| | | if __name__ == "__main__": |
| | | code = "002559" |
| | | latest_2_day_limit_up_datas_temp = kpl_data_manager.get_current_limit_up_data_records(2) |
| | | latest_2_day_limit_up_datas = [] |
| | | for d in latest_2_day_limit_up_datas_temp: |
| | | latest_2_day_limit_up_datas.extend(d[1]) |
| | | |
| | | code = "002655" |
| | | block_info.init() |
| | | current_limit_up_datas = kpl_data_manager.KPLDataManager().get_from_file(KPLDataType.LIMIT_UP, |
| | | tool.get_now_date_str()) |
| | | LimitUpCodesPlateKeyManager().set_today_limit_up([(d[0], d[5]) for d in current_limit_up_datas]) |
| | | |
| | | limit_up_record_datas = kpl_data_manager.KPLLimitUpDataRecordManager.list_all(tool.get_now_date_str()) |
| | | results = CodePlateKeyBuyManager.get_can_buy_block(code, current_limit_up_datas, latest_2_day_limit_up_datas, |
| | | limit_up_record_datas) |
| | | for d in limit_up_record_datas: |
| | | block_info.init_code(d[3]) |
| | | results = CodePlateKeyBuyManager.get_can_buy_block(code, current_limit_up_datas, |
| | | limit_up_record_datas, block_info.get_before_blocks_dict()) |
| | | print(results) |
| | |
| | | self.__get_redis().expire(f"kpl_limit_up_reason_his-{code}", tool.get_expire()) |
| | | self.__set_total_keys(code) |
| | | |
| | | # 设置代码的今日涨停原因 |
| | | def __set_total_keys(self, code): |
| | | keys = set() |
| | | keys_his = self.__get_redis().smembers(f"kpl_limit_up_reason_his-{code}") |
| | | keys |= keys_his |
| | | # keys_his = self.__get_redis().smembers(f"kpl_limit_up_reason_his-{code}") |
| | | # keys |= keys_his |
| | | if code in self.today_limit_up_reason_dict: |
| | | if self.today_limit_up_reason_dict.get(code) not in constant.KPL_INVALID_BLOCKS: |
| | | keys.add(self.today_limit_up_reason_dict.get(code)) |
| | | self.total_code_keys_dict[code] = keys |
| | | for k in keys: |
| | |
| | | self.total_key_codes_dict[k].add(code) |
| | | |
| | | logger_kpl_limit_up.info("{}板块关键词:{}", code, keys) |
| | | |
| | | # 根据传入的关键词与涨停代码信息匹配身位 |
| | | |
| | | def get_codes_by_key_without_mine(self, key, code): |
| | | # 只比较今日涨停原因 |
| | |
| | | # latest_2_day_limit_up_datas:最近2天的实时涨停(不含今日) |
| | | # limit_up_record_datas:今日历史涨停 |
| | | @classmethod |
| | | def get_can_buy_block(cls, code, current_limit_up_datas, latest_2_day_limit_up_datas, limit_up_record_datas): |
| | | def get_can_buy_block(cls, code, current_limit_up_datas, limit_up_record_datas, |
| | | 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] |
| | | return code_limit_up_reason_dict |
| | | |
| | | now_time = int(tool.get_now_time_str().replace(":", "")) |
| | | times = [100000, 103000, 110000, 133000, 150000] |
| | | time_index = 0 |
| | |
| | | if now_time < times[i]: |
| | | time_index = i |
| | | break |
| | | # 获取板块 |
| | | # 获取目标代码板块 |
| | | keys, k1, k11, k2, k3, k4 = cls.__TargetCodePlateKeyManager.get_plate_keys(code) |
| | | log.logger_kpl_debug.info("{}关键词:今日-{},今日历史-{},历史-{},二级行业-{},代码板块-{}", code, k1, k11, k2, k3, k4) |
| | | keys = set() |
| | | if k3: |
| | | # 匹配二级行业 |
| | | keys |= k3 |
| | | if k1: |
| | | # 有今日涨停原因 |
| | | keys |= k1 |
| | | pass |
| | | elif k2: |
| | | # 今日无涨停但有历史涨停 |
| | | keys |= k2 |
| | | else: |
| | | if k4: |
| | | keys |= k4 |
| | | for k in k1: |
| | | if k not in constant.KPL_INVALID_BLOCKS: |
| | | keys.add(k) |
| | | if not keys: |
| | | for k in k2: |
| | | if k not in constant.KPL_INVALID_BLOCKS: |
| | | keys.add(k) |
| | | if not keys: |
| | | if k3: |
| | | keys |= k3 |
| | | log.logger_kpl_debug.info("{}最终关键词:{}", code, keys) |
| | | |
| | | # 涨停列表中匹配关键词,返回(板块:代码集合),代码集合中已经排除自身 |
| | | match_limit_up_result = cls.__LimitUpCodesPlateKeyManager.match_limit_up_reason_keys(code, keys) |
| | | log.logger_kpl_debug.info("{}关键词身位匹配结果:{}", code, match_limit_up_result) |
| | | if not match_limit_up_result: |
| | | return cls.BLOCK_TYPE_NONE, None, "未在涨停列表中未匹配到涨停原因" |
| | | # 获取板块归类 |
| | | for block in match_limit_up_result: |
| | | # 获取强势板块 |
| | | strong_result = kpl_block_util.is_strong_block(block, current_limit_up_datas, latest_2_day_limit_up_datas) |
| | | # 获取猛拉板块 |
| | | soon_limit_up_result = kpl_block_util.is_soon_limit_up(code, block, limit_up_record_datas) |
| | | |
| | | # 获取身位 |
| | | rank = kpl_block_util.get_code_rank(code, block, limit_up_record_datas) |
| | | # 主板身位 |
| | | sh_sz_rank = kpl_block_util.get_sh_sz_code_rank(code, block, limit_up_record_datas) |
| | | # 是否后排 |
| | | is_back_row = kpl_block_util.is_back_row(code, block, current_limit_up_datas) |
| | | |
| | | # 是否满足市场流入前几 |
| | | is_in_top_input = RealTimeKplMarketData.is_in_top(set([block]))[0] |
| | | |
| | | log.logger_kpl_debug.info("{}-{} 板块判断结果:强势板块-{} 猛拉板块-{} 身位-{} 主板身位-{} 是否后排-{} 是否在流入前排-{}", code, block, |
| | | strong_result, soon_limit_up_result, rank, sh_sz_rank, is_back_row, |
| | | is_in_top_input) |
| | | |
| | | if time_index == 0: |
| | | # 09:30:00 - 10:00:00 |
| | | if strong_result[0]: |
| | | # 强势板块 |
| | | # 买主板龙1,2,3,4 买后排 |
| | | if is_back_row and sh_sz_rank <= 2: |
| | | return cls.BLOCK_TYPE_STRONG, block, f"{block} 强势板块:买主板龙1,2,3 买后排" |
| | | |
| | | if soon_limit_up_result[0]: |
| | | # 猛拉板块 |
| | | # 只买龙2 买后排 |
| | | if is_back_row and rank == 1: |
| | | return cls.BLOCK_TYPE_SOON_LIMIT_UP, block, f"{block} 猛拉板块:只买龙2,买后排" |
| | | # 其他板块 |
| | | if is_in_top_input and sh_sz_rank <= 1 and is_back_row: |
| | | # 看精选/行业流入 买龙主板1,2 买后排 |
| | | return cls.BLOCK_TYPE_COMMON, block, f"{block} 其他板块:看精选/行业流入 买龙主板1,2 买后排" |
| | | |
| | | elif time_index == 1: |
| | | # 10:00:00 - 10:30:00 |
| | | if strong_result[0]: |
| | | # 强势板块 |
| | | # 买主板龙1,2,3 买后排 |
| | | if is_back_row and sh_sz_rank <= 2: |
| | | return cls.BLOCK_TYPE_STRONG, block, f"{block} 强势板块:买主板龙1,2,3 买后排" |
| | | |
| | | if soon_limit_up_result[0]: |
| | | # 猛拉板块 |
| | | # 只买龙2 买后排 |
| | | if is_back_row and rank == 1: |
| | | return cls.BLOCK_TYPE_SOON_LIMIT_UP, block, f"{block} 猛拉板块:只买龙2,买后排" |
| | | # 其他板块 |
| | | if is_in_top_input and sh_sz_rank <= 1 and is_back_row: |
| | | # 看精选/行业流入 买龙主板1,2 买后排 |
| | | return cls.BLOCK_TYPE_COMMON, block, f"{block} 其他板块:看精选/行业流入 买龙主板1,2 买后排" |
| | | elif time_index == 2: |
| | | # 10:30:00 - 11:00:00 |
| | | if strong_result[0]: |
| | | # 强势板块 |
| | | # 买主板龙1,2 买后排 |
| | | if is_back_row and sh_sz_rank <= 1: |
| | | return cls.BLOCK_TYPE_STRONG, block, f"{block} 强势板块:买主板龙1,2 买后排" |
| | | |
| | | if soon_limit_up_result[0]: |
| | | # 猛拉板块 |
| | | # 只买龙2 买后排 |
| | | if is_back_row and rank == 1: |
| | | return cls.BLOCK_TYPE_SOON_LIMIT_UP, block, f"{block} 猛拉板块:只买龙2,买后排" |
| | | # 其他板块 |
| | | if is_in_top_input and sh_sz_rank <= 1 and is_back_row: |
| | | # 看精选/行业流入 买龙主板1,2 买后排 |
| | | return cls.BLOCK_TYPE_COMMON, block, f"{block} 其他板块:看精选/行业流入 买龙主板1,2 买后排" |
| | | elif time_index == 3: |
| | | # 11:00:00 - 13:30:00 |
| | | if soon_limit_up_result[0]: |
| | | # 猛拉板块 |
| | | # 只买龙2 买后排 |
| | | if is_back_row and rank == 1: |
| | | return cls.BLOCK_TYPE_SOON_LIMIT_UP, block, f"{block} 猛拉板块:只买龙2,买后排" |
| | | # 其他板块 |
| | | if is_in_top_input and sh_sz_rank <= 1 and is_back_row: |
| | | # 看精选/行业流入 买龙主板1,2 买后排 |
| | | return cls.BLOCK_TYPE_COMMON, block, f"{block} 其他板块:看精选/行业流入,买龙主板1,2 ,买后排" |
| | | elif time_index == 4: |
| | | # 13:30:00 - 15:00:00 |
| | | if soon_limit_up_result[0]: |
| | | # 猛拉板块 |
| | | # 只买龙2 买后排 |
| | | if is_back_row and rank == 1: |
| | | return cls.BLOCK_TYPE_SOON_LIMIT_UP, block, f"{block} 猛拉板块:只买龙2,买后排" |
| | | # 其他板块 |
| | | if is_in_top_input: |
| | | # 精选/行业流入符合 |
| | | if sh_sz_rank <= 1 and is_back_row: |
| | | # 看精选/行业流入 买龙主板1,2 买后排 |
| | | return cls.BLOCK_TYPE_COMMON, block, f"{block} 其他板块:精选/行业流入符合,买龙主板1,2,买后排" |
| | | if not keys: |
| | | return cls.BLOCK_TYPE_NONE, None, "尚未找到涨停原因" |
| | | code_limit_up_reason_dict = {} |
| | | load_code_block() |
| | | msg_list = [] |
| | | for block in keys: |
| | | is_top_4 = kpl_block_util.is_top_block(code, block, limit_up_record_datas, 4) |
| | | # 获取主板实时身位 |
| | | current_shsz_rank = kpl_block_util.get_code_current_rank(code, block, current_limit_up_datas, |
| | | code_limit_up_reason_dict, shsz=True) |
| | | record_shsz_rank = kpl_block_util.get_code_record_rank(code, block, limit_up_record_datas, |
| | | code_limit_up_reason_dict, shsz=True) |
| | | # 获取主板历史身位 |
| | | if is_top_4: |
| | | is_open_limit_up, msg = kpl_block_util.is_shsz_open_limit_up(code, block, limit_up_record_datas, |
| | | code_limit_up_reason_dict) |
| | | if is_open_limit_up: |
| | | # 主板开1 |
| | | if current_shsz_rank < 2 and record_shsz_rank < 2: |
| | | # 属于龙1,龙2 |
| | | return block, f"top4涨停板块,主板开1,属于龙1/龙2(实时身位-{current_shsz_rank})" |
| | | else: |
| | | if sh_sz_rank == 0 and not is_back_row: |
| | | return cls.BLOCK_TYPE_START_UP, block, f"{block} 其他板块: 买主板龙1,买主板独苗" |
| | | |
| | | return cls.BLOCK_TYPE_NONE, None, f"板块({match_limit_up_result.keys()})不符合买入条件" |
| | | msg_list.append( |
| | | f"板块-{block}: top4涨停板块,主板开1({msg}),不为主板龙1龙2(实时身位-{current_shsz_rank},历史身位-{record_shsz_rank})") |
| | | continue |
| | | else: |
| | | if current_shsz_rank == 0 and record_shsz_rank < 2: |
| | | return block, "top4涨停板块,非主板开1,属于龙1" |
| | | else: |
| | | msg_list.append( |
| | | f"板块-{block}: top4涨停板块,非主板开1,不为主板龙1(实时身位-{current_shsz_rank},历史身位-{record_shsz_rank})") |
| | | continue |
| | | else: |
| | | # 是否满足行业精选流入要求 |
| | | is_in_top_input = RealTimeKplMarketData.is_in_top(set([block]))[0] |
| | | if not is_in_top_input: |
| | | msg_list.append( |
| | | f"板块-{block}: 非top4涨停板块,不满足精选/行业流入要求") |
| | | continue |
| | | else: |
| | | # 是否为主板龙1(实时龙1,历史龙2以内) |
| | | if current_shsz_rank == 0 and record_shsz_rank < 2: |
| | | return block, "不是top4涨停板块,满足精选/行业流入要求,满足主板龙1" |
| | | else: |
| | | msg_list.append( |
| | | f"板块-{block}: 不是top4涨停板块,满足精选/行业流入要求,不为主板龙1(实时身位-{current_shsz_rank},历史身位-{record_shsz_rank})") |
| | | continue |
| | | return None, "\r\n".join(msg_list) |
| | | |
| | | # 是否可以下单 |
| | | # 返回:是否可以下单,消息,板块类型 |
| | | @classmethod |
| | | def can_buy(cls, code, current_limit_up_datas, latest_2_day_limit_up_datas, limit_up_record_datas): |
| | | def can_buy(cls, code, current_limit_up_datas, limit_up_record_datas,before_blocks_dict): |
| | | if constant.TEST: |
| | | return True, "", cls.BLOCK_TYPE_NONE |
| | | block_type, block, block_msg = cls.get_can_buy_block(code, current_limit_up_datas, latest_2_day_limit_up_datas, |
| | | limit_up_record_datas) |
| | | if block_type == cls.BLOCK_TYPE_NONE: |
| | | return False, block_msg, block_type |
| | | block, block_msg = cls.get_can_buy_block(code, current_limit_up_datas, |
| | | limit_up_record_datas, before_blocks_dict) |
| | | if block is None: |
| | | return False, block_msg |
| | | |
| | | # ---------------------------------判断目标代码的板块-------------------start------------ |
| | | # 判断匹配出的涨停原因,判断是否有已经下单的票 |
| | |
| | | msg_list.append(f"【{key}】中已经有{success_codes_count}个成交代码") |
| | | log.logger_kpl_debug.debug(f"{code}:板块({key})已经有成交【{trade_success_blocks_count[key]}】") |
| | | continue |
| | | return True, block_msg, block_type |
| | | return True, block_msg |
| | | # 板块可以下单数量 |
| | | # if trade_block_codes_dict.get(key) is None or len(trade_block_codes_dict.get(key)) < \ |
| | | # can_buy_codes_count_dict[key]: |
| | |
| | | # order_count = len(trade_block_codes_dict.get(key)) |
| | | # msg_list.append(f"【{key}】中下单代码数量{order_count}/允许下单数量{can_buy_codes_count_dict[key]}") |
| | | |
| | | return False, ",".join(msg_list), block_type |
| | | return False, ",".join(msg_list) |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | |
| | | import datetime |
| | | import time |
| | | |
| | | import constant |
| | | from utils import tool |
| | | |
| | | |
| | |
| | | return False, "" |
| | | |
| | | |
| | | # 是否是猛拉板块 |
| | | # 是否主板开1 |
| | | # limit_up_record_datas 今日历史涨停 |
| | | def is_soon_limit_up(code, block, limit_up_record_datas): |
| | | block_codes_infos = [] |
| | | limit_up_time = time.time() |
| | | def is_shsz_open_limit_up(code, block, limit_up_record_datas, code_block_dict): |
| | | # 获取今日9:30的时间戳 |
| | | time_str = datetime.datetime.now().strftime("%Y-%m-%d") + " 09:30:00" |
| | | timestamp = time.mktime(time.strptime(time_str, '%Y-%m-%d %H:%M:%S')) |
| | | for k in limit_up_record_datas: |
| | | if k[2] == block: |
| | | if k[3] != code: |
| | | block_codes_infos.append((k[3], int(k[5]))) |
| | | else: |
| | | limit_up_time = int(k[5]) |
| | | # 排序 |
| | | block_codes_infos.append((code, limit_up_time)) |
| | | block_codes_infos.sort(key=lambda x: x[1]) |
| | | if len(block_codes_infos) < 2: |
| | | return False, "" |
| | | if block_codes_infos[1][1] - block_codes_infos[0][1] < 30 * 60: |
| | | # 首次涨停时间间隔30分钟内 |
| | | return True, f"板块:{block} 龙1:{block_codes_infos[0][0]} 龙2:{block_codes_infos[1][0]}" |
| | | if code_block_dict.get(k[3]) == block: |
| | | if int(k[5]) < timestamp: |
| | | return True, f"{k[3]}开一" |
| | | return False, "" |
| | | |
| | | |
| | |
| | | return True |
| | | |
| | | |
| | | # 获取主板身位 |
| | | def get_sh_sz_code_rank(code, block, limit_up_record_datas): |
| | | # 是否是前几的板块 |
| | | def is_top_block(code, block, limit_up_record_datas, topn): |
| | | block_codes_infos = [] |
| | | limit_up_time = time.time() |
| | | for k in limit_up_record_datas: |
| | | if k[3].find("00") != 0 and k[3].find("60") != 0: |
| | | if k[3] != code: |
| | | block_codes_infos.append((k[3], k[2], int(k[5]))) |
| | | else: |
| | | limit_up_time = int(k[5]) |
| | | # 排序 |
| | | block_codes_infos.append((code, block, limit_up_time)) |
| | | block_first_limit_up_dict = {} |
| | | for b in block_codes_infos: |
| | | if b[1] not in block_first_limit_up_dict: |
| | | block_first_limit_up_dict[b[1]] = b |
| | | else: |
| | | if b[2] < block_first_limit_up_dict[b[1]][2]: |
| | | block_first_limit_up_dict[b[1]] = b |
| | | block_codes_infos = [block_first_limit_up_dict[k] for k in block_first_limit_up_dict] |
| | | block_codes_infos.sort(key=lambda x: x[2]) |
| | | # 去除通用涨停原因 |
| | | index = 0 |
| | | for d in block_codes_infos: |
| | | if d[1] in constant.KPL_INVALID_BLOCKS: |
| | | continue |
| | | if k[2] == block: |
| | | if d[1] == block: |
| | | if index + 1 <= topn: |
| | | return True |
| | | else: |
| | | return False |
| | | index += 1 |
| | | if index <= topn: |
| | | return True |
| | | return False |
| | | |
| | | |
| | | # 获取当日历史身位 |
| | | # shsz:是否主板 |
| | | def get_code_record_rank(code, block, limit_up_record_datas, code_limit_up_reason_dict, shsz=True): |
| | | block_codes_infos = [] |
| | | limit_up_time = time.time() |
| | | for k in limit_up_record_datas: |
| | | if shsz and k[3].find("00") != 0 and k[3].find("60") != 0: |
| | | continue |
| | | if code_limit_up_reason_dict.get(k[3]) == block: |
| | | if k[3] != code: |
| | | block_codes_infos.append((k[3], int(k[5]))) |
| | | else: |
| | |
| | | return 0 |
| | | |
| | | |
| | | # 获取身位 |
| | | def get_code_rank(code, block, limit_up_record_datas): |
| | | # 获取当日实时身位 |
| | | # before_blocks_dict格式位{"代码":set("板块")} |
| | | def get_code_current_rank(code, block, current_limit_up_datas, code_limit_up_reason_dict, shsz=False): |
| | | block_codes_infos = [] |
| | | limit_up_time = time.time() |
| | | for k in limit_up_record_datas: |
| | | if k[2] == block: |
| | | if k[3] != code: |
| | | block_codes_infos.append((k[3], int(k[5]))) |
| | | for k in current_limit_up_datas: |
| | | if shsz and k[0].find("00") != 0 and k[0].find("60") != 0: |
| | | continue |
| | | if code_limit_up_reason_dict.get(k[0]) == block: |
| | | if k[0] != code: |
| | | # 代码.涨停时间 |
| | | block_codes_infos.append((k[0], int(k[2]))) |
| | | else: |
| | | limit_up_time = int(k[5]) |
| | | limit_up_time = int(k[2]) |
| | | block_codes_infos.append((code, limit_up_time)) |
| | | block_codes_infos.sort(key=lambda x: x[1]) |
| | | for i in range(0, len(block_codes_infos)): |