From 9513c56bfd52852356d177a0c68d957b2219a6ad Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期三, 20 十二月 2023 18:02:27 +0800
Subject: [PATCH] 买入条件调整

---
 l2/l2_data_manager_new.py |  171 +++++++++++++++++++++++++++++---------------------------
 1 files changed, 88 insertions(+), 83 deletions(-)

diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py
index ef73366..550d20f 100644
--- a/l2/l2_data_manager_new.py
+++ b/l2/l2_data_manager_new.py
@@ -842,7 +842,7 @@
         limit_up_price = gpcode_manager.get_limit_up_price(code)
 
         if float(limit_up_price) >= constant.MAX_CODE_PRICE:
-            HighIncreaseCodeManager().add_code(code)
+            # HighIncreaseCodeManager().add_code(code)
             return False, True, f"鑲′环澶т簬{constant.MAX_CODE_PRICE}鍧�"
 
         # place_order_count = cls.__PlaceOrderCountManager.get_place_order_count(code)
@@ -925,22 +925,25 @@
         #     return False, True, f"鐐告澘鍚庢渶浣庝环璺岃嚦5%浠ヤ笅"
 
         # 鍥炲皝鐨勭エ锛屼笅13:15涔板叆闇�瑕佸垽鏂澘鍧楁槸鍚︿负鐙嫍
-        if open_limit_up_lowest_price and int(total_data[-1]["val"]["time"].replace(":", "")) > 131500:
-            # 鑾峰彇褰撳墠绁ㄧ殑娑ㄥ仠鍘熷洜
-            if code in LimitUpCodesPlateKeyManager.today_total_limit_up_reason_dict:
-                limit_up_reason = kpl_data_manager.KPLLimitUpDataRecordManager.get_current_block(code)
-                if limit_up_reason and limit_up_reason not in constant.KPL_INVALID_BLOCKS:
-                    # 鍒ゆ柇鏄惁鏄嫭鑻�
-                    codes = kpl_data_manager.KPLLimitUpDataRecordManager.get_current_codes_by_block(limit_up_reason)
-                    if codes:
-                        codes = copy.deepcopy(codes)
-                        codes.discard(code)
-                    if not codes:
-                        return False, True, f"13:15浠ュ悗鐐告澘涔嬪悗涓嬪崟锛岋紙{limit_up_reason}锛� 涓虹嫭鑻�"
+        # if open_limit_up_lowest_price and int(total_data[-1]["val"]["time"].replace(":", "")) > 131500:
+        #     # 鑾峰彇褰撳墠绁ㄧ殑娑ㄥ仠鍘熷洜
+        #     if code in LimitUpCodesPlateKeyManager.today_total_limit_up_reason_dict:
+        #         limit_up_reason = kpl_data_manager.KPLLimitUpDataRecordManager.get_current_block(code)
+        #         if limit_up_reason and limit_up_reason not in constant.KPL_INVALID_BLOCKS:
+        #             # 鍒ゆ柇鏄惁鏄嫭鑻�
+        #             codes = kpl_data_manager.KPLLimitUpDataRecordManager.get_current_codes_by_block(limit_up_reason)
+        #             if codes:
+        #                 codes = copy.deepcopy(codes)
+        #                 codes.discard(code)
+        #             if not codes:
+        #                 return False, True, f"13:15浠ュ悗鐐告澘涔嬪悗涓嬪崟锛岋紙{limit_up_reason}锛� 涓虹嫭鑻�"
         # 鏆傛椂娉ㄩ噴鎯充拱鍗曞姛鑳�
         # if not cls.__WantBuyCodesManager.is_in_cache(code):
         # if cls.__TradeTargetCodeModeManager.get_mode_cache() == TradeTargetCodeModeManager.MODE_ONLY_BUY_WANT_CODES:
         #     return False, True, f"鍙拱鎯充拱鍗曚腑鐨勪唬鐮�"
+
+        if HighIncreaseCodeManager().is_in(code):
+            return False, True, f"娑ㄥ箙杩囬珮锛�5澶╁唴3娆℃定鍋�"
         return cls.can_buy_first(code, limit_up_price)
         # else:
         #     return True, False, "鍦ㄦ兂涔板悕鍗曚腑"
