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 |   85 ++++++++++++++++++++----------------------
 1 files changed, 40 insertions(+), 45 deletions(-)

diff --git a/l2_data_util.py b/l2_data_util.py
index f9f3f7b..24c66ac 100644
--- a/l2_data_util.py
+++ b/l2_data_util.py
@@ -6,10 +6,12 @@
 # 姣旇緝鏃堕棿鐨勫ぇ灏�
 import json
 import time
-from tool import async_call
+
+from db.redis_manager_delegate import RedisUtils
+from utils.tool import async_call
 
 from l2 import l2_data_manager
-import tool
+from utils import tool
 
 
 def run_time():
@@ -26,23 +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, is_ge=False):
+    if is_ge:
+        return min(299 * 10000, round(limit_up_price * 2900 * 100))
+    else:
+        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
@@ -117,32 +140,6 @@
     return min_time, max_time
 
 
-# 鏍规嵁涔版挙鏁版嵁(涓庝粖鏃ユ�荤殑鏁版嵁)璁$畻涔板叆鏁版嵁
-def get_buy_data_with_cancel_data(cancel_data, local_today_num_operate_map):
-    min_space, max_space = compute_time_space_as_second(cancel_data["val"]["cancelTime"],
-                                                        cancel_data["val"]["cancelTimeUnit"])
-    max_time = __sub_time(cancel_data["val"]["time"], min_space)
-    min_time = __sub_time(cancel_data["val"]["time"], max_space)
-    buy_datas = local_today_num_operate_map.get(
-        "{}-{}-{}".format(cancel_data["val"]["num"], "0", cancel_data["val"]["price"]))
-    if buy_datas is None:
-        # 鏃犳暟鎹�
-        return None, None
-    for i in range(0, len(buy_datas)):
-        data = buy_datas[i]
-        if int(data["val"]["operateType"]) != 0:
-            continue
-        if int(data["val"]["num"]) != int(cancel_data["val"]["num"]):
-            continue
-        if min_space == 0 and max_space == 0:
-            if compare_time(data["val"]["time"], min_time) == 0:
-                return data["index"], data
-
-        elif compare_time(data["val"]["time"], min_time) > 0 and compare_time(data["val"]["time"], max_time) <= 0:
-            return data["index"], data
-    return None, None
-
-
 # 鍒ゆ柇鍗栨挙鐨勫崠淇″彿鏄惁鍦ㄧ洰鏍囦俊鍙蜂箣鍓�
 def is_sell_index_before_target(sell_cancel_data, target_data, local_today_num_operate_map):
     min_space, max_space = compute_time_space_as_second(sell_cancel_data["val"]["cancelTime"],
@@ -196,29 +193,27 @@
         if abs(get_time_as_seconds(time_str) - get_time_as_seconds(time_)) > 3:
             continue
         if same_time_nums[time_] > 20:
-            redis = l2_data_manager._redisManager.getRedis()
-            redis.setex("big_data-{}-{}".format(code, int(round(time.time() * 1000))), tool.get_expire(), d1)
+            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):
-    redis = l2_data_manager._redisManager.getRedis()
-    redis.setex("l2_latest_data_num-{}".format(code), 3, num)
+    RedisUtils.setex(l2_data_manager._redisManager.getRedis(), "l2_latest_data_num-{}".format(code), 3, num)
 
 
 # 鑾峰彇鏈�鏂版暟鎹潯鏁�
 def get_l2_latest_data_number(code):
-    redis = l2_data_manager._redisManager.getRedis()
-    num = redis.get("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