| | |
| | | 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 |
| | | |
| | | |
| | |
| | | |
| | | |
| | | 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) |
| | |
| | | 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) |
| | | # 将日期格式转为datetime |
| | | 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): |
| | | """ |
| | | 获取之前的收盘价 |