From 65afea1ba534b51f947cbe7989d7f4d650bbc9e6 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期一, 04 十一月 2024 18:29:00 +0800 Subject: [PATCH] 代码异常保护 --- utils/init_data_util.py | 36 ++++++++++++++++++++++++++---------- 1 files changed, 26 insertions(+), 10 deletions(-) diff --git a/utils/init_data_util.py b/utils/init_data_util.py index 7868b39..e400369 100644 --- a/utils/init_data_util.py +++ b/utils/init_data_util.py @@ -14,16 +14,12 @@ def re_set_price_pres(codes, force=False): # 閫氳繃鍘嗗彶鏁版嵁缂撳瓨鑾峰彇 - try: - result = HistoryKDatasUtils.get_gp_latest_info(codes) - for item in result: - symbol = item['symbol'] - 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) - except Exception as e: - logger_debug.error(f"get_gp_latest_info寮傚父:{codes}") - logger_debug.exception(e) + result = HistoryKDatasUtils.get_gp_latest_info(codes) + for item in result: + symbol = item['symbol'] + 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澶╃殑鏈�澶ч噺涓庢渶杩戠殑閲� @@ -66,6 +62,26 @@ "%Y-%m-%d"), refer_index +def parse_max_volume_in_days(datas, max_day): + """ + 瑙f瀽鏈�杩戝嚑澶╂渶澶х殑閲� + @param datas: + @param max_day: + @return: + """ + # 瑙f瀽鏈�杩戝嚑澶╃殑鏈�澶ч噺 + datas = datas[:max_day] + max_volume_info = None + for d in datas: + if max_volume_info is None: + max_volume_info = (d["volume"], d) + if d["volume"] > max_volume_info[0]: + max_volume_info = (d["volume"], d) + if max_volume_info: + return max_volume_info[0] + return None + + # 杩斿洖锛�(60澶╂渶澶ч噺,鏄ㄦ棩閲�,閲忓弬鑰冩棩鏈�,鍙傝�冮噺鎹粖浜ゆ槗鏃ユ暟) def __parse_max_volume(code, datas, is_new_or_near_top=False): max_volume = 0 -- Gitblit v1.8.0