From ea44e1fddfb7a663802ca6dcd33f2350c805ec61 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期二, 03 六月 2025 16:40:36 +0800 Subject: [PATCH] 获取昨日收盘价接口更换为huaxin/调整大单接口/优化昨日收盘价获取方式 --- third_data/history_k_data_manager.py | 34 +++++++++++++++++++++++++++++++++- 1 files changed, 33 insertions(+), 1 deletions(-) diff --git a/third_data/history_k_data_manager.py b/third_data/history_k_data_manager.py index cb995d5..c6c2cca 100644 --- a/third_data/history_k_data_manager.py +++ b/third_data/history_k_data_manager.py @@ -11,6 +11,7 @@ from huaxin_client import l1_subscript_codes_manager from log_module.log import logger_debug from third_data import history_k_data_util +from third_data.history_k_data_util import HistoryKDatasUtils from utils import tool, init_data_util @@ -47,10 +48,13 @@ def re_set_price_pres(codes, force=False): - day = tool.get_now_date_str() # 閫氳繃鍘嗗彶鏁版嵁缂撳瓨鑾峰彇 + # 鑾峰彇涓婁竴涓氦鏄撴棩 + day = HistoryKDatasUtils.get_previous_trading_date_cache(tool.get_now_date_str()) not_codes = [] for code in codes: + if not tool.is_can_buy_code(code): + continue pre_close = HistoryKDataManager().get_pre_close(code, day) if pre_close is not None: gpcode_manager.CodePrePriceManager.set_price_pre(code, pre_close, force) @@ -158,6 +162,34 @@ return datas return None + def load_data(self): + """ + 鍔犺浇鏁版嵁 + @param day: + @return: + """ + day = HistoryKDatasUtils.get_previous_trading_date_cache(tool.get_now_date_str()) + cache_dir = self.__get_cache_dir() + if not os.path.exists(cache_dir): + return + fs = os.listdir(cache_dir) + for f in fs: + if f.find(day) < 0: + continue + with open(os.path.join(cache_dir, f), mode='r', encoding='utf-8') as fs: + line = fs.readline() + if line: + datas = eval(line) + # 灏嗘棩鏈熸牸寮忚浆涓篸atetime + for d in datas: + for k in d: + if type(d[k]) == str and d[k].find("-") > 0 and d[k].find(":") > 0 and d[k].find(" ") > 0: + d[k] = datetime.datetime.strptime(d[k], "%Y-%m-%d %H:%M:%S") + if datas: + if day not in self.__history_k_day_datas: + self.__history_k_day_datas[day] = {} + self.__history_k_day_datas[day][datas[0]['sec_id']] = datas + def get_pre_close(self, code, day): """ 鑾峰彇涔嬪墠鐨勬敹鐩樹环 -- Gitblit v1.8.0