From 8f2d9ed1cb23e87c7ee0d682403fecbd5427cd1c Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期五, 18 七月 2025 16:22:28 +0800 Subject: [PATCH] 测试 --- cancel_strategy/s_l_h_cancel_strategy.py | 41 ++++++++++++++++++++++++----------------- 1 files changed, 24 insertions(+), 17 deletions(-) diff --git a/cancel_strategy/s_l_h_cancel_strategy.py b/cancel_strategy/s_l_h_cancel_strategy.py index a9b0d6f..86d2746 100644 --- a/cancel_strategy/s_l_h_cancel_strategy.py +++ b/cancel_strategy/s_l_h_cancel_strategy.py @@ -2099,30 +2099,37 @@ before_watch_indexed_info, before_canceled_watch_indexes_info = rate_info[2][0], rate_info[2][1] canceled_indexes = set([x[0] for x in before_canceled_watch_indexes_info]) # [绱鎵嬫暟,绱鎾ゅ崟鎵嬫暟] + ts = [50, 200, 300, 10000] + tss = [] + for i in range(len(ts) - 1): + start_money, end_money = ts[i] * 100, ts[i + 1] * 100 + tss.append((start_money, end_money)) + watch_index_info_less_of_200 = [0, 0] watch_index_info_200_to_300 = [0, 0] watch_index_info_more_than_300 = [0, 0] + rate_info_dict = {} for x in before_watch_indexed_info: money = limit_up_price * x[1] - if money >= 300 * 100: - watch_index_info_more_than_300[0] += x[1] - if x[0] in canceled_indexes: - watch_index_info_more_than_300[1] += x[1] - elif money >= 200 * 100: - watch_index_info_200_to_300[0] += x[1] - if x[0] in canceled_indexes: - watch_index_info_200_to_300[1] += x[1] + for t in tss: + if t[0] <= money < t[1]: + if t[0] not in rate_info_dict: + rate_info_dict[t[0]] = [0,0] + rate_info_dict[t[0]][0] += x[1] + if x[0] in canceled_indexes: + rate_info_dict[t[0]][1] += x[1] + break + watch_index_info = [(k,v) for k,v in rate_info_dict.items()] + watch_index_info.sort(key= lambda x:x[0]) + watch_index_info = [x[1] for x in watch_index_info] + watch_index_info_details = [] + for x in watch_index_info: + if x[0] > 0: + watch_index_info_details.append(f"{int(round(x[1] * 100 / x[0]))}") else: - watch_index_info_less_of_200[0] += x[1] - if x[0] in canceled_indexes: - watch_index_info_less_of_200[1] += x[1] - fresults.append(( - round(watch_index_info_less_of_200[1] * 100 / max(watch_index_info_less_of_200[0], 1)), - round(watch_index_info_200_to_300[1] * 100 / max(watch_index_info_200_to_300[0], 1)), - round(watch_index_info_more_than_300[1] * 100 / max(watch_index_info_more_than_300[0], 1)), - )) - + watch_index_info_details.append(f"--") + fresults.append(watch_index_info_details) return fresults -- Gitblit v1.8.0