From 9d2b0ab3967761b2d4b4e1c92034c3c0ea6705f5 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 16 一月 2025 16:29:56 +0800
Subject: [PATCH] 添加低吸中间服务器

---
 utils/tool.py |   48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/utils/tool.py b/utils/tool.py
index 0b39e4f..b494ad0 100644
--- a/utils/tool.py
+++ b/utils/tool.py
@@ -3,6 +3,7 @@
 """
 import ctypes
 import decimal
+import math
 import random
 import threading
 import time
@@ -180,7 +181,8 @@
 def time_sub_as_ms(time_str_1, time_str_2):
     time_1 = get_time_as_second(time_str_1[:8])
     time_2 = get_time_as_second(time_str_2[:8])
-    return (time_1 - time_2) * 1000 + (int(time_str_1[9:]) - int(time_str_2[9:])) if len(time_str_1)>8 and len(time_str_2)>8 else 0
+    return (time_1 - time_2) * 1000 + (int(time_str_1[9:]) - int(time_str_2[9:])) if len(time_str_1) > 8 and len(
+        time_str_2) > 8 else 0
 
 
 # 浜ゆ槗鏃堕棿鍔犲嚑s
@@ -192,6 +194,14 @@
     if s >= 11 * 3600 + 30 * 60 > s_:
         s += 90 * 60
     return time_seconds_format(s)
+
+
+def is_sh_code(code):
+    return code.find('60') == 0 or code.find('11') == 0 or code.find('68') == 0
+
+
+def is_sz_code(code):
+    return code.find('00') == 0 or code.find('12') == 0 or code.find('30') == 0
 
 
 def compute_buy1_real_time(time_):
@@ -254,3 +264,39 @@
     except:
         pass
     return None
+
+
+def get_limit_up_rate(code):
+    # 鑾峰彇娑ㄥ仠鍊嶆暟
+    if code.find("00") == 0 or code.find("60") == 0:
+        return 1.1
+    else:
+        return 1.2
+
+
+def get_limit_down_rate(code):
+    # 鑾峰彇娑ㄥ仠鍊嶆暟
+    if code.find("00") == 0 or code.find("60") == 0:
+        return 0.9
+    else:
+        return 0.8
+
+
+def get_limit_up_price_by_preprice(code, price):
+    if price is None:
+        return None
+    return to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{get_limit_up_rate(code)}"))
+
+
+def get_limit_down_price_by_preprice(code, price):
+    if price is None:
+        return None
+    return to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{get_limit_down_rate(code)}"))
+
+
+# 鑾峰彇涔板叆浠锋牸绗煎瓙鐨勬渶楂樹环
+def get_buy_max_price(price):
+    price1 = price * (1 + 0.02)
+    price1 = math.ceil(price1 * 100) / 100
+    price2 = price + 0.1
+    return min(price1, price2)

--
Gitblit v1.8.0