| | |
| | | from huaxin_client.client_network import SendResponseSkManager |
| | | |
| | | # 活动时间 |
| | | from log_module.log import logger_local_huaxin_l2_error |
| | | from log_module.log import logger_local_huaxin_l2_error, logger_local_huaxin_l2_upload |
| | | |
| | | order_detail_upload_active_time_dict = {} |
| | | transaction_upload_active_time_dict = {} |
| | |
| | | |
| | | tmep_order_detail_queue_dict[code].put( |
| | | (data['SecurityID'], data['Price'], data['Volume'], data['Side'], data['OrderType'], data['OrderTime'], |
| | | data['MainSeq'], data['SubSeq'], data['OrderNO'], data['OrderStatus'], int(time.time()*1000))) |
| | | data['MainSeq'], data['SubSeq'], data['OrderNO'], data['OrderStatus'], int(time.time() * 1000))) |
| | | |
| | | |
| | | # 添加逐笔成交 |
| | |
| | | temp = tmep_order_detail_queue_dict[code].get() |
| | | udatas.append(temp) |
| | | if udatas: |
| | | start_time = time.time() |
| | | upload_data(code, "l2_order", udatas) |
| | | use_time = int((time.time() - start_time)*1000) |
| | | if use_time > 20: |
| | | logger_local_huaxin_l2_upload.info(f"{code}-上传代码耗时:{use_time}ms") |
| | | |
| | | time.sleep(0.01) |
| | | |
| | |
| | | if l2.l2_data_util.L2DataUtil.is_same_time(now_time_str, latest_time): |
| | | cls.__process_not_order(code, start_index, end_index, capture_timestamp, is_first_code) |
| | | |
| | | logger_l2_process.info("code:{} 处理数据范围: {}-{} 处理时间:{} 截图时间戳:{}", code, add_datas[0]["index"], |
| | | add_datas[-1]["index"], round(t.time() * 1000) - __start_time, |
| | | capture_timestamp) |
| | | async_log_util.info(logger_l2_process, "code:{} 处理数据范围: {}-{} 处理时间:{} 截图时间戳:{}", code, |
| | | add_datas[0]["index"], |
| | | add_datas[-1]["index"], round(t.time() * 1000) - __start_time, |
| | | capture_timestamp) |
| | | # __start_time = l2_data_log.l2_time(code, round(t.time() * 1000) - __start_time, |
| | | # "l2数据处理时间") |
| | | |
| | |
| | | 日志分析 |
| | | """ |
| | | # 获取不可以下单的原因 |
| | | import datetime |
| | | import os |
| | | |
| | | import constant |
| | |
| | | line = f.readline() |
| | | |
| | | |
| | | # 分析L2数据传输时间 |
| | | def analyze_l2_data_transformation(path_): |
| | | with open(path_, 'r') as f: |
| | | while True: |
| | | line = f.readline() |
| | | if not line: |
| | | break |
| | | datas = line.split("|") |
| | | create_time = datas[0].strip() |
| | | data = datas[2].split("-")[1].strip() |
| | | code = data.split("#")[0] |
| | | l2_data = data.split("#")[1] |
| | | l2_data = eval(l2_data) |
| | | max_time_data = None |
| | | min_time_data = None |
| | | for d in l2_data: |
| | | if len(d) > 10: |
| | | if max_time_data is None: |
| | | max_time_data = d |
| | | if min_time_data is None: |
| | | min_time_data = d |
| | | if d[10] > max_time_data[10]: |
| | | max_time_data = d |
| | | if d[10] < min_time_data[10]: |
| | | min_time_data = d |
| | | if max_time_data and min_time_data: |
| | | dt = datetime.datetime.strptime(create_time.split(".")[0], "%Y-%m-%d %H:%M:%S") |
| | | create_timestamp = int(dt.timestamp() * 1000) + int(create_time.split(".")[1]) |
| | | if create_timestamp - min_time_data[10] > 20: |
| | | print(create_time, f"数量:{len(l2_data)}", code, create_timestamp - min_time_data[10], |
| | | create_timestamp - max_time_data[10]) |
| | | |
| | | pass |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | print(get_kpl_can_buy_reasons_dict()) |
| | | analyze_l2_data_transformation("D:\\logs\\huaxin_l2\\orderdetail.2023-08-23.log") |
| | |
| | | # L2逐笔委托 |
| | | data = data_json["data"] |
| | | code = data["code"] |
| | | timestamp = data.get("time") |
| | | datas = data["data"] |
| | | hx_logger_l2_orderdetail.info(f"{code}#{datas}") |
| | | async_log_util.info(hx_logger_l2_orderdetail,f"{code}#{timestamp}->{int(time.time()*1000)}#{datas}") |
| | | l2_log.threadIds[code] = random.randint(0, 100000) |
| | | l2_data_manager_new.L2TradeDataProcessor.process_huaxin(code, datas) |
| | | finally: |