| | |
| | | |
| | | def load_l2_from_log(date=None): |
| | | today_data = {} |
| | | if date is None: |
| | | if date is None: |
| | | date = datetime.datetime.now().strftime("%Y-%m-%d") |
| | | try: |
| | | with open("D:/logs/gp/l2/l2_data.{}.log".format(date), mode='r') as f: |
| | |
| | | return today_data |
| | | |
| | | |
| | | # 获取日志时间 |
| | | def __get_log_time(line): |
| | | time_ = line.split("|")[0].split(" ")[1].split(".")[0] |
| | | return time_ |
| | | |
| | | |
| | | # 获取L2每次批量处理数据的位置范围 |
| | | def get_l2_process_position(code, date=None): |
| | | if not date: |
| | |
| | | break |
| | | if line.find("code:{}".format(code)) < 0: |
| | | continue |
| | | time_ = __get_log_time(line) |
| | | line = line[line.find("处理数据范围") + len("处理数据范围") + 1:line.find("处理时间")].strip() |
| | | if len(pos_list) == 0 or pos_list[-1][1] < int(line.split("-")[0]): |
| | | pos_list.append((int(line.split("-")[0]), int(line.split("-")[1]))) |
| | | if int("093000") <= int(time_.replace(":", "")) <= int("150000"): |
| | | pos_list.append((int(line.split("-")[0]), int(line.split("-")[1]))) |
| | | return pos_list |
| | | |
| | | |
| | |
| | | if line.find("code={}".format(code)) < 0: |
| | | continue |
| | | print(line) |
| | | time_ = __get_log_time(line) |
| | | if int("093000") > int(time_.replace(":", "")) or int(time_.replace(":", "")) > int("150000"): |
| | | continue |
| | | |
| | | if line.find("获取到买入信号起始点") > 0: |
| | | str_ = line.split("获取到买入信号起始点:")[1].strip() |
| | |
| | | |
| | | if __name__ == '__main__': |
| | | # logger_l2_process_time.info("test123") |
| | | codes = ["000909"] |
| | | codes = ["002766"] |
| | | for code in codes: |
| | | export_logs(code) |
| | | |