From 1e64a42737bb6cc7192c68633d3c168ca150da97 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期三, 22 十一月 2023 19:08:09 +0800 Subject: [PATCH] L下动态更新一次/加载订单是否成交 --- l2/code_price_manager.py | 30 +++++++++++++++++++++++++----- 1 files changed, 25 insertions(+), 5 deletions(-) diff --git a/l2/code_price_manager.py b/l2/code_price_manager.py index aea0a50..dba7264 100644 --- a/l2/code_price_manager.py +++ b/l2/code_price_manager.py @@ -20,6 +20,10 @@ __latest_data = {} __current_buy_1_price = {} __buy1_price_info_cache = {} + # 涔�1鐨勯噾棰� + __latest_buy1_money_dict = {} + # 鏈�杩�3鍒嗛挓鍐呯殑涔�1閲戦 + __latest_3m_buy1_money_list_dict = {} __open_limit_up_lowest_price_cache = {} __instance = None @@ -137,13 +141,10 @@ # 澶勭悊 - def process(self, code, buy_1_price, time_str, limit_up_price, sell_1_price, sell_1_volumn): - data_str = f"{buy_1_price},{time_str},{limit_up_price},{sell_1_price},{sell_1_volumn}" + def process(self, code, buy_1_price, buy_1_volume, time_str, limit_up_price, sell_1_price, sell_1_volumn): + data_str = f"{buy_1_price},{buy_1_volume},{time_str},{limit_up_price},{sell_1_price},{sell_1_volumn}" if self.__latest_data.get(code) == data_str: return - self.__latest_data[code] = data_str - # 淇濆瓨涔�1浠锋牸 - self.__save_buy1_price(code, buy_1_price) # 璁板綍鏃ュ織 logger_trade_queue_price_info.info( @@ -151,6 +152,18 @@ # 涔�1浠锋牸涓嶈兘灏忎簬1鍧� if float(buy_1_price) < 1.0: return + + ## 璁板綍鏈�杩戠殑涔�1閲戦 + if code not in self.__latest_3m_buy1_money_list_dict: + self.__latest_3m_buy1_money_list_dict[code] = [] + self.__latest_3m_buy1_money_list_dict[code].append((time_str, int(buy_1_price * buy_1_volume))) + if len(self.__latest_3m_buy1_money_list_dict[code]) > 80: + self.__latest_3m_buy1_money_list_dict[code] = self.__latest_3m_buy1_money_list_dict[code][-80:] + self.__latest_data[code] = data_str + self.__latest_buy1_money_dict[code] = int(buy_1_price * buy_1_volume) + + # 淇濆瓨涔�1浠锋牸 + self.__save_buy1_price(code, buy_1_price) is_limit_up = abs(float(limit_up_price) - float(buy_1_price)) < 0.01 old_limit_up_time, old_open_limit_up_time = self.__get_buy1_price_info_cache(code) @@ -232,6 +245,13 @@ if limit_up_time is None: self.__save_buy1_price_info(code, time_str, None) + # 鑾峰彇鏈�杩戠殑涔�1閲戦 + def get_latest_buy1_money(self, code): + return self.__latest_buy1_money_dict.get(code) + + def get_latest_3m_buy1_money_list(self, code): + return self.__latest_3m_buy1_money_list_dict.get(code) + if __name__ == "__main__": print(Buy1PriceManager().get_limit_up_info("002777")) -- Gitblit v1.8.0