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 |   52 +++++++++++++++++++++++++++++++++-------------------
 1 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/l2_data_util.py b/l2_data_util.py
index 4e0e7f6..24c66ac 100644
--- a/l2_data_util.py
+++ b/l2_data_util.py
@@ -7,7 +7,7 @@
 import json
 import time
 
-from db.redis_manager import RedisUtils
+from db.redis_manager_delegate import RedisUtils
 from utils.tool import async_call
 
 from l2 import l2_data_manager
@@ -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,13 +193,13 @@
         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
 
 
 # 淇濆瓨l2鏈�鏂版暟鎹殑澶у皬
-# TODO 娴嬭瘯鏁版嵁
 # @async_call
 def save_l2_latest_data_number(code, num):
     RedisUtils.setex(l2_data_manager._redisManager.getRedis(), "l2_latest_data_num-{}".format(code), 3, num)
@@ -193,13 +207,13 @@
 
 # 鑾峰彇鏈�鏂版暟鎹潯鏁�
 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
 
 
-# l2鏁版嵁鎷兼帴宸ュ叿 TODO 鏆傛椂杩樻湭鍚敤
+# l2鏁版嵁鎷兼帴宸ュ叿  鏆傛椂杩樻湭鍚敤
 class L2DataConcatUtil:
 
     # 鍒濆鍖�

--
Gitblit v1.8.0