From 302500d0ddcaf02b6dc3e182ad77d78178deaa44 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期五, 30 八月 2024 14:46:28 +0800 Subject: [PATCH] 板上买判断 --- l2/l2_data_manager_new.py | 39 +++++++++++++++++++++++++++++++++------ 1 files changed, 33 insertions(+), 6 deletions(-) diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py index 3f9ca9b..1ee1ba3 100644 --- a/l2/l2_data_manager_new.py +++ b/l2/l2_data_manager_new.py @@ -263,6 +263,9 @@ # 涓柇鏈壒娆′拱鍏ユ暟鎹鐞� __break_current_batch_data_for_buy_dict = {} + # 鏈�杩戠殑鎵ц浣嶇疆 + __latest_exec_indexes = {} + # 鑾峰彇浠g爜璇勫垎 @classmethod def get_code_scores(cls): @@ -947,13 +950,28 @@ # 1.褰撳墠鎴愪氦浠蜂负娑ㄥ仠浠� # 2.璺濈鏈�杩戠殑闈炴澘涓婃垚浜ょ殑鏃堕棿澶т簬涓�涓槇鍊� if abs(limit_up_price - float(trade_price)) < 0.001: + latest_exec_indexes = cls.__latest_exec_indexes[code] + # 鍒ゆ柇鏄惁鏄偢寮�鍚庝拱鍏� + last_exec_index = 0 + if len(latest_exec_indexes) > 1: + last_exec_index = latest_exec_indexes[-2] # 鑾峰彇鏈�杩戠殑闈炴定鍋滀环鎴愪氦鏃堕棿 not_limit_up_trade_time_with_ms = current_price_process_manager.get_trade_not_limit_up_time_with_ms( code) - threshold_time_space = buy_condition_util.get_cancel_and_buy_space_time(code) - if not not_limit_up_trade_time_with_ms or tool.trade_time_sub_with_ms( - L2DataUtil.get_time_with_ms(total_data[-1]['val']), - not_limit_up_trade_time_with_ms) >= threshold_time_space: + + is_limit_up_buy = True + if not_limit_up_trade_time_with_ms: + t1 = int( + L2DataUtil.get_time_with_ms(total_data[last_exec_index]["val"]).replace(":", "").replace(".", + "")) + t2 = int(not_limit_up_trade_time_with_ms.replace(":", "").replace(".", "")) + t3 = int(L2DataUtil.get_time_with_ms(total_data[order_begin_pos.buy_exec_index]["val"]).replace(":", + "").replace( + ".", "")) + if t1 < t2 <= t3: + # 鐐告澘鏃堕棿鍦ㄤ袱娆′笅鍗曟椂闂翠腑闂� + is_limit_up_buy = False + if is_limit_up_buy: # 鍒ゆ柇鎴愪氦杩涘害鍒板綋鍓嶆暟鎹殑绗旀暟锛屽鏋滃皯浜�10绗斾笖杩樻湁鏈垚浜ょ殑澶у崟锛�>=299锛夊氨鍙互涓嬪崟 trade_index, is_default = cls.__TradeBuyQueue.get_traded_index(code) if trade_index is None: @@ -1390,8 +1408,10 @@ if not has_single: # 娌℃湁淇″彿锛屽鏋滃綋鍓嶆暟鎹槸娑ㄥ仠涔板氨璁板綍鏃ュ織锛岄槻姝㈣褰曡繃澶氱殑鏃ュ織 if L2DataUtil.is_limit_up_price_buy( - total_datas[compute_start_index]["val"]) and L2DataUtil.is_limit_up_price_buy(total_datas[compute_end_index]["val"]): - async_log_util.info(logger_l2_trade_buy_queue, "灏氭湭鑾峰彇鍒颁拱鍏ヤ俊鍙凤細 code-{} start_index-{} end_index-{} msg-{}", code, + total_datas[compute_start_index]["val"]) and L2DataUtil.is_limit_up_price_buy( + total_datas[compute_end_index]["val"]): + async_log_util.info(logger_l2_trade_buy_queue, + "灏氭湭鑾峰彇鍒颁拱鍏ヤ俊鍙凤細 code-{} start_index-{} end_index-{} msg-{}", code, compute_start_index, compute_end_index, sell_info) fast_msg = None if has_single: @@ -1484,6 +1504,13 @@ threshold_money=threshold_money)) cls.__LimitUpTimeManager.save_limit_up_time(code, total_datas[new_buy_exec_index]["val"]["time"]) l2_log.debug(code, "delete_buy_cancel_point") + if code not in cls.__latest_exec_indexes: + cls.__latest_exec_indexes[code] = [] + cls.__latest_exec_indexes[code].append(new_buy_exec_index) + # 淇濈暀鏈�杩�3娆$殑涔板叆鎵ц浣嶇疆 + if len(cls.__latest_exec_indexes[code]) > 3: + cls.__latest_exec_indexes[code] = cls.__latest_exec_indexes[code][-3:] + # 鐩存帴涓嬪崟 ordered = cls.__buy(code, capture_time, total_datas[-1], total_datas[-1]["index"], is_first_code) -- Gitblit v1.8.0