From 794d154fb8dd8aaf2f4a670a59f85302287d5b2b Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期二, 03 九月 2024 17:12:02 +0800 Subject: [PATCH] 历史板块判断调整/有效执行位判断 --- l2/l2_data_manager_new.py | 65 +++++++++++++++++--------------- 1 files changed, 34 insertions(+), 31 deletions(-) diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py index de11f6b..d3450d5 100644 --- a/l2/l2_data_manager_new.py +++ b/l2/l2_data_manager_new.py @@ -731,7 +731,7 @@ return False __start_time = tool.get_now_timestamp() - can, need_clear_data, reason = cls.__can_buy_first(code) + can, need_clear_data, reason, is_valid_exec_index = cls.__can_buy_first(code) # __start_time = l2_data_log.l2_time(code, tool.get_now_timestamp() - __start_time, "鏈�鍚庡垽鏂槸鍚﹁兘涓嬪崟", force=True) # 鍒犻櫎铏氭嫙涓嬪崟 @@ -741,6 +741,11 @@ order_begin_pos = cls.__get_order_begin_pos( code) if not can: + if not is_valid_exec_index: + if cls.__latest_exec_indexes.get(code) and cls.__latest_exec_indexes[code][ + -1] == order_begin_pos.buy_exec_index: + # 濡傛灉鎵ц浣嶇疆绠楀仛鏃犳晥锛屽氨闇�瑕佸垹闄ゅ綋鍓嶆墽琛屼綅缃� + cls.__latest_exec_indexes[code].pop() l2_log.debug(code, "涓嶅彲浠ヤ笅鍗曪紝鍘熷洜锛歿}", reason) trade_record_log_util.add_cant_place_order_log(code, reason) if need_clear_data: @@ -848,26 +853,29 @@ @classmethod def __can_buy_first(cls, code): - # if code.find("60") == 0: - # return False, True, f"涓婅瘉鏆備笉浜ゆ槗" + """ + 鏄惁鍙互涓嬪崟 + @param code: + @return:(鏄惁鍙互涓嬪崟, 鏄惁娓呯悊淇″彿鏁版嵁, 涓嶈兘涓嬪崟娑堟伅, 鏄惁绠楁湁鏁堟墽琛�) + """ if not cls.__TradeStateManager.is_can_buy_cache(): - return False, True, f"浠婃棩宸茬姝氦鏄�" + return False, True, f"浠婃棩宸茬姝氦鏄�", True if l2_trade_util.is_in_forbidden_trade_codes(code): - return False, True, f"浠g爜绂佹浜ゆ槗" + return False, True, f"浠g爜绂佹浜ゆ槗", True if cls.__PauseBuyCodesManager.is_in_cache(code): - return False, True, f"璇ヤ唬鐮佽鏆傚仠浜ゆ槗" + return False, True, f"璇ヤ唬鐮佽鏆傚仠浜ゆ槗", True now_time_int = int(tool.get_now_time_str().replace(":", "")) if now_time_int >= 145700: - return False, True, f"14:57鍚庝笉鑳戒氦鏄�" + return False, True, f"14:57鍚庝笉鑳戒氦鏄�", True if 130100 >= now_time_int >= 112900 or now_time_int < 93100: if now_time_int < 93100: # 鍒ゆ柇杩�120澶╂槸鍚︽湁娑ㄥ仠 k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) if k_format and len(k_format) >= 12 and not k_format[11]: - return False, True, f"09:31:00涔嬪墠涓嬪崟锛�90涓氦鏄撴棩鏃犳定鍋�" + return False, True, f"09:31:00涔嬪墠涓嬪崟锛�90涓氦鏄撴棩鏃犳定鍋�", True # 鍒ゆ柇鎴愪氦鐨勫ぇ鍗曟暟閲� data_list = BigOrderDealManager().get_total_buy_money_list(code) @@ -879,20 +887,15 @@ fdatas.append(d) thresh_count = 3 if tool.is_sh_code(code) else 1 if len(fdatas) < thresh_count: - return False, True, f"09:31:00涔嬪墠涓嬪崟锛屾垚浜ゅぇ鍗曟暟閲忥紙{len(fdatas)}锛変笉瓒硔thresh_count}涓�" + return False, True, f"09:31:00涔嬪墠涓嬪崟锛屾垚浜ゅぇ鍗曟暟閲忥紙{len(fdatas)}锛変笉瓒硔thresh_count}涓�", True else: # 鍒ゆ柇鏁版嵁鏄惁鍗� total_datas = local_today_datas.get(code) if tool.trade_time_sub_with_ms(tool.get_now_time_with_ms_str(), L2DataUtil.get_time_with_ms(total_datas[-1]["val"])) > 500: - return False, True, f"09:31:00涔嬪墠涓嬪崟锛孡2鏁版嵁鏃堕棿鐩稿樊500ms浠ヤ笂" + return False, True, f"09:31:00涔嬪墠涓嬪崟锛孡2鏁版嵁鏃堕棿鐩稿樊500ms浠ヤ笂", True else: - return False, True, f"09:31:00涔嬪墠锛�11:29:00-13:01:00涓嶈兘浜ゆ槗" - - # place_order_count = cls.__PlaceOrderCountManager.get_place_order_count(code) - # if place_order_count > 0 and now_time_int >= 140000: - # # 14:00:00鍚庡彧鎵撹�佸ぇ鐨勫洖灏� - # return False, True, f"14:00:00涓嶆墦鍥炲皝" + return False, True, f"09:31:00涔嬪墠锛�11:29:00-13:01:00涓嶈兘浜ゆ槗", True limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) @@ -904,9 +907,9 @@ # 灏忓競鍊奸珮鑲′环鍙拱 zyltgb = global_util.zyltgb_map.get(code) if zyltgb > 25e8 or limit_up_price > constant.MAX_SUBSCRIPT_CODE_PRICE: - return False, True, f"鑲′环澶т簬{constant.MAX_CODE_PRICE}鍧�/灏忎簬{constant.MIN_CODE_PRICE}鍧�" + return False, True, f"鑲′环澶т簬{constant.MAX_CODE_PRICE}鍧�/灏忎簬{constant.MIN_CODE_PRICE}鍧�", True else: - return False, True, f"鑲′环灏忎簬{constant.MIN_CODE_PRICE}鍧�" + return False, True, f"鑲′环灏忎簬{constant.MIN_CODE_PRICE}鍧�", True # place_order_count = cls.__PlaceOrderCountManager.get_place_order_count(code) # if place_order_count and place_order_count >= 10: @@ -916,7 +919,7 @@ # ---------鍧囦环绾︽潫------------- average_rate = cls.__Buy1PriceManager.get_average_rate(code) if average_rate and average_rate <= 0.01 and tool.trade_time_sub(tool.get_now_time_str(), "10:30:00") >= 0: - return False, True, f"鍧囦环娑ㄥ箙({average_rate})灏忎簬1%" + return False, True, f"鍧囦环娑ㄥ箙({average_rate})灏忎簬1%", True total_data = local_today_datas.get(code) @@ -927,26 +930,26 @@ if limit_up_data: limit_up_time = tool.to_time_str(limit_up_data[2]) if int(limit_up_time.replace(":", "")) < int("093000"): - return False, True, f"涓婅瘉寮�涓�09:32涔嬪墠涓嶄笅鍗�" + return False, True, f"涓婅瘉寮�涓�09:32涔嬪墠涓嶄笅鍗�", True # ------------鎸傚崟鏃堕棿绾︽潫---------- order_begin_pos = cls.__get_order_begin_pos( code) if not trade_result_manager.can_place_order_for_cancel_time(code, total_data[order_begin_pos.buy_exec_index]): - return False, True, f"璺濈涓婃鎸傚崟灏忎簬鏃堕棿闄愬埗" + return False, True, f"璺濈涓婃鎸傚崟灏忎簬鏃堕棿闄愬埗", True # ------------鏉垮潡绾︽潫------------- if not cls.__WantBuyCodesManager.is_in_cache(code): # 鎯充拱鍗曟棤鏉垮潡绾︽潫 block_buy_result = buy_strategy_util.is_block_can_buy(code, cls.__get_can_buy_block(code)) if not block_buy_result[0]: - return block_buy_result + return block_buy_result[0], block_buy_result[1], block_buy_result[2], True if constant.L2_SOURCE_TYPE == constant.L2_SOURCE_TYPE_HUAXIN: # ---------------------鍒ゆ柇鏄惁涓烘澘涓婃斁閲�---------------------- trade_price = current_price_process_manager.get_trade_price(code) if trade_price is None: - return False, True, f"灏氭湭鑾峰彇鍒板綋鍓嶆垚浜や环" + return False, True, f"灏氭湭鑾峰彇鍒板綋鍓嶆垚浜や环", True # 鍒ゆ柇鏄惁涓烘澘涓婃斁閲忥細 # 1.褰撳墠鎴愪氦浠蜂负娑ㄥ仠浠� # 2.璺濈鏈�杩戠殑闈炴澘涓婃垚浜ょ殑鏃堕棿澶т簬涓�涓槇鍊� @@ -990,13 +993,13 @@ trade_index, order_begin_pos.buy_single_index) if not cancel_rate_reieved_info[0]: - return False, True, f"鏉夸笂鏀鹃噺璺濈杩�({not_limit_up_trade_time_with_ms})锛屾湁灏忕兢鎾�, 鏁翠綋鎾ゅ崟姣斾緥涓嶈冻锛坽trade_index}-{order_begin_pos.buy_single_index}锛墈cancel_rate_reieved_info[1]}" + return False, True, f"鏉夸笂鏀鹃噺璺濈杩�({not_limit_up_trade_time_with_ms})锛屾湁灏忕兢鎾�, 鏁翠綋鎾ゅ崟姣斾緥涓嶈冻锛坽trade_index}-{order_begin_pos.buy_single_index}锛墈cancel_rate_reieved_info[1]}", False else: - return False, True, f"鏉夸笂鏀鹃噺璺濈杩�({not_limit_up_trade_time_with_ms})锛屾病鏈夊皬缇ゆ挙锛坽trade_index}-{order_begin_pos.buy_single_index}锛�" + return False, True, f"鏉夸笂鏀鹃噺璺濈杩�({not_limit_up_trade_time_with_ms})锛屾病鏈夊皬缇ゆ挙锛坽trade_index}-{order_begin_pos.buy_single_index}锛�", False except Exception as e: l2_log.info(code, logger_l2_error, f"鏉夸笂鏀鹃噺({not_limit_up_trade_time_with_ms})涓嶈冻寮傚父锛歿str(e)}") logger_l2_error.exception(e) - return False, True, f"鏉夸笂鏀鹃噺璁$畻寮傚父" + return False, True, f"鏉夸笂鏀鹃噺璁$畻寮傚父", False # -------鏄惁璺濈鎴愪氦杩涘害浣嶅お杩�-------- buy1_money = code_price_manager.Buy1PriceManager().get_latest_buy1_money(code) @@ -1007,7 +1010,7 @@ if not buy1_money: buy1_money = 1 if buy_strategy_util.is_far_away_from_trade_index(code, trade_index, buy1_money): - return False, True, f"璺濈鎴愪氦杩涘害浣嶅お杩滐細鎴愪氦杩涘害-{trade_index} 涔�1-{buy1_money}" + return False, True, f"璺濈鎴愪氦杩涘害浣嶅お杩滐細鎴愪氦杩涘害-{trade_index} 涔�1-{buy1_money}", False # ------------------涓婅瘉涓嬪崟闇�瑕佹湁鎴愪氦澶у崟锛堝寘鍚富鍔ㄤ拱涓庤鍔ㄤ拱锛夋垨鑰呮寕涔扮殑澶у崟----------------- if tool.is_sh_code(code): @@ -1028,7 +1031,7 @@ limit_up_price, min_money=min_money) if left_count < 1: - return False, False, f"娌℃湁宸叉寕鎴栬�呮垚浜ょ殑澶у崟" + return False, False, f"娌℃湁宸叉寕鎴栬�呮垚浜ょ殑澶у崟", False place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code) # ------------------绗竴鍜岀浜屾涓嬪崟閮藉繀椤昏鏈夎嚦灏戜竴绗旀湭鎴愪氦鐨勫ぇ鍗�-------------------------- # 璁$畻澶у崟 @@ -1042,7 +1045,7 @@ total_datas[-1]["index"], limit_up_price, min_money) if left_count < 1: - return False, False, f"绗瑊place_order_count + 1}涓嬪崟鏃犲緟鎴愪氦鐨勫ぇ鍗�" + return False, False, f"绗瑊place_order_count + 1}涓嬪崟鏃犲緟鎴愪氦鐨勫ぇ鍗�", False # -------鍒ゆ柇鏄惁鏄噺鍖栦笅鍗曪紝濡傛灉鏄氨涓嶈窡鍒颁笅鍗�-------- # 閲嶈锛氶噺鍖栦笅鍗曚細澧炲姞涓嬪崟娆℃暟锛屾澘鍧椾笅鍗曚腑鏈変笅鍗曟鏁扮殑浣跨敤锛屾墍浠ユ澘鍧楅渶瑕佸湪閲忓寲鍒ゆ柇涔嬪墠 @@ -1053,8 +1056,8 @@ is_quantization_result = buy_strategy_util.is_quantization(code, range_indexes[0], range_indexes[1]) if is_quantization_result[0]: cls.__next_buy_time_dict[code] = is_quantization_result[1] - return False, True, is_quantization_result[2] - return True, False, "婊¤冻涓嬪崟鏉′欢" + return False, True, is_quantization_result[2], True + return True, False, "婊¤冻涓嬪崟鏉′欢", True # 鑾峰彇鍙互涔扮殑鏉垮潡 @classmethod -- Gitblit v1.8.0