From 89f860904270b6cdc20b5e7e90a7c12b5b2bf8e3 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期五, 25 四月 2025 09:53:15 +0800
Subject: [PATCH] bug修复

---
 code_attribute/code_nature_analyse.py |   42 ++++++++++++++++++++++++++++++++----------
 1 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/code_attribute/code_nature_analyse.py b/code_attribute/code_nature_analyse.py
index 0984759..bedeea1 100644
--- a/code_attribute/code_nature_analyse.py
+++ b/code_attribute/code_nature_analyse.py
@@ -9,7 +9,7 @@
 from code_attribute import gpcode_manager
 
 # 浠g爜鑲℃�ц褰曠鐞�
-from db import redis_manager
+from db import redis_manager_delegate as redis_manager
 from utils import tool
 from db.redis_manager_delegate import RedisUtils
 from utils.tool import CodeDataCacheUtil
@@ -220,8 +220,8 @@
     p11 = __is_latest_open_limit_up(code, record_datas, 5)
     # 90澶╁唴鏄惁鏈夋定鍋�
     p12 = __has_limit_up(code, record_datas, 90)
-    # 鏈�杩�5澶╂槸鍚﹁穼鍋�
-    p13 = __is_latest_limit_down(code, record_datas, 5)
+    # 涓婁釜浜ゆ槗鏃ユ槸鍚﹁穼骞呰繃澶�
+    p13 = __is_pre_day_limit_rate_too_low(code, record_datas)
     # 60涓氦鏄撴棩鏄惁鏇炬定鍋�
     p14 = __has_limited_up(code, record_datas, 60)
     # 鏄ㄦ棩鏄惁娑ㄥ仠杩�
@@ -404,7 +404,8 @@
     # if max_price > float(limit_up_price):
     #     return False
     rate = (float(limit_up_price) - min_price_info[1]["close"]) / min_price_info[1]["close"]
-    if rate >= 0.319:
+    THRESHOLD_RATE = 0.319 * 2 if tool.is_ge_code(code) else 0.319
+    if rate >= THRESHOLD_RATE:
         return True, rate
     return False, rate
 
@@ -471,7 +472,7 @@
 def __is_new_top(code, limit_up_price, datas):
     datas = copy.deepcopy(datas)
     datas.sort(key=lambda x: x["bob"])
-    datas = datas[-80:]
+    datas = datas[-60:]
     max_price = 0
     for data in datas:
         if max_price < data["high"]:
@@ -559,8 +560,9 @@
     items = datas[0 - day_count:]
     for item in items:
         limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(code, item["pre_close"]))
-        if abs(limit_up_price - item["high"]) < 0.001 and abs(limit_up_price - item["close"]) > 0.001:
-            # 鐐告澘
+        limit_down_price = float(gpcode_manager.get_limit_down_price_by_preprice(code, item["pre_close"]))
+        if abs(limit_up_price - item["high"]) < 0.001 or abs(limit_down_price - item["close"]) < 0.001:
+            # 鐐告澘 # 鎴栨定鍋� # 鎴栬�呰穼鍋�
             return True
     return False
 
@@ -574,6 +576,26 @@
         limit_down_price = float(gpcode_manager.get_limit_down_price_by_preprice(code, item["pre_close"]))
         if abs(limit_down_price - item["close"]) < 0.001:
             # 璺屽仠
+            return True
+    return False
+
+
+def __is_pre_day_limit_rate_too_low(code, datas):
+    """
+    涓婁釜浜ゆ槗鏃ユ槸鍚﹁穼骞呰繃澶�
+    @param code:
+    @param datas:
+    @return:
+    """
+    datas = copy.deepcopy(datas)
+    datas.sort(key=lambda x: x["bob"])
+    items = datas[-1:]
+    for item in items:
+        # 鏄惁鏈夎穼鍋�
+        # 鑾峰彇褰撴棩娑ㄥ箙
+        rate = (item["close"] - item["pre_close"]) / item["pre_close"]
+        threshold_rate_ = round(0 - ((1 - tool.get_limit_down_rate(code)) * 0.9), 2)
+        if rate < threshold_rate_:
             return True
     return False
 
@@ -738,6 +760,6 @@
 
 
 if __name__ == "__main__":
-    HighIncreaseCodeManager().add_code("000333")
-    print(HighIncreaseCodeManager().is_in("000333"))
-    print(HighIncreaseCodeManager().is_in("000222"))
+    code = "000333"
+    threshold_rate = 0 - ((1 - tool.get_limit_down_rate(code)) * 0.9)
+    print(threshold_rate)

--
Gitblit v1.8.0