From 751183dcd74207a50834cacc575f0dfccb41658c Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期二, 06 六月 2023 18:13:05 +0800
Subject: [PATCH] 交易优化,看盘接口完善

---
 l2/l2_data_manager_new.py |   99 +++++++++++++++++++++++--------------------------
 1 files changed, 47 insertions(+), 52 deletions(-)

diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py
index caf67cd..c6c0e15 100644
--- a/l2/l2_data_manager_new.py
+++ b/l2/l2_data_manager_new.py
@@ -678,19 +678,31 @@
         if zyltgb is None:
             global_data_loader.load_zyltgb()
             zyltgb = global_util.zyltgb_map.get(code)
-        buy1_price = code_price_manager.Buy1PriceManager.get_buy1_price(code)
-        if buy1_price is None:
-            return False, True, f"灏氭湭鑾峰彇鍒颁拱1浠�"
+        # buy1_price = code_price_manager.Buy1PriceManager.get_buy1_price(code)
+        # if buy1_price is None:
+        #     return False, True, f"灏氭湭鑾峰彇鍒颁拱1浠�"
         limit_up_price = gpcode_manager.get_limit_up_price(code)
 
-        dif = float(limit_up_price) - float(buy1_price)
-        if zyltgb >= 80 * 100000000:
-            # 澶т簬2妗�
-            if dif > 0.02001:
-                return False, True, f"涔�1鍓╀綑妗f暟澶т簬2妗o紝涔颁竴锛坽buy1_price}锛夋定鍋滐紙{limit_up_price}锛�"
-        else:
-            if dif > 0.03001:
-                return False, True, f"涔�1鍓╀綑妗f暟澶т簬3妗o紝涔颁竴锛坽buy1_price}锛夋定鍋滐紙{limit_up_price}锛�"
+        # dif = float(limit_up_price) - float(buy1_price)
+        # if zyltgb >= 100 * 100000000:
+        #     # 澶т簬2妗�
+        #     if dif > 0.01001:
+        #         return False, True, f"涔�1鍓╀綑妗f暟澶т簬1妗o紝涔颁竴锛坽buy1_price}锛夋定鍋滐紙{limit_up_price}锛�"
+        # elif zyltgb >= 80 * 100000000:
+        #     # 澶т簬2妗�
+        #     if dif > 0.02001:
+        #         return False, True, f"涔�1鍓╀綑妗f暟澶т簬2妗o紝涔颁竴锛坽buy1_price}锛夋定鍋滐紙{limit_up_price}锛�"
+        # elif zyltgb >= 60 * 100000000:
+        #     # 澶т簬2妗�
+        #     if dif > 0.03001:
+        #         return False, True, f"涔�1鍓╀綑妗f暟澶т簬3妗o紝涔颁竴锛坽buy1_price}锛夋定鍋滐紙{limit_up_price}锛�"
+        # elif zyltgb >= 40 * 100000000:
+        #     # 澶т簬2妗�
+        #     if dif > 0.04001:
+        #         return False, True, f"涔�1鍓╀綑妗f暟澶т簬4妗o紝涔颁竴锛坽buy1_price}锛夋定鍋滐紙{limit_up_price}锛�"
+        # else:
+        #     if dif > 0.05001:
+        #         return False, True, f"涔�1鍓╀綑妗f暟澶т簬5妗o紝涔颁竴锛坽buy1_price}锛夋定鍋滐紙{limit_up_price}锛�"
 
         limit_up_info = code_price_manager.Buy1PriceManager.get_limit_up_info(code)
         if limit_up_info[0] is None and False:
@@ -721,50 +733,33 @@
                                       cls.__l2PlaceOrderParamsManagerDict[code].score_info)
 
         if not gpcode_manager.WantBuyCodesManager.is_in(code):
-
-            if float(limit_up_price) >= 40:
-                return False, True, "鑲′环澶т簬40鍧�"
-
-            # 鍒ゆ柇鏉垮潡
-            plate_can_buy, msg = CodePlateKeyBuyManager.can_buy(code)
-            if not plate_can_buy:
-                return False, True, msg
-
-            # 鏌ョ湅鍒嗘暟绛夌骇
             score_index = cls.__l2PlaceOrderParamsManagerDict[code].score_index
             score = cls.__l2PlaceOrderParamsManagerDict[code].score
             score_info = cls.__l2PlaceOrderParamsManagerDict[code].score_info