@@ -951,11 +954,11 @@
         can_buy_result = CodePlateKeyBuyManager.can_buy(code)
         if can_buy_result is None:
             async_log_util.warning(logger_debug, "娌℃湁鑾峰彇鍒版澘鍧楃紦瀛橈紝灏嗚幏鍙栨澘鍧�")
-            yesterday_current_limit_up_records = kpl_data_manager.get_yesterday_current_limit_up_records()
+            latest_current_limit_up_records = kpl_data_manager.get_latest_current_limit_up_records()
             CodePlateKeyBuyManager.update_can_buy_blocks(code,
                                                          kpl_data_manager.KPLLimitUpDataRecordManager.latest_origin_datas,
                                                          kpl_data_manager.KPLLimitUpDataRecordManager.total_datas,
-                                                         yesterday_current_limit_up_records,
+                                                         latest_current_limit_up_records,
                                                          block_info.get_before_blocks_dict(),
                                                          kpl_data_manager.KPLLimitUpDataRecordManager.get_current_reason_codes_dict())
             can_buy_result = CodePlateKeyBuyManager.can_buy(code)
@@ -965,87 +968,89 @@
     def can_buy_first(cls, code, limit_up_price):
         now_timestamp = int(tool.get_now_time_str().replace(":", ""))
         # 鍒ゆ柇鏉垮潡
+        # (鍙互涔扮殑鏉垮潡鍒楄〃, 鏄惁鏄嫭鑻�, 娑堟伅绠�浠�,鍙拱鐨勫己鍔夸富绾�)
         can_buy_result = cls.__get_can_buy_block(code)
         l2_log.debug(code, "鑾峰彇鍒扮殑鏉垮潡淇℃伅锛歿}", can_buy_result)
         if can_buy_result is None:
             return False, True, "灏氭湭鑾峰彇鍒版澘鍧椾俊鎭�"
-        if not can_buy_result[0] and can_buy_result[1]:
-            zyltgb = global_util.zyltgb_map.get(code)
-            # 鐙嫍
-            if now_timestamp > int("100000"):
-                return False, True, f"鐙嫍涓嶄笅鍗曪紙{can_buy_result[4]}锛� 10鐐瑰悗涓嶄笅鍗�"
-            elif zyltgb < 10 * 100000000 or zyltgb > 20 * 100000000:
-                return False, True, f"鐙嫍涓嶄笅鍗曪紙{can_buy_result[4]}锛夎嚜鐢辨祦閫氬競鍊硷紙{zyltgb}锛変笉婊¤冻鏉′欢"
-
         # -------閲忕殑绾︽潫--------
         k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code)
+        if k_format and (k_format[1][0] or k_format[3][0]) and len(k_format) >= 12 and k_format[11]:
+            # 鐮村墠楂�/鎺ヨ繎鍓嶉珮涓�30澶╁唴鏈夋定鍋�
+            if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6:
+                return False, True, f"鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮涓�30澶╁唴鏈夋定鍋�,褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.6"
 
         # 鍓嶄竴澶╃偢鏉夸箣鍚庯紝浠婃棩10:00涔嬪墠鎵嶈兘涓嬪崟
         if k_format and len(k_format) >= 11 and k_format[10]:
             if now_timestamp > int("100000"):
-                return False, True, f"涓婁釜浜ゆ槗鏃ョ偢鏉�,褰撴棩閲�10鐐逛互鍚庝笉涓嬪崟"
+                return False, True, f"涓婁釜浜ゆ槗鏃ョ偢鏉�,褰撴棩10鐐逛互鍚庝笉涓嬪崟"
 
+        msg_list = []
         if can_buy_result[3] and now_timestamp <= int("094000"):
