From cd3eccb32719bb5409ec62f4e201b85992df2d33 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 30 六月 2025 18:14:50 +0800 Subject: [PATCH] 网页修改 --- code_data_manager.py | 31 ++++++++----------------------- 1 files changed, 8 insertions(+), 23 deletions(-) diff --git a/code_data_manager.py b/code_data_manager.py index a1e19a8..1971a10 100644 --- a/code_data_manager.py +++ b/code_data_manager.py @@ -3,37 +3,19 @@ import json import os -import tool +from utils import tool +from utils import log_util class CodeDataManager: def save_data(self, data): code = data["code"] create_at = data["created_at"] - day = create_at.strftime("%Y%m%d") data["created_at"] = create_at.strftime("%Y-%m-%d %H:%M:%S") - file_path = "datas/{}_{}.txt".format(day, code) - if not os.path.exists(file_path): - with open(file_path, 'w', encoding="utf-8") as f: - pass - with open(file_path, "a", encoding="utf-8") as f: - f.write(json.dumps(data)) - f.write("\n") + log_util.save_l1_data(code, data) def get_datas(self, code): - day = datetime.datetime.now().strftime("%Y%m%d") - file_path = "datas/{}_{}.txt".format(day, code) - datas = [] - try: - with open(file_path, "r") as f: - while True: - line = f.readline() - if not line or len(line) == 0: - break - data = json.loads(line) - datas.append(data) - except: - pass + datas = log_util.get_l1_datas(code) # 鏍规嵁鍒涘缓鏃堕棿鎺掑簭 datas = sorted(datas, key=lambda tup: int(tup["created_at"].split(" ")[1].replace(":", ""))) return datas @@ -75,6 +57,9 @@ if tool.trade_time_sub(time_, last_time) > 30: if len(ranges) == 0 or ranges[-1][0] != last_time: if is_trade_time(last_time) and is_trade_time(time_): - ranges.append((tool.trade_time_add_second(last_time, 3), tool.trade_time_add_second(time_, -3))) + start_time = tool.trade_time_add_second(last_time, 3) + end_time = tool.trade_time_add_second(time_, -3) + if tool.trade_time_sub(end_time, start_time) > 0: + ranges.append((start_time, end_time)) last_time = time_ return ranges -- Gitblit v1.8.0