| | |
| | | # 导出数据处理位置日志 |
| | | def __export_l2_pos_range(code, date, dir): |
| | | LogUtil.extract_log_from_key("{} 处理数据范围".format(code), |
| | | "{}/logs_/gp/l2/l2_process.{}.log".format(constant.get_path_prefix(), date), |
| | | "{}/logs/gp/l2/l2_process.{}.log".format(constant.get_path_prefix(), date), |
| | | "{}/l2_process_{}.log".format(dir, date)) |
| | | |
| | | |
| | | # 导出交易日志 |
| | | def __export_l2_trade_log(code, date, dir): |
| | | LogUtil.extract_log_from_key(code, "{}/logs_/gp/l2/l2_trade.{}.log".format(constant.get_path_prefix(), date), |
| | | LogUtil.extract_log_from_key(code, "{}/logs/gp/l2/l2_trade.{}.log".format(constant.get_path_prefix(), date), |
| | | "{}/l2_trade_{}.log".format(dir, date)) |
| | | |
| | | |
| | | # 导出交易取消日志 |
| | | def __export_l2_trade_cancel_log(code, date, dir): |
| | | LogUtil.extract_log_from_key(code, "{}/logs_/gp/l2/l2_trade_cancel.{}.log".format(constant.get_path_prefix(), date), |
| | | LogUtil.extract_log_from_key(code, "{}/logs/gp/l2/l2_trade_cancel.{}.log".format(constant.get_path_prefix(), date), |
| | | "{}/l2_trade_cancel_{}.log".format(dir, date)) |
| | | |
| | | |
| | | def __analyse_pricess_time(): |
| | | date = datetime.datetime.now().strftime("%Y-%m-%d") |
| | | file_path = f"{constant.get_path_prefix()}/logs_/gp/l2/l2_process.{date}.log" |
| | | file_path = f"{constant.get_path_prefix()}/logs/gp/l2/l2_process.{date}.log" |
| | | with open(file_path, encoding="utf-8") as f: |
| | | line = f.readline() |
| | | while line: |
| | |
| | | if len(code) < 6: |
| | | return |
| | | date = datetime.datetime.now().strftime("%Y-%m-%d") |
| | | dir_ = "{}/logs_/gp/l2/{}".format(constant.get_path_prefix(), code) |
| | | dir_ = "{}/logs/gp/l2/{}".format(constant.get_path_prefix(), code) |
| | | if not os.path.exists(dir_): |
| | | os.mkdir(dir_) |
| | | __export_l2_pos_range(code, date, dir_) |
| | |
| | | if date is None: |
| | | date = datetime.datetime.now().strftime("%Y-%m-%d") |
| | | try: |
| | | with open("{}/logs_/gp/l2/l2_data.{}.log".format(constant.get_path_prefix(), date), mode='r') as f: |
| | | with open("{}/logs/gp/l2/l2_data.{}.log".format(constant.get_path_prefix(), date), mode='r') as f: |
| | | while True: |
| | | data = f.readline() |
| | | if not data: |
| | |
| | | if not date: |
| | | date = datetime.datetime.now().strftime("%Y-%m-%d") |
| | | pos_list = [] |
| | | with open("{}/logs_/gp/l2/l2_process.{}.log".format(constant.get_path_prefix(), date), mode='r', encoding="utf-8") as f: |
| | | with open("{}/logs/gp/l2/l2_process.{}.log".format(constant.get_path_prefix(), date), mode='r', encoding="utf-8") as f: |
| | | while True: |
| | | line = f.readline() |
| | | if not line: |
| | |
| | | if not date: |
| | | date = datetime.datetime.now().strftime("%Y-%m-%d") |
| | | pos_list = [] |
| | | with open("{}/logs_/gp/l2/l2_trade.{}.log".format(constant.get_path_prefix(), date), mode='r', encoding="utf-8") as f: |
| | | with open("{}/logs/gp/l2/l2_trade.{}.log".format(constant.get_path_prefix(), date), mode='r', encoding="utf-8") as f: |
| | | while True: |
| | | line = f.readline() |
| | | if not line: |
| | |
| | | date = datetime.datetime.now().strftime("%Y-%m-%d") |
| | | index_list = [] |
| | | buy_queues = [] |
| | | with open("{}/logs_/gp/l2/l2_trade_buy_queue.{}.log".format(constant.get_path_prefix(),date), mode='r', encoding="utf-8") as f: |
| | | with open("{}/logs/gp/l2/l2_trade_buy_queue.{}.log".format(constant.get_path_prefix(),date), mode='r', encoding="utf-8") as f: |
| | | while True: |
| | | line = f.readline() |
| | | if not line: |
| | |
| | | def get_h_cancel_compute_info(code, date=None): |
| | | if not date: |
| | | date = datetime.datetime.now().strftime("%Y-%m-%d") |
| | | path_str = f"{constant.get_path_prefix()}/logs_/gp/l2/cancel/h_cancel.{date}.log" |
| | | path_str = f"{constant.get_path_prefix()}/logs/gp/l2/cancel/h_cancel.{date}.log" |
| | | latest_info = None |
| | | if os.path.exists(path_str): |
| | | with open(path_str, mode='r', encoding="utf-8") as f: |
| | |
| | | def get_kp_msg_list(date=None): |
| | | if not date: |
| | | date = datetime.datetime.now().strftime("%Y-%m-%d") |
| | | path_str = f"{constant.get_path_prefix()}/logs_/gp/kp/kp_msg.{date}.log" |
| | | path_str = f"{constant.get_path_prefix()}/logs/gp/kp/kp_msg.{date}.log" |
| | | msg_list = [] |
| | | if os.path.exists(path_str): |
| | | with open(path_str, mode='r', encoding="utf-8") as f: |
| | |
| | | def export_logs(code): |
| | | code_name = gpcode_manager.get_code_name(code) |
| | | date = datetime.datetime.now().strftime("%Y-%m-%d") |
| | | target_dir = f"{constant.get_path_prefix()}/logs_/gp/l2/export/{code}_{code_name}_{date}" |
| | | target_dir = f"{constant.get_path_prefix()}/logs/gp/l2/export/{code}_{code_name}_{date}" |
| | | if os.path.exists(target_dir): |
| | | shutil.rmtree(target_dir) |
| | | os.makedirs(target_dir) |
| | |
| | | dir_path = "/".join(target_path.split("/")[:-1]) |
| | | if not os.path.exists(dir_path): |
| | | os.makedirs(dir_path) |
| | | LogUtil.extract_log_from_key(key, f"{constant.get_path_prefix()}/logs_/gp/l2/{log_name}.{date}.log", |
| | | LogUtil.extract_log_from_key(key, f"{constant.get_path_prefix()}/logs/gp/l2/{log_name}.{date}.log", |
| | | target_path) |
| | | |
| | | |
| | | def export_trade_progress(code): |
| | | path = f"{constant.get_path_prefix()}/logs_/gp/l2/l2_trade_buy_progress.{tool.get_now_date_str()}.log" |
| | | path = f"{constant.get_path_prefix()}/logs/gp/l2/l2_trade_buy_progress.{tool.get_now_date_str()}.log" |
| | | index_set = set() |
| | | with open(path, mode='r', encoding="utf-8") as f: |
| | | lines = f.readlines() |
| | |
| | | |
| | | # 加载买入得分记录 |
| | | def load_buy_score_recod(code): |
| | | path = f"{constant.get_path_prefix()}/logs_/gp/trade/trade_record.{tool.get_now_date_str()}.log" |
| | | path = f"{constant.get_path_prefix()}/logs/gp/trade/trade_record.{tool.get_now_date_str()}.log" |
| | | fdatas = [] |
| | | if os.path.exists(path): |
| | | with open(path, 'r', encoding="utf-8") as f: |
| | |
| | | |
| | | |
| | | def load_kpl_reason_changes(): |
| | | path = f"{constant.get_path_prefix()}/logs_/gp/kpl/kpl_limit_up_reason_change.{tool.get_now_date_str()}.log" |
| | | path = f"{constant.get_path_prefix()}/logs/gp/kpl/kpl_limit_up_reason_change.{tool.get_now_date_str()}.log" |
| | | fdatas = [] |
| | | if os.path.exists(path): |
| | | with open(path, 'r', encoding="utf-8") as f: |