-            # 寮哄娍涓荤嚎涓庡己鍔�10鍒嗛挓涓嶇湅閲�
-            pass
-        else:
-            if k_format and (k_format[1][0] or k_format[3][0]):
-                # 鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮
-                if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3:
-                    return False, True, f"鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮,褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.3"
-        # 濡傛灉鏄棭涓婄殑寮哄娍鍚庢帓灏变笉闇�瑕佸垽鏂噺
-        if can_buy_result[0] and not can_buy_result[1] and now_timestamp <= int("094000"):
-            return True, False, f"9:40:00涔嬪墠闈炵嫭鑻楋細{can_buy_result[0]}"
-        else:
-            if code in cls.volume_rate_info:
-                if float(limit_up_price) < 3.0 and cls.volume_rate_info[code][0] < 0.6:
-                    return False, True, f"娑ㄥ仠浠峰皬浜�3鍧楋紝褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.6"
-
-                if HighIncreaseCodeManager().is_in(code) and cls.volume_rate_info[code][0] < 0.6:
-                    return False, True, f"鑲′环娑ㄥ緱杩囬珮锛屽綋鏃ラ噺姣�({cls.volume_rate_info[code][0]})灏忎簬0.6"
-
-                if now_timestamp <= int("100000"):
-                    if cls.volume_rate_info[code][0] < 0.1:
-                        return False, True, f"褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.1"
+            msg_list.append("寮哄娍10鍒嗛挓")
+            zyltgb = global_util.zyltgb_map.get(code)
+            # 鐙嫍
+            if not can_buy_result[0] and can_buy_result[1]:
+                msg_list.append("鐙嫍")
+                if zyltgb < 10 * 100000000 or zyltgb > 20 * 100000000:
+                    return False, True, f"寮哄娍10鍒嗛挓锛岀嫭鑻椾笉涓嬪崟锛坽can_buy_result[4]}锛夎嚜鐢辨祦閫氬競鍊硷紙{zyltgb}锛変笉婊¤冻鏉′欢"
+                if k_format and (k_format[1][0] or k_format[3][0]):
+                    msg_list.append("鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮")
+                    # 鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮
+                    if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6:
+                        return False, True, f"寮哄娍10鍒嗛挓锛岀嫭鑻楋紝鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮,褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.6"
                 else:
