From 48fb7a00951f91bdc707e5dd2d196e5bccb752c3 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期三, 18 六月 2025 18:41:30 +0800
Subject: [PATCH] 异常保护

---
 l2_data_util.py |   47 +++++++++++++++++++++++++++++++----------------
 1 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/l2_data_util.py b/l2_data_util.py
index af18fa3..24c66ac 100644
--- a/l2_data_util.py
+++ b/l2_data_util.py
@@ -28,30 +28,44 @@
 
 
 # 鏄惁涓哄ぇ鍗�
-def is_big_money(val):
+def is_big_money(val, is_ge=False):
+    """
+    鍒ゆ柇鏄惁涓哄ぇ鍗�
+    @param val: l2鏁版嵁
+    @param is_ge: 鏄惁涓哄垱涓氭澘
+    @return:
+    """
     price = float(val["price"])
-    money = price * val["num"]
-    if price > 3.0:
-        if money >= 30000:
+    money = round(price * val["num"], 2)
+    if is_ge:
+        if money >= 29900 or val["num"] >= 2999:
             return True
         else:
             return False
     else:
-        max_money = price * 10000
-        if money >= max_money * 0.95:
-            return True
+        if price > 3.0:
+            if money >= 29900 or val["num"] >= 7999:
+                return True
+            else:
+                return False
         else:
-            return False
+            max_money = price * 10000
+            if money >= max_money * 0.95:
+                return True
+            else:
+                return False
 
 
 # 鑾峰彇澶ц祫閲戠殑閲戦
-def get_big_money_val(limit_up_price):
-    if limit_up_price > 3.0:
-        return 300 * 10000
+def get_big_money_val(limit_up_price, is_ge=False):
+    if is_ge:
+        return min(299 * 10000, round(limit_up_price * 2900 * 100))
     else:
-        max_money = limit_up_price * 10000
-        return max_money * 0.95
-
+        if limit_up_price > 3.0:
+            return min(299 * 10000, round(limit_up_price * 7999 * 100))
+        else:
+            max_money = limit_up_price * 10000 * 100
+            return int(max_money * 0.95)
 
 # if int(val["num"]) >= constant.BIG_MONEY_NUM:
 #     return True
@@ -179,7 +193,8 @@
         if abs(get_time_as_seconds(time_str) - get_time_as_seconds(time_)) > 3:
             continue
         if same_time_nums[time_] > 20:
-            RedisUtils.setex(l2_data_manager._redisManager.getRedis(), "big_data-{}-{}".format(code, int(round(time.time() * 1000))), tool.get_expire(),
+            RedisUtils.setex(l2_data_manager._redisManager.getRedis(),
+                             "big_data-{}-{}".format(code, int(round(time.time() * 1000))), tool.get_expire(),
                              d1)
             break
 
@@ -192,7 +207,7 @@
 
 # 鑾峰彇鏈�鏂版暟鎹潯鏁�
 def get_l2_latest_data_number(code):
-    num =RedisUtils.get(l2_data_manager._redisManager.getRedis(), "l2_latest_data_num-{}".format(code))
+    num = RedisUtils.get(l2_data_manager._redisManager.getRedis(), "l2_latest_data_num-{}".format(code))
     if num is not None:
         return int(num)
     return None

--
Gitblit v1.8.0