From f0248f54f90a12f491245f0ee3ccfbe8f477a76b Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期五, 22 十二月 2023 14:24:20 +0800 Subject: [PATCH] bug修复 --- utils/init_data_util.py | 34 ++++++++++++++++++++++++++-------- 1 files changed, 26 insertions(+), 8 deletions(-) diff --git a/utils/init_data_util.py b/utils/init_data_util.py index e0ced67..53977c9 100644 --- a/utils/init_data_util.py +++ b/utils/init_data_util.py @@ -1,4 +1,3 @@ - # 璁剧疆鏀剁洏浠� import decimal @@ -7,9 +6,9 @@ from utils import tool -def re_set_price_pre(code): +def re_set_price_pre(code, force=False): codes = [code] - re_set_price_pres(codes) + re_set_price_pres(codes, force=force) def re_set_price_pres(codes, force=False): @@ -19,6 +18,7 @@ symbol = symbol.split(".")[1] pre_close = tool.to_price(decimal.Decimal(str(item['pre_close']))) gpcode_manager.CodePrePriceManager.set_price_pre(symbol, pre_close, force) + # 鑾峰彇杩�90澶╃殑鏈�澶ч噺涓庢渶杩戠殑閲� # 鑾峰彇鏈�杩戜竴娆℃定鍋�/娑ㄥ仠涓嬩竴涓氦鏄撴棩鐨勬渶澶у�� @@ -30,11 +30,31 @@ # 瑙f瀽鏈�澶ч噺 -def parse_max_volume(datas, is_new_top=False): +def parse_max_volume(datas, is_new_or_near_top=False): max_volume = 0 - max_volume_date = None - if is_new_top: + # 鍒ゆ柇30澶╁唴鏄惁鏈夋定鍋� + if is_new_or_near_top: + # 30澶╁唴鏄惁鏈夋定鍋� + latest_limit_up_index = None + for i in range(30): + if i >= len(datas): + break + item = datas[i] + limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(item["pre_close"])) + if abs(limit_up_price - item["high"]) < 0.001: + latest_limit_up_index = i + break + if latest_limit_up_index is not None: + # 绐佺牬鍓嶉珮鎴栬�呮帴杩戝墠楂橈紝30涓氦鏄撴棩鍐呮湁娑ㄥ仠 + if latest_limit_up_index > 0 and datas[latest_limit_up_index - 1]["volume"] > datas[latest_limit_up_index]["volume"]: + return datas[latest_limit_up_index - 1]["volume"], datas[latest_limit_up_index - 1]["volume"], \ + datas[latest_limit_up_index - 1]['bob'].strftime("%Y-%m-%d") + else: + return datas[latest_limit_up_index]["volume"], datas[latest_limit_up_index]["volume"], \ + datas[latest_limit_up_index]['bob'].strftime("%Y-%m-%d") + + if is_new_or_near_top: # 濡傛灉鏄獊鐮村墠楂樺氨鍙栨渶澶ч噺 for item in datas: if max_volume < item["volume"]: @@ -42,7 +62,6 @@ max_volume_date = item["bob"] return max_volume, max_volume, max_volume_date.strftime("%Y-%m-%d") else: - date = None target_volume = None for i in range(len(datas)): @@ -89,4 +108,3 @@ return max_60_volume_info[0], max_60_volume_info[0], max_60_volume_info[1].strftime("%Y-%m-%d") else: return target_volume[0], target_volume[0], target_volume[1].strftime("%Y-%m-%d") - -- Gitblit v1.8.0