From 3a87b1c89a76d858e8e7e4e54ff360dc0b8670f5 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期四, 11 九月 2025 16:27:20 +0800 Subject: [PATCH] L撤删除L前撤单与L后后半段撤单 --- l2/l2_limitup_sell_data_manager.py | 52 ++++++++++++++++++++++++++-------------------------- 1 files changed, 26 insertions(+), 26 deletions(-) diff --git a/l2/l2_limitup_sell_data_manager.py b/l2/l2_limitup_sell_data_manager.py index 8e711d0..674ee5a 100644 --- a/l2/l2_limitup_sell_data_manager.py +++ b/l2/l2_limitup_sell_data_manager.py @@ -5,7 +5,7 @@ from l2 import l2_log from l2.l2_data_util import L2DataUtil from log_module import async_log_util, log_export -from log_module.log import hx_logger_l2_sell_delegate, hx_logger_l2_sell_deal +from log_module.log import hx_logger_l2_sell_delegate, hx_logger_l2_sell_deal, logger_debug from utils import tool @@ -71,42 +71,42 @@ return cls.__delegating_sell_num_dict.get(code) @classmethod - def set_deal_datas(cls, code, datas): + def set_deal_datas(cls, code, fdatas): """ 璁剧疆鎴愪氦鐨勫崠鍗� @param code: - @param datas: q.append((data['SecurityID'], data['TradePrice'], data['TradeVolume'],data['OrderTime'], data['MainSeq'], data['SubSeq'], data['BuyNo'],data['SellNo'], data['ExecType'])) + @param fdatas: 鏁版嵁鏈韩鏍煎紡锛� (data['SecurityID'], data['TradePrice'], data['TradeVolume'],data['OrderTime'], data['MainSeq'], data['SubSeq'], data['BuyNo'],data['SellNo'], data['ExecType']) + [(鏁版嵁鏈韩, 鏄惁涓诲姩涔�, 鏄惁娑ㄥ仠, 鎬绘垚浜ら, 涓嶅惈ms鏃堕棿锛屽惈ms鏃堕棿)] @return: 鏄惁瑙﹀彂璁$畻 """ try: - limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) order_no_set = cls.__order_no_set_dict.get(code) if order_no_set is None: order_no_set = set() - limit_up_active_buy_datas = [] - for d in datas: - if abs(d[1] - limit_up_price) > 0.001: - continue + # 缁熻娑ㄥ仠鍗栧崟鐨勬垚浜� + # 鍗栧崟鎴愪氦瀛楀吀 + __deal_order_volume_dict = {} + for d in fdatas: # 鏄惁鏈夋定鍋滀富鍔ㄤ拱鎴愪氦 - if d[6] < d[7]: + if not d[1] or not d[2]: continue - limit_up_active_buy_datas.append(d) - total_deal_volume = 0 - if code in cls.__delegating_sell_num_dict: - for d in datas: - # 鍑忓幓 - if d[7] in order_no_set: - total_deal_volume += d[2] - cls.__delegating_sell_num_dict[code] -= total_deal_volume + if d[0][7] not in __deal_order_volume_dict: + __deal_order_volume_dict[d[0][7]] = 0 + __deal_order_volume_dict[d[0][7]] += d[0][2] - if len(limit_up_active_buy_datas): - async_log_util.l2_data_log.info(hx_logger_l2_sell_deal, - f"娑ㄥ仠涓诲姩涔版垚浜わ細{limit_up_active_buy_datas}") + # 鍑忓幓 + add_order_nos = order_no_set & __deal_order_volume_dict.keys() + _total_deal_volume = sum([__deal_order_volume_dict[x] for x in add_order_nos]) + if code in cls.__delegating_sell_num_dict: + cls.__delegating_sell_num_dict[code] -= _total_deal_volume + if _total_deal_volume > 0: + l2_log.info(code, hx_logger_l2_sell_deal, + f"娑ㄥ仠涓诲姩涔版垚浜わ細{_total_deal_volume}") # 鎵撳嵃鏃ュ織 - async_log_util.l2_data_log.info(hx_logger_l2_sell_deal, - f"鏈夋定鍋滀富鍔ㄥ崠锛歿code}-{datas[-1][3]}-{cls.__delegating_sell_num_dict.get(code)}, 鎴愪氦閲�-{total_deal_volume}") - except: - pass + l2_log.info(code, hx_logger_l2_sell_deal, + f"鏈夋定鍋滀富鍔ㄥ崠锛歿code}-{fdatas[-1][0][3]}-{cls.__delegating_sell_num_dict.get(code)}, 鎴愪氦閲�-{_total_deal_volume}") + except Exception as e: + logger_debug.exception(e) @classmethod def clear_data(cls, code): @@ -123,8 +123,8 @@ if cls.__delegating_sell_num_dict.get(code): cls.__delegating_sell_num_dict[code] = 0 - async_log_util.l2_data_log.info(hx_logger_l2_sell_delegate, - f"鍑虹幇涓诲姩鍗栨竻闄ゆ暟鎹細{code}") + l2_log.info(code, hx_logger_l2_sell_delegate, + f"鍑虹幇涓诲姩鍗栨竻闄ゆ暟鎹細{code}") if __name__ == "__main__": -- Gitblit v1.8.0