From 52c4cb753226d69e9ca04ff73ffa6e8ba79dd917 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期三, 06 十二月 2023 16:36:35 +0800
Subject: [PATCH] 强势时间段调整

---
 l2/l2_data_manager_new.py |  178 +++++++++++++++++++++++++----------------------------------
 1 files changed, 76 insertions(+), 102 deletions(-)

diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py
index d81834a..0763aa4 100644
--- a/l2/l2_data_manager_new.py
+++ b/l2/l2_data_manager_new.py
@@ -228,8 +228,8 @@
     __AccountAvailableMoneyManager = AccountAvailableMoneyManager()
     __TradeBuyDataManager = trade_data_manager.TradeBuyDataManager()
     __LimitUpTimeManager = limit_up_time_manager.LimitUpTimeManager()
-    __BlackListCodeManager = l2_trade_util.BlackListCodeManager()
-    __WhiteListCodeManager = l2_trade_util.WhiteListCodeManager()
+    __BlackListCodeManager = gpcode_manager.BlackListCodeManager()
+    __WhiteListCodeManager = gpcode_manager.WhiteListCodeManager()
     __WantBuyCodesManager = gpcode_manager.WantBuyCodesManager()
     __TradeTargetCodeModeManager = TradeTargetCodeModeManager()
     __TradeOrderIdManager = trade_huaxin.TradeOrderIdManager()
@@ -844,39 +844,15 @@
             HighIncreaseCodeManager().add_code(code)
             return False, True, f"鑲′环澶т簬{constant.MAX_CODE_PRICE}鍧�"
 
-        place_order_count = cls.__PlaceOrderCountManager.get_place_order_count(code)
-        if place_order_count and place_order_count >= 10:
-            l2_trade_util.forbidden_trade(code, msg="褰撴棩涓嬪崟娆℃暟宸茶揪10娆�")
-            return False, True, f"褰撴棩涓嬪崟娆℃暟宸茶揪10娆�"
+        # place_order_count = cls.__PlaceOrderCountManager.get_place_order_count(code)
+        # if place_order_count and place_order_count >= 10:
+        #     l2_trade_util.forbidden_trade(code, msg="褰撴棩涓嬪崟娆℃暟宸茶揪10娆�")
+        #     return False, True, f"褰撴棩涓嬪崟娆℃暟宸茶揪10娆�"
 
         # ---------鍧囦环绾︽潫-------------
         average_rate = cls.__Buy1PriceManager.get_average_rate(code)
         if average_rate and average_rate <= 0.01:
             return False, True, f"鍧囦环娑ㄥ箙({average_rate})灏忎簬1%"
-
-        # -------閲忕殑绾︽潫--------
-        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 int(tool.get_now_time_str().replace(":", "")) <= int("100000"):
-            if cls.volume_rate_info[code][0] < 0.1:
-                return False, True, f"褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.1"
-        else:
-            if cls.volume_rate_info[code][0] < 0.2:
-                return False, True, f"褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.2"
-        k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code)
-        if k_format and (k_format[1][0] or k_format[3][0]):
-            # 鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮
-            if cls.volume_rate_info[code][0] < 0.3:
-                return False, True, f"鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮,褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.3"
-        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"
 
         total_data = local_today_datas.get(code)
         if constant.L2_SOURCE_TYPE == constant.L2_SOURCE_TYPE_HUAXIN:
@@ -960,56 +936,17 @@
                         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"鍙拱鎯充拱鍗曚腑鐨勪唬鐮�"
+        return cls.can_buy_first(code, limit_up_price)
+        # else:
+        #     return True, False, "鍦ㄦ兂涔板悕鍗曚腑"
 
