From c3ccb1f01a94d944760559be4d81bc5363ee8825 Mon Sep 17 00:00:00 2001
From: admin <admin@example.com>
Date: 星期一, 15 九月 2025 18:15:38 +0800
Subject: [PATCH] bug修复

---
 utils/tool.py |   43 +++++++++++++++++++++++++++++++------------
 1 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/utils/tool.py b/utils/tool.py
index ab56534..ac37d98 100644
--- a/utils/tool.py
+++ b/utils/tool.py
@@ -280,26 +280,24 @@
 
 
 # 鑾峰彇涔板叆浠锋牸绗煎瓙鐨勬渶浣庝环
-def get_buy_min_price(price, is_cb=False):
+def get_buy_min_price(price):
     price1 = price * (1 - 0.02)
-    if is_cb:
-        price1 = math.ceil(price1 * 1000) / 1000
-    else:
-        price1 = math.ceil(price1 * 100) / 100
+    price1 = math.ceil(price1 * 100) / 100
     price2 = price - 0.1
-    if not is_cb:
-        return round(min(price1, price2) + 0.05, 2)
-    else:
-        return min(price1, price2)
+    return round(min(price1, price2), 2)
 
 
+# 鑾峰彇涔板叆浠锋牸绗煎瓙鐨勬渶楂樹环
 def get_buy_max_price(price, is_cb=False):
-    price1 = price * (1 + 0.02)
+    if not constant.IS_SIMULATED_TRADE:
+        price1 = price * (1 + 0.015)  # 鏈嶅姟鍣ㄧ増
+    else:
+        price1 = price * (1 + 0.005)  # 鏈湴鐗�
     if is_cb:
         price1 = math.ceil(price1 * 1000) / 1000
     else:
         price1 = math.ceil(price1 * 100) / 100
-    price2 = price + 0.1
+    price2 = price + 0.05
     return max(price1, price2)
 
 
@@ -356,6 +354,18 @@
         return 0.9
     else:
         return 0.8
+
+
+def get_limit_up_price(code, pre_price):
+    price = (decimal.Decimal(pre_price) * decimal.Decimal(get_limit_up_rate(code))).quantize(decimal.Decimal("0.00"),
+                                                                                             decimal.ROUND_HALF_UP)
+    return round(float(price), 2)
+
+
+def get_limit_down_price(code, pre_price):
+    price = (decimal.Decimal(pre_price) * decimal.Decimal(get_limit_down_rate(code))).quantize(decimal.Decimal("0.00"),
+                                                                                               decimal.ROUND_HALF_UP)
+    return round(price, 2)
 
 
 def get_thread_id():
@@ -428,5 +438,14 @@
     return code.find("00") == 0 or code.find("30") == 0 or code.find("60") == 0 or code.find("68") == 0
 
 
+def get_symbol(code):
+    if is_sh_code(code):
+        return f"SHSE.{code}"
+    elif is_sz_code(code):
+        return f"SZSE.{code}"
+    return code
+
+
 if __name__ == "__main__":
-    print(get_buy_max_price(100.123, is_cb=True))
+    # print(get_buy_max_price(100.123, is_cb=True))
+    print(get_limit_up_price("000333", 56.23))

--
Gitblit v1.8.0