From a9f7afb116ed37a37d84815510956b0c72d007a1 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期四, 20 三月 2025 10:21:13 +0800 Subject: [PATCH] 日志调整 --- l2/l2_transaction_data_processor.py | 71 ++++++++++++++++++++++------------- 1 files changed, 45 insertions(+), 26 deletions(-) diff --git a/l2/l2_transaction_data_processor.py b/l2/l2_transaction_data_processor.py index cce490d..516458c 100644 --- a/l2/l2_transaction_data_processor.py +++ b/l2/l2_transaction_data_processor.py @@ -20,7 +20,8 @@ from l2.l2_transaction_data_manager import HuaXinBuyOrderManager, HuaXinSellOrderStatisticManager, BigOrderDealManager from l2.place_order_single_data_manager import L2TradeSingleDataProcessor from log_module import async_log_util -from log_module.log import hx_logger_l2_debug, logger_l2_trade_buy_queue, logger_debug, hx_logger_l2_upload +from log_module.log import hx_logger_l2_debug, logger_l2_trade_buy_queue, logger_debug, hx_logger_l2_upload, \ + logger_trade, logger_l2_trade from trade import current_price_process_manager, trade_constant import concurrent.futures @@ -59,7 +60,6 @@ @return: """ - @dask.delayed def statistic_big_buy_data(): buy_datas, bigger_buy_datas = HuaXinBuyOrderManager.statistic_big_buy_data(code, fdatas, limit_up_price) if buy_datas: @@ -90,24 +90,28 @@ logger_debug.exception(e) return buy_datas - @dask.delayed def statistic_big_sell_data(): sell_datas = HuaXinSellOrderStatisticManager.statistic_big_sell_data(code, fdatas) if sell_datas: BigOrderDealManager().add_sell_datas(code, sell_datas) return sell_datas - @dask.delayed def statistic_big_data(f1_, f2_): temp_data = f1_, f2_ return temp_data limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) - # 骞惰澶勭悊涔板崟涓庡崠鍗� - f1 = statistic_big_buy_data() - f2 = statistic_big_sell_data() - dask_result = statistic_big_data(f1, f2) - buy_datas, sell_datas = dask_result.compute() + + if len(fdatas) > 100: + # 骞惰澶勭悊涔板崟涓庡崠鍗� + # 瓒呰繃100鏉℃暟鎹墠闇�瑕佸苟琛屽鐞� + f1 = dask.delayed(statistic_big_buy_data)() + f2 = dask.delayed(statistic_big_sell_data)() + dask_result = dask.delayed(statistic_big_data)(f1, f2) + buy_datas, sell_datas = dask_result.compute() + else: + buy_datas = statistic_big_buy_data() + sell_datas = statistic_big_sell_data() # L鎾ょ殑姣斾緥涓庝拱鍗栧ぇ鍗曟棤鐩存帴鍏崇郴浜� # if buy_datas or sell_datas: # buy_money = BigOrderDealManager().get_total_buy_money(code) @@ -137,10 +141,10 @@ # 璁剧疆鎴愪氦浠� try: current_price_process_manager.set_trade_price(code, fdatas[-1][0][1]) - if limit_up_price > fdatas[-1][0][1]: + if not fdatas[-1][2]: # 娌℃湁娑ㄥ仠 EveryLimitupBigDealOrderManager.open_limit_up(code, f"鏈�鏂版垚浜や环锛歿fdatas[-1][0][1]}") - radical_buy_strategy.clear_data(code) + radical_buy_strategy.clear_data(code, msg=f"娌℃湁娑ㄥ仠锛歿fdatas[-1][0]}") except: pass @@ -238,11 +242,10 @@ if buy_progress_index is not None: buy_progress_index_changed = cls.__TradeBuyQueue.set_traded_index(code, buy_progress_index, total_datas) - async_log_util.info(logger_l2_trade_buy_queue, "鑾峰彇鎴愪氦浣嶇疆鎴愬姛锛� code-{} index-{}", code, - buy_progress_index) + l2_log.info(code, logger_l2_trade_buy_queue, "鑾峰彇鎴愪氦浣嶇疆鎴愬姛锛� code-{} index-{}", code, buy_progress_index) if is_placed_order: - NewGCancelBigNumComputer().set_trade_progress(code, order_begin_pos.buy_single_index, - buy_progress_index) + # NewGCancelBigNumComputer().set_trade_progress(code, order_begin_pos.buy_single_index, + # buy_progress_index) LCancelBigNumComputer().set_trade_progress(code, order_begin_pos.buy_single_index, buy_progress_index, total_datas) @@ -267,11 +270,10 @@ cancel_type=trade_constant.CANCEL_TYPE_W) except: pass - - SCancelBigNumComputer().set_transaction_index(code, order_begin_pos.buy_single_index, - buy_progress_index) - HourCancelBigNumComputer().set_transaction_index(code, order_begin_pos.buy_single_index, - buy_progress_index) + # SCancelBigNumComputer().set_transaction_index(code, order_begin_pos.buy_single_index, + # buy_progress_index) + # HourCancelBigNumComputer().set_transaction_index(code, order_begin_pos.buy_single_index, + # buy_progress_index) else: pass if is_placed_order: @@ -342,6 +344,8 @@ limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) # =====鏍煎紡鍖栨暟鎹�===== # 鏁村舰鏁版嵁锛屾牸寮忥細[(鏁版嵁鏈韩, 鏄惁涓诲姩涔�, 鏄惁娑ㄥ仠, 鎬绘垚浜ら, 涓嶅惈ms鏃堕棿锛屽惈ms鏃堕棿)] + use_time_list = [] + __start_time = int(time.time() * 1000) fdatas = [ [d, d[6] > d[7], limit_up_price == d[1], d[1] * d[2], '', ''] for d in o_datas] @@ -352,6 +356,8 @@ d[5] = temp_time_dict.get(d[0][3]) d[4] = d[5][:8] temp_time_dict.clear() + _start_time = int(time.time() * 1000) + use_time_list.append((_start_time - __start_time, "鏁版嵁鏁村舰")) try: @@ -359,7 +365,7 @@ # 璁剧疆鎴愪氦浠� try: current_price_process_manager.set_trade_price(code, fdatas[-1][0][1]) - if limit_up_price > fdatas[-1][0][1]: + if not fdatas[-1][2]: # 娌℃湁娑ㄥ仠 EveryLimitupBigDealOrderManager.open_limit_up(code, f"鏈�鏂版垚浜や环锛歿fdatas[-1][0][1]}") radical_buy_strategy.clear_data(code) @@ -374,8 +380,7 @@ current_price_process_manager.set_latest_not_limit_up_time(code, last_data[5]) elif not last_data[1] and last_data[2]: # 娑ㄥ仠涓诲姩鍗� - if last_data[2]: - L2LimitUpSellDataManager.clear_data(code) + L2LimitUpSellDataManager.clear_data(code) except: pass @@ -387,9 +392,15 @@ __process_placed_order() else: filter_datas = L2TradeSingleDataProcessor.filter_last_limit_up_sell_data(code, fdatas) + _start_time = int(time.time() * 1000) + use_time_list.append((_start_time - __start_time, "澶勭悊娑ㄥ仠鍗�")) # 鍥炶皟鏁版嵁 - if filter_datas: - data_callback.l2_trade_single_callback.OnLastLimitUpSellDeal(code, filter_datas[0]) + if filter_datas is not None: + l2_log.info(code, logger_l2_trade, f"鏈�鍚庝竴绗旀定鍋滃崠琚悆锛歿filter_datas[0]}") + data_callback.l2_trade_single_callback.OnLastLimitUpSellDeal(code, filter_datas[0][0]) + + _start_time = int(time.time() * 1000) + use_time_list.append((_start_time - __start_time, "澶勭悊涔板叆淇″彿")) # 濡傛灉鏄鍔ㄤ拱灏辨洿鏂版垚浜よ繘搴� if not fdatas[-1][1]: @@ -403,5 +414,13 @@ cls.__statistic_thread_pool.submit(cls.statistic_big_order_infos, code, fdatas, order_begin_pos) else: cls.statistic_big_order_infos(code, fdatas, order_begin_pos) + + _start_time = int(time.time() * 1000) + use_time_list.append((_start_time - __start_time, "缁熻澶у崟")) except Exception as e: - hx_logger_l2_debug.exception(e) \ No newline at end of file + hx_logger_l2_debug.exception(e) + finally: + _start_time = int(time.time() * 1000) + if _start_time - __start_time > 5: + l2_log.info(code, hx_logger_l2_upload, + f"{code}澶勭悊鎴愪氦鐢ㄦ椂锛歿_start_time - __start_time} 鏁版嵁鏁伴噺锛歿len(fdatas)} 璇︽儏:{use_time_list}") -- Gitblit v1.8.0