| | |
| | | filter=lambda record: record["extra"].get("name") == "place_order_score", |
| | | rotation="00:00", compression="zip", enqueue=True) |
| | | |
| | | logger.add(self.get_path("kpl", "kpl_limit_up_reason_change"), |
| | | filter=lambda record: record["extra"].get("name") == "kpl_limit_up_reason_change", |
| | | rotation="00:00", compression="zip", enqueue=True) |
| | | |
| | | logger.add(self.get_path("kpl", "kpl_limit_up"), |
| | | filter=lambda record: record["extra"].get("name") == "kpl_limit_up", |
| | | rotation="00:00", compression="zip", enqueue=True) |
| | | |
| | | def get_path(self, dir_name, log_name): |
| | | return "D:/logs/gp/{}/{}".format(dir_name, log_name) + ".{time:YYYY-MM-DD}.log" |
| | | |
| | |
| | | logger_trade_record = __mylogger.get_logger("trade_record") |
| | | |
| | | logger_place_order_score = __mylogger.get_logger("place_order_score") |
| | | |
| | | logger_kpl_limit_up_reason_change = __mylogger.get_logger("kpl_limit_up_reason_change") |
| | | |
| | | logger_kpl_limit_up = __mylogger.get_logger("kpl_limit_up") |
| | | |
| | | |
| | | class LogUtil: |
| | | @classmethod |
| | |
| | | |
| | | def export_logs(code): |
| | | code_name = gpcode_manager.get_code_name(code) |
| | | date = datetime.datetime.now().strftime("%Y-%m-%d") |
| | | date = datetime.datetime.now().strftime("%Y-%m-%d") |
| | | target_dir = f"D:/logs/gp/l2/export/{code}_{code_name}_{date}" |
| | | if os.path.exists(target_dir): |
| | | shutil.rmtree(target_dir) |
| | | os.makedirs(target_dir) |
| | | log_names = ["l2_process", "l2_trade", "l2_trade_cancel", "l2_process_time", "l2_trade_buy", "l2_trade_buy_progress", "cancel/h_cancel"] |
| | | log_names = ["l2_process", "l2_trade", "l2_trade_cancel", "l2_process_time", "l2_trade_buy", |
| | | "l2_trade_buy_progress", "cancel/h_cancel"] |
| | | # 导出交易日志 |
| | | for log_name in log_names: |
| | | key = f"code={code}" |
| | |
| | | LogUtil.extract_log_from_key(key, f"D:/logs/gp/l2/{log_name}.{date}.log", |
| | | target_path) |
| | | |
| | | |
| | | def export_trade_progress(code): |
| | | path =f"D:/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: |
| | | path = f"D:/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() |
| | | for line in lines: |
| | | if line.find(f"code-{code}") > -1 and line.find("确定交易进度成功")>-1: |
| | | index= line.split("index-")[1].split(" ")[0] |
| | | if line.find(f"code-{code}") > -1 and line.find("确定交易进度成功") > -1: |
| | | index = line.split("index-")[1].split(" ")[0] |
| | | index_set.add(int(index)) |
| | | results = list(index_set) |
| | | results.sort() |
| | | return results |
| | | |
| | | |
| | | |
| | | |
| | | # 加载买入得分记录 |
| | |
| | | time_str = line[11:19] |
| | | data = line[line.find("data=") + 5:] |
| | | type = line[line.find("type=") + 5:line.find(" ", line.find("type="))] |
| | | fdatas.append((time_str, type, eval("{"+data+"}"))) |
| | | fdatas.append((time_str, type, eval("{" + data + "}"))) |
| | | return fdatas |
| | | |
| | | |
| | | def load_kpl_reason_changes(): |
| | | path = f"D:/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: |
| | | lines = f.readlines() |
| | | for line in lines: |
| | | data = line[line.find("code-") + 5:] |
| | | code = data.split(":")[0] |
| | | from_r = data.split(":")[1].split("-")[0] |
| | | to_r = eval(data.split(":")[1].split("-")[1]) |
| | | fdatas.append((code, from_r, to_r)) |
| | | return fdatas |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | | print(logger_place_order_score.info("002681")) |
| | | |
| | | |
| | | print(load_kpl_reason_changes()) |
| | | |
| | | # logger_l2_h_cancel.info("test") |
| | | # logger_l2_process_time.info("test123") |