-                    if cls.volume_rate_info[code][0] < 0.2:
-                        return False, True, f"褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.2"
-
-                if code_nature_analyse.LatestMaxVolumeManager().is_latest_max_volume(code):
-                    # 鏈�杩戝嚑澶╂湁鏈�澶ч噺锛屽垽鏂噺姣旀槸鍚﹀ぇ浜�60%
-                    if cls.volume_rate_info[code][0] < 0.6:
-                        # HighIncreaseCodeManager().add_code(code)
-                        return False, True, f"杩戞棩鍑虹幇鏈�澶ч噺锛屽綋鏃ラ噺姣�({cls.volume_rate_info[code][0]})灏忎簬0.6"
-
-            # 鐙嫍涓嶅啀涓嬪崟
-            # if can_buy_result[1]:
-            #     # 鐙嫍
-            #     # ------鑷敱娴侀�氬競鍊肩害鏉�------
-            #     zyltgb = global_util.zyltgb_map.get(code)
-            #     if zyltgb:
-            #         if zyltgb < 10 * 100000000:
-            #             return False, True, f"鐙嫍锛岃嚜鐢辨祦閫氬皬浜�10浜匡紙{zyltgb}锛�"
-            #     if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6:
-            #         return False, True, f"鐙嫍锛氶噺姣旓紙{cls.volume_rate_info[code][0]}锛夋湭杈惧埌60%"
-            #
-            #     # 鍒ゆ柇鏄惁杩�2澶╂槸鍚︿负10澶╁唴鏈�澶ч噺
-            #     if k_format and len(k_format) >= 10 and k_format[9]:
-            #         # 鏄嫭鑻�
-            #         if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3:
-            #             return False, True, f"杩�2澶╂湁10鏃ュ唴鏈�楂橀噺锛岄噺姣旓紙{cls.volume_rate_info[code][0]}锛夋湭杈惧埌30%"
-            #     if now_timestamp < int("100000") or int("130000") <= now_timestamp < int("133000"):
-            #         # 鐙嫍蹇呴』9:30-10:00鍜�13:00-13:30鏃堕棿娈靛唴涔�
-            #         return True, False, f"鐙嫍锛歿can_buy_result[2]}"
-            #     else:
-            #         return False, True, f"鐙嫍锛氬綋鍓嶆椂闂翠笉鑳戒拱"
-            # else:
-            if can_buy_result[0]:
-                return True, False, can_buy_result[2]
-
-            if can_buy_result[1]:
-                return True, False, "涔扮嫭鑻�"
-
-        return False, True, can_buy_result[2]
+                    if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3:
+                        return False, True, f"寮哄娍10鍒嗛挓锛岀嫭鑻�,褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.3"
+            else:
+                msg_list.append("闈炵嫭鑻�")
+                if zyltgb < 10 * 100000000 or zyltgb > 20 * 100000000:
+                    msg_list.append("涓嶆弧瓒宠嚜鐢辨祦閫�")
+                    if k_format and (k_format[1][0] or k_format[3][0]):
+                        # 鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮
+                        if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6:
+                            return False, True, f"寮哄娍10鍒嗛挓锛屽悗鎺掞紝涓嶆弧瓒宠嚜鐢卞競鍊硷紝鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮,褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.6"
+                    else:
+                        if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3:
+                            return False, True, f"寮哄娍10鍒嗛挓锛屽悗鎺�,涓嶆弧瓒宠嚜鐢卞競鍊硷紝褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.3"
+                else:
+                    msg_list.append("婊¤冻鑷敱娴侀��")
+                    # 鍚庢帓锛屾弧瓒宠嚜鐢辨祦閫氬競鍊奸渶瑕佷笅鍗�
+                    return True, False, can_buy_result[2]
+            return True, False, can_buy_result[2]
+        else:
+            zyltgb = global_util.zyltgb_map.get(code)
+            # 闈炲己鍔�10鍒嗛挓鍙拱涓荤嚎
+            if not can_buy_result[0] and can_buy_result[1]:
+                return False, True, f"闈炲己鍔�10鍒嗛挓锛岀嫭鑻椾笉涓嬪崟"
+            if can_buy_result[3]:
+                # 寮哄娍涓荤嚎
+                if zyltgb < 10 * 100000000 or zyltgb > 20 * 100000000:
+                    if k_format and (k_format[1][0] or k_format[3][0]):
+                        # 鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮
+                        if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6:
+                            return False, True, f"闈炲己鍔�10鍒嗛挓锛屽己鍔夸富绾垮悗鎺掞紝涓嶆弧瓒宠嚜鐢卞競鍊硷紝鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮,褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.6"
+                    else:
+                        if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3:
+                            return False, True, f"闈炲己鍔�10鍒嗛挓锛屽己鍔夸富绾垮悗鎺�,涓嶆弧瓒宠嚜鐢卞競鍊硷紝褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.3"
+                else:
+                    if k_format and (k_format[1][0] or k_format[3][0]):
+                        if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3:
+                            return False, True, f"闈炲己鍔�10鍒嗛挓锛屽己鍔夸富绾垮悗鎺�,婊¤冻鑷敱甯傚�硷紝鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮, 褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.3"
+            else:
+                # 闈炲己鍔夸富绾�
+                if zyltgb < 10 * 100000000 or zyltgb > 20 * 100000000:
+                    if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6:
+                        return False, True, f"闈炲己鍔�10鍒嗛挓锛岄潪寮哄娍涓荤嚎鍚庢帓锛屼笉婊¤冻鑷敱甯傚��, 褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.6"
+                else:
+                    if k_format and (k_format[1][0] or k_format[3][0]):
+                        # 鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮
+                        if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6:
+                            return False, True, f"闈炲己鍔�10鍒嗛挓锛屽己鍔夸富绾垮悗鎺掞紝涓嶆弧瓒宠嚜鐢卞競鍊硷紝鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮,褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.6"
+                    else:
+                        if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3:
+                            return False, True, f"闈炲己鍔�10鍒嗛挓锛屽己鍔夸富绾垮悗鎺�,涓嶆弧瓒宠嚜鐢卞競鍊硷紝褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.3"
+            return True, False, can_buy_result[2]
 
     @classmethod
     def __cancel_buy(cls, code):

--
Gitblit v1.8.0