From 2f4bf81b042d24d5fbbd2fa7ec3672a06b211264 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期五, 21 三月 2025 15:41:17 +0800 Subject: [PATCH] 根据板块成分股来获取新题材的成分股/成交数据处理优化 --- l2/l2_transaction_data_manager.py | 58 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 42 insertions(+), 16 deletions(-) diff --git a/l2/l2_transaction_data_manager.py b/l2/l2_transaction_data_manager.py index 0b7b836..4594b34 100644 --- a/l2/l2_transaction_data_manager.py +++ b/l2/l2_transaction_data_manager.py @@ -467,6 +467,22 @@ use_time = time.time() - __start_time __start_time = time.time() use_time_list.append(("澶勭悊娑ㄥ仠鍗�", use_time)) + latest_sell_order = cls.__latest_sell_order_dict.get(code) + big_sell_order_ids = cls.__big_sell_order_ids_dict.get(code) + if big_sell_order_ids is None: + big_sell_order_ids = set() + big_sell_order_info = cls.__big_sell_order_info_dict.get(code) + if big_sell_order_info is None: + big_sell_order_info = {} + big_sell_order_info_list = cls.__big_sell_order_info_list_dict.get(code) + if big_sell_order_info_list is None: + big_sell_order_info_list = [] + + latest_all_sell_orders = cls.__latest_all_sell_orders_dict.get(code) + if latest_all_sell_orders is None: + latest_all_sell_orders = [] + + last_trade_data = cls.__last_trade_data_dict.get(code) for d in fdatas: # 鑾峰彇褰撳墠鏄惁涓轰富鍔ㄤ拱 if d[1]: @@ -478,22 +494,20 @@ L2TradeSingleDataProcessor.add_active_limit_up_sell_data(d[0]) # 鍒ゆ柇鏄惁鏄定鍋滆鍔ㄥ彉涓诲姩 - last_trade_data = cls.__last_trade_data_dict.get(code) if last_trade_data and last_trade_data[1] and last_trade_data[2]: if d[2]: # 娑ㄥ仠琚姩鍙樹富鍔� L2TradeSingleDataManager.set_sell_passive_to_active_datas(code, last_trade_data[0], d[0]) # cls.__latest_sell_order_info_list_dict[code].append(d) - if code not in cls.__latest_sell_order_dict: - cls.__latest_sell_order_dict[code] = [d[0][7], d[0][2], d[0][1], (d[0][3], d[0][6]), - (d[0][3], d[0][6])] + if latest_sell_order is None: + latest_sell_order = [d[0][7], d[0][2], d[0][1], (d[0][3], d[0][6]), (d[0][3], d[0][6])] else: - if cls.__latest_sell_order_dict[code][0] == d[0][7]: - cls.__latest_sell_order_dict[code][1] += d[0][2] - cls.__latest_sell_order_dict[code][2] = d[0][1] - cls.__latest_sell_order_dict[code][4] = (d[0][3], d[0][6]) + if latest_sell_order[0] == d[0][7]: + latest_sell_order[1] += d[0][2] + latest_sell_order[2] = d[0][1] + latest_sell_order[4] = (d[0][3], d[0][6]) else: - info = cls.__latest_sell_order_dict[code] + info = latest_sell_order # 涓婁釜鍗栧崟鎴愪氦瀹屾垚 # 灏佸瓨鏁版嵁锛岃绠楁柊璧风偣 @@ -501,22 +515,34 @@ # 澶т簬50w鍔犲叆鍗栧崟 money = info[1] * info[2] if money >= 500000: - cls.__big_sell_order_ids_dict[code].add(info[0]) - cls.__big_sell_order_info_dict[code][info[0]] = info - cls.__big_sell_order_info_list_dict[code].append(info) + big_sell_order_ids.add(info[0]) + big_sell_order_info[info[0]] = info + big_sell_order_info_list.append(info) # 鍙繚鐣�10w浠ヤ笂鐨勫崟 if money > 100000: - cls.__latest_all_sell_orders_dict[code].append(info) + latest_all_sell_orders.append(info) l2_log.info(code, hx_logger_l2_transaction_sell_order, f"{info}") if limit_up_price == info[2]: # 灏嗘定鍋滀富鍔ㄥ崠璁板叆鏃ュ織 l2_log.info(code, hx_logger_l2_active_sell, f"{info}") - cls.__latest_sell_order_dict[code] = [d[0][7], d[0][2], d[0][1], (d[0][3], d[0][6]), - (d[0][3], d[0][6])] + latest_sell_order = [d[0][7], d[0][2], d[0][1], (d[0][3], d[0][6]), + (d[0][3], d[0][6])] finally: - cls.__last_trade_data_dict[code] = d + last_trade_data = d + + cls.__last_trade_data_dict[code] = last_trade_data + if latest_sell_order: + cls.__latest_sell_order_dict[code] = latest_sell_order + if big_sell_order_ids: + cls.__big_sell_order_ids_dict[code] = big_sell_order_ids + if big_sell_order_info: + cls.__big_sell_order_info_dict[code] = big_sell_order_info + if big_sell_order_info_list: + cls.__big_sell_order_info_list_dict[code] = big_sell_order_info_list + if latest_all_sell_orders: + cls.__latest_all_sell_orders_dict[code] = latest_all_sell_orders use_time = time.time() - __start_time __start_time = time.time() -- Gitblit v1.8.0