| | |
| | | code_limit_up_reason_dict = {} |
| | | load_code_block() |
| | | msg_list = [] |
| | | |
| | | can_buy_blocks = [] |
| | | for block in keys: |
| | | is_top_8_record, top_8_record = kpl_block_util.is_record_top_block(code, block, limit_up_record_datas, |
| | | yesterday_current_limit_up_codes, 20) |
| | |
| | | code_limit_up_reason_dict) |
| | | if pen_limit_up_codes: |
| | | # 主板开1 |
| | | if current_shsz_rank < len(pen_limit_up_codes) + 1 and record_shsz_rank < len(pen_limit_up_codes) + 1: |
| | | if current_shsz_rank < len(pen_limit_up_codes) + 1 and record_shsz_rank < len( |
| | | pen_limit_up_codes) + 1: |
| | | # 属于龙1,龙2 |
| | | return block, f"{block}:top4涨停板块,主板开1({pen_limit_up_codes}),属于主板前龙{len(pen_limit_up_codes) + 1}(实时身位-{current_shsz_rank})" |
| | | can_buy_blocks.append((block, |
| | | f"{block}:top4涨停板块,主板开1({pen_limit_up_codes}),属于主板前龙{len(pen_limit_up_codes) + 1}(实时身位-{current_shsz_rank})")) |
| | | continue |
| | | else: |
| | | msg_list.append( |
| | | f"板块-{block}: top4涨停板块,主板开1({pen_limit_up_codes}),不为主板前龙{len(pen_limit_up_codes) + 1}(实时身位-{current_shsz_rank},历史身位-{record_shsz_rank})") |
| | | continue |
| | | else: |
| | | if current_shsz_rank == 0 and record_shsz_rank < 2: |
| | | return block, f"{block}:top4涨停板块,非主板开1,属于龙1" |
| | | can_buy_blocks.append((block, f"{block}:top4涨停板块,非主板开1,属于龙1")) |
| | | continue |
| | | else: |
| | | msg_list.append( |
| | | f"板块-{block}: top4涨停板块,非主板开1,不为主板龙1(实时身位-{current_shsz_rank},历史身位-{record_shsz_rank})") |
| | |
| | | else: |
| | | # 是否为主板龙1(实时龙1,历史龙2以内) |
| | | if current_shsz_rank == 0 and record_shsz_rank < 2: |
| | | return block, f"{block}:不是top4涨停板块,满足精选/行业流入要求,满足主板龙1" |
| | | can_buy_blocks.append((block, f"{block}:不是top4涨停板块,满足精选/行业流入要求,满足主板龙1")) |
| | | continue |
| | | else: |
| | | msg_list.append( |
| | | f"板块-{block}: 不是top4涨停板块,满足精选/行业流入要求,不为主板龙1(实时身位-{current_shsz_rank},历史身位-{record_shsz_rank})") |
| | | continue |
| | | if len(can_buy_blocks) == len(keys): |
| | | blocks = "/".join([x[0] for x in can_buy_blocks]) |
| | | blocks_msg = "\n".join([x[1] for x in can_buy_blocks]) |
| | | return blocks, blocks_msg |
| | | |
| | | return None, "\n".join(msg_list) |
| | | |
| | | # 是否可以下单 |
| | |
| | | from third_data.kpl_util import KPLPlatManager, KPLDataType |
| | | |
| | | |
| | | |
| | | |
| | | class KPLCodeLimitUpReasonManager: |
| | | __redisManager = redis_manager.RedisManager(3) |
| | | |
| | |
| | | for b in constant.KPL_INVALID_BLOCKS: |
| | | wheres.append(f"hb.`_hot_block_name` != '{b}'") |
| | | wheres = " and ".join(wheres) |
| | | sql = f"SELECT GROUP_CONCAT(_hot_block_name) FROM (SELECT hb.`_hot_block_name`,hb.`_day` FROM `kpl_limit_up_record` hb WHERE hb.`_code`='{code}' AND {wheres} ORDER BY hb.`_day` DESC LIMIT 10) a GROUP BY a._day ORDER BY a._day DESC LIMIT 1" |
| | | sql = f"SELECT GROUP_CONCAT(_hot_block_name) FROM (SELECT hb.`_hot_block_name`,hb.`_day` FROM `kpl_limit_up_record` hb WHERE hb.`_code`='{code}' AND {wheres} ORDER BY hb.`_day` DESC LIMIT 2) a GROUP BY a._day ORDER BY a._day DESC LIMIT 1" |
| | | print(sql) |
| | | mysqldb = mysql_data.Mysqldb() |
| | | return mysqldb.select_one(sql) |
| | | |
| | | # 获取代码最近的板块,返回[(板块,日期)] |
| | | @classmethod |
| | | def get_latest_infos(cls, code, count, contains_today=True): |
| | | wheres = [] |
| | | for b in constant.KPL_INVALID_BLOCKS: |
| | | wheres.append(f"hb.`_hot_block_name` != '{b}'") |
| | | wheres = " and ".join(wheres) |
| | | # 只获取最近180天的数据 |
| | | min_day = tool.date_sub(tool.get_now_date_str(), 180) |
| | | sql = f"SELECT GROUP_CONCAT(_hot_block_name),`_day`,_blocks FROM (SELECT hb.`_hot_block_name`,hb.`_day`,hb._blocks FROM `kpl_limit_up_record` hb WHERE hb.`_code`='{code}' and hb.`_day` > '{min_day}' ORDER BY hb.`_day` DESC LIMIT 10) a GROUP BY a._day ORDER BY a._day DESC LIMIT {count}" |
| | | sql = f"SELECT GROUP_CONCAT(_hot_block_name),`_day`,_blocks FROM (SELECT hb.`_hot_block_name`,hb.`_day`,hb._blocks FROM `kpl_limit_up_record` hb WHERE hb.`_code`='{code}' and {wheres} and hb.`_day` > '{min_day}' ORDER BY hb.`_day` DESC LIMIT 10) a GROUP BY a._day ORDER BY a._day DESC LIMIT {count}" |
| | | mysqldb = mysql_data.Mysqldb() |
| | | results = mysqldb.select_all(sql) |
| | | if results and not contains_today and results[0][1] == tool.get_now_date_str(): |
| | |
| | | |
| | | @classmethod |
| | | def get_latest_blocks_set(cls, code): |
| | | results = cls.get_latest_infos(code, 10, False) |
| | | results = cls.get_latest_infos(code, 2, False) |
| | | bs = set([b[0] for b in results]) |
| | | return bs |
| | | |
| | |
| | | yesterday_codes = set([x[0] for x in yesterday_limit_up_data_records]) |
| | | return yesterday_codes |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | fresults = get_current_limit_up_data_records(2) |
| | | for d in fresults: |
| | | print(d) |
| | | get_current_limit_up_data_records(2) |
| | | print(KPLLimitUpDataRecordManager.get_latest_blocks_set("002671")) |