From cbe19ea6066a600cbd0b5110db5d43f8252d14a8 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期四, 13 六月 2024 11:23:53 +0800 Subject: [PATCH] L撤成交进度相关改进 --- third_data/kpl_block_util.py | 74 +++++++++++++++++++++++++++--------- 1 files changed, 55 insertions(+), 19 deletions(-) diff --git a/third_data/kpl_block_util.py b/third_data/kpl_block_util.py index debb990..6c9c1f4 100644 --- a/third_data/kpl_block_util.py +++ b/third_data/kpl_block_util.py @@ -18,10 +18,24 @@ 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')) limit_up_codes = set() - for k in limit_up_record_datas: - if code_block_dict.get(k[3]) == block: - if int(k[5]) < timestamp: - limit_up_codes.add(k[3]) + if limit_up_record_datas: + for k in limit_up_record_datas: + if code_block_dict.get(k[3]) == block: + if int(k[5]) < timestamp: + limit_up_codes.add(k[3]) + return limit_up_codes + + +# 鑾峰彇涓绘澘寮�1涓旂洰鍓嶆槸娑ㄥ仠鐨勪唬鐮� +def get_shsz_open_limit_up_codes_current(code, block, current_limit_up_datas): + # 鑾峰彇浠婃棩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')) + limit_up_codes = set() + for k in current_limit_up_datas: + if k[5] == block: + if int(k[2]) < timestamp: + limit_up_codes.add(k[0]) return limit_up_codes @@ -52,7 +66,7 @@ for k in block_limit_up_dict: has_shsz = False for b in block_limit_up_dict[k]: - if b[0].find('00') == 0 or b[0].find('60') == 0: + if tool.is_can_buy_code(b[0]): has_shsz = True break if not has_shsz: @@ -124,45 +138,67 @@ # 鑾峰彇褰撴棩鍘嗗彶韬綅 # shsz:鏄惁涓绘澘 -def get_code_record_rank(code, block, limit_up_record_datas, code_limit_up_reason_dict, shsz=True): +def get_code_record_rank(code, block, limit_up_record_datas, code_limit_up_reason_dict, + yesterday_current_limit_up_codes, 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: + if k[3] == code: + # 鑾峰彇褰撳墠浠g爜娑ㄥ仠鏃堕棿 + limit_up_time = int(k[5]) + if shsz and not tool.is_can_buy_code(k[3]): + continue + # 鍓旈櫎楂樹綅鏉� + if k[3] in yesterday_current_limit_up_codes: 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: - limit_up_time = int(k[5]) + block_codes_infos.append((code, limit_up_time)) block_codes_infos.sort(key=lambda x: x[1]) + front_codes = [] for i in range(0, len(block_codes_infos)): if block_codes_infos[i][0] == code: - return i - return 0 + return i, front_codes + else: + front_codes.append(block_codes_infos[i][0]) + return 0, [] # 鑾峰彇褰撴棩瀹炴椂韬綅 # before_blocks_dict鏍煎紡浣峽"浠g爜":set("鏉垮潡")} -def get_code_current_rank(code, block, current_limit_up_datas, code_limit_up_reason_dict, shsz=False): +def get_code_current_rank(code, block, current_limit_up_datas, code_limit_up_reasons_dict, + yesterday_current_limit_up_codes, exclude_codes, open_limit_up_count, shsz=False, + limit_up_time=time.time()): block_codes_infos = [] - limit_up_time = time.time() for k in current_limit_up_datas: - if shsz and k[0].find("00") != 0 and k[0].find("60") != 0: + if k[0] == code: + # 鑾峰彇褰撳墠浠g爜娑ㄥ仠鏃堕棿 + limit_up_time = int(k[2]) + if shsz and not tool.is_can_buy_code(k[0]): continue - if code_limit_up_reason_dict.get(k[0]) == block: + # 鍓旈櫎楂樹綅鏉� + if k[0] in yesterday_current_limit_up_codes: + continue + if code_limit_up_reasons_dict.get(k[0]) and block in code_limit_up_reasons_dict.get(k[0]): if k[0] != code: # 浠g爜.娑ㄥ仠鏃堕棿 block_codes_infos.append((k[0], int(k[2]))) - else: - limit_up_time = int(k[2]) block_codes_infos.append((code, limit_up_time)) block_codes_infos.sort(key=lambda x: x[1]) + front_codes = [] + first_count = 0 for i in range(0, len(block_codes_infos)): + if i == open_limit_up_count and exclude_codes and block_codes_infos[i][0] in exclude_codes: + # 闈炲紑1鑰佸ぇ琚帓闄� + first_count += 1 + continue if block_codes_infos[i][0] == code: - return i - return 0 + return i - first_count, front_codes + else: + front_codes.append(block_codes_infos[i][0]) + return 0, [] if __name__ == "__main__": -- Gitblit v1.8.0