-
-            # 鍖哄垎澶хエ锛屽皬绁�
-            if zyltgb >= 80 * 100000000:
-                if cls.volume_rate_info[code][0] < 0.5:
-                    return False, True, f"澶у競鍊�:閲忓ぇ浜�50%鎵嶄笅鍗�,閲忔瘮锛歿cls.volume_rate_info[code][0]}"
-            elif zyltgb <= 35 * 100000000:
-                # 鑾峰彇鏉垮潡涓殑绁ㄧ殑鏁伴噺
-                if score_info[1][5]["limit_up_codes_count"] < 2:
-                    return False, True, f"灏忓競鍊�:鏉垮潡涓繀椤�2涓定鍋滄墠鑳戒拱锛屾澘鍧梴score_info[1][5]['target_block_info'][0]}-娑ㄥ仠鏁皗score_info[1][5]['limit_up_codes_count']}"
-
-            # 灏剧洏鍋疯窇绁�
-            limit_up_time = score_info[1][7]
-            if limit_up_time is None:
-                limit_up_time = tool.get_now_time_str()
-
-            # 灏剧洏鍋疯窇鏆傛椂涓嶈
-            # if int(limit_up_time.replace(":", "")) > int("143000"):
-            #     if not score_info[1][3][6][0]:
-            #         return False, True, f"灏剧洏鍋疯窇:鏃犱换浣曞舰鎬�"
-            #     if score_info[1][5]["limit_up_codes_count"] > 1:
-            #         return False, True, f"灏剧洏鍋疯窇:鏉垮潡{score_info[1][5]['target_block_info'][0]}-娑ㄥ仠鏁皗score_info[1][5]['limit_up_codes_count']}"
-            #     if float(gpcode_manager.get_limit_up_price(code)) > 30:
-            #         return False, True, f"灏剧洏鍋疯窇:鑲′环澶т簬30"
-
-            if score_index < 0:
-                return False, True, f"鍒嗗�硷細{score}鏈揪鍒伴渶瑕佷拱鍏ョ殑鍒嗘暟绾�"
-            # if score_index >= 3:
-            #     return False, True, f"鍒嗗�硷細{score}鏈揪鍒颁富鍔ㄤ拱鍏ュ垎鏁扮嚎"
-            return True, False, ""
+            return cls.can_buy_first(code, limit_up_price, score_index, score, score_info, cls.volume_rate_info[code])
         else:
             return True, False, "鍦ㄦ兂涔板悕鍗曚腑"
+
+    @classmethod
+    def can_buy_first(cls, code, limit_up_price, score_index, score, score_info, volume_rate_info):
+        if float(limit_up_price) >= 40:
+            return False, True, "鑲′环澶т簬40鍧�"
+        # 鍒ゆ柇鏉垮潡
+        plate_can_buy, msg = CodePlateKeyBuyManager.can_buy(code)
+        if not plate_can_buy:
+            return False, True, msg
+
+        if volume_rate_info[0] < 0.4:
+            return False, True, f"閲忓ぇ浜�40%鎵嶄笅鍗�,閲忔瘮锛歿volume_rate_info[0]}"
+
+        # 鏄惁鏈塊绾垮舰鎬�(鏈塊绾垮舰鎬佹垨鑰呭ぉ閲忓ぇ闃�)
+        has_k_format = score_info[1][3][6][0] or score_info[1][3][7][0]
+        if not has_k_format:
+            return False, True, f"鏃燢绾垮舰鎬�"
+
+        if score_index < 0:
+            return False, True, f"鍒嗗�硷細{score}鏈揪鍒伴渶瑕佷拱鍏ョ殑鍒嗘暟绾�"
+        return True, False, ""
 
     @classmethod
     def __cancel_buy(cls, code):
@@ -1092,8 +1087,8 @@
             data = total_datas[i]
             _val = total_datas[i]["val"]
             trigger_buy = False
-            # 蹇呴』涓鸿繛缁�3绉掑唴鐨勬暟鎹�
-            if L2DataUtil.get_time_as_second(_val["time"]) - buy_single_time_seconds > max_space_time:
+            # 蹇呴』涓鸿繛缁�2绉掑唴鐨勬暟鎹�
+            if L2DataUtil.get_time_as_second(_val["time"]) - buy_single_time_seconds + 1 > max_space_time:
                 TradePointManager.delete_buy_point(code)
                 if i == compute_end_index:
                     # 鏁版嵁澶勭悊瀹屾瘯

--
Gitblit v1.8.0