-        # limit_up_info = cls.__Buy1PriceManager.get_limit_up_info(code)
-        # if limit_up_info[0] is None and False:
-        #     total_data = local_today_datas.get(code)
-        #     buy_single_index, buy_exec_index, buy_compute_index, num, count, max_num_set, buy_volume_rate = cls.__get_order_begin_pos(
-        #         code)
-        #     # 涔嬪墠娌℃湁娑ㄥ仠杩�
-        #     # 缁熻涔板叆淇″彿浣嶅埌褰撳墠浣嶇疆娌℃湁鎾ょ殑澶у崟閲戦
-        #     min_money_w = l2_data_util.get_big_money_val(float(total_data[buy_single_index]["val"]["price"])) // 10000
-        #     left_big_num = cls.__SecondCancelBigNumComputer.compute_left_big_num(code,
-        #                                                                          buy_single_index,
-        #                                                                          buy_exec_index,
-        #                                                                          total_data[-1][
-        #                                                                              "index"],
-        #                                                                          total_data,
-        #                                                                          0, min_money_w)
-        #     if left_big_num > 0:
-        #         # 閲嶆柊鑾峰彇鍒嗘暟涓庡垎鏁扮储寮�
-        #         limit_up_time = cls.__LimitUpTimeManager.get_limit_up_time_cache(code)
-        #         if limit_up_time is None:
-        #             limit_up_time = tool.get_now_time_str()
-
-        # logger_place_order_score.info("code={},data='score_index':{},'score_info':{}", code,
-        #                               cls.__l2PlaceOrderParamsManagerDict[code].score_index,
-        #                               cls.__l2PlaceOrderParamsManagerDict[code].score_info)
-
-        if not cls.__WantBuyCodesManager.is_in_cache(code):
-            if cls.__TradeTargetCodeModeManager.get_mode_cache() == TradeTargetCodeModeManager.MODE_ONLY_BUY_WANT_CODES:
-                return False, True, f"鍙拱鎯充拱鍗曚腑鐨勪唬鐮�"
-            score_index = None  # cls.__l2PlaceOrderParamsManagerDict[code].score_index
-            score = None  # cls.__l2PlaceOrderParamsManagerDict[code].score
-            score_info = None  # cls.__l2PlaceOrderParamsManagerDict[code].score_info
-
-            # lp = LineProfiler()
-            # lp.enable()
-            # lp_wrap = lp(cls.can_buy_first)
-            # results = lp_wrap(code, limit_up_price, score_index, score, score_info, cls.volume_rate_info[code])
-            # output = io.StringIO()
-            # lp.print_stats(stream=output)
-            # lp.disable()
-            # with open(f"{constant.get_path_prefix()}/logs/profile/{code}_can_buy_first.txt", 'w') as f:
-            #     f.write(output.getvalue())
-            # return results
-            return cls.can_buy_first(code, limit_up_price)
-        else:
-            return True, False, "鍦ㄦ兂涔板悕鍗曚腑"
-
+    # 鑾峰彇鍙互涔扮殑鏉垮潡
     @classmethod
-    def can_buy_first(cls, code, limit_up_price):
-        # 鍒ゆ柇鏉垮潡
+    def __get_can_buy_block(cls, code):
         can_buy_result = CodePlateKeyBuyManager.can_buy(code)
         if can_buy_result is None:
             async_log_util.warning(logger_debug, "娌℃湁鑾峰彇鍒版澘鍧楃紦瀛橈紝灏嗚幏鍙栨澘鍧�")
@@ -1021,36 +958,73 @@
                                                          block_info.get_before_blocks_dict(),
                                                          kpl_data_manager.KPLLimitUpDataRecordManager.get_current_reason_codes_dict())
             can_buy_result = CodePlateKeyBuyManager.can_buy(code)
+        return can_buy_result
 
+    @classmethod
+    def can_buy_first(cls, code, limit_up_price):
+        # 鍒ゆ柇鏉垮潡
+        can_buy_result = cls.__get_can_buy_block(code)
         if can_buy_result is None:
             return False, True, "灏氭湭鑾峰彇鍒版澘鍧椾俊鎭�"
 
-        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%"
-
-        # 鑾峰彇K绾垮舰鎬侊紝鍒ゆ柇鏄惁杩�2澶╂槸鍚︿负10澶╁唴鏈�澶ч噺
+        # -------閲忕殑绾︽潫--------
         k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code)
-        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 can_buy_result[1]:
-            now_time_int = int(tool.get_now_time_str().replace(":", ""))
-            if now_time_int < int("100000") or int("130000") <= now_time_int < int("133000"):
-                # 鐙嫍蹇呴』9:30-10:00鍜�13:00-13:30鏃堕棿娈靛唴涔�
-                return True, False, f"鐙嫍锛歿can_buy_result[2]}"
-            else:
-                return False, True, f"鐙嫍锛氬綋鍓嶆椂闂翠笉鑳戒拱"
+        if k_format and (k_format[1][0] or k_format[3][0]):
+            # 鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮
+            if cls.volume_rate_info[code][0] < 0.3:
+                return False, True, f"鑲′环鍒涙柊楂樻垨鑰呴�艰繎鍓嶉珮,褰撴棩閲忔瘮({cls.volume_rate_info[code][0]})灏忎簬0.3"
+
+        # 濡傛灉鏄棭涓婄殑寮哄娍鍚庢帓灏变笉闇�瑕佸垽鏂噺
+        now_timestamp = int(tool.get_now_time_str().replace(":", ""))
+        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 can_buy_result[0]:
-                return True, False, can_buy_result[2]
+            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"
+                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 can_buy_result[1]:
+                    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]
         return False, True, can_buy_result[2]
 
     @classmethod

--
Gitblit v1.8.0