From 4520b64baf84997d9d1116957417089d0bfdc1d1 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期四, 15 八月 2024 14:58:55 +0800
Subject: [PATCH] 可转债买卖接口

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

diff --git a/utils/tool.py b/utils/tool.py
index 89ac66f..91baaa1 100644
--- a/utils/tool.py
+++ b/utils/tool.py
@@ -264,10 +264,23 @@
 
 
 # 鑾峰彇涔板叆浠锋牸绗煎瓙鐨勬渶浣庝环
-def get_buy_min_price(price):
+def get_buy_min_price(price, is_cb=False):
     price1 = price * (1 - 0.02)
-    price1 = math.ceil(price1 * 100) / 100
+    if is_cb:
+        price1 = math.ceil(price1 * 1000) / 1000
+    else:
+        price1 = math.ceil(price1 * 100) / 100
     price2 = price - 0.1
+    return max(price1, price2)
+
+
+def get_buy_max_price(price, is_cb=False):
+    price1 = price * (1 + 0.02)
+    if is_cb:
+        price1 = math.ceil(price1 * 1000) / 1000
+    else:
+        price1 = math.ceil(price1 * 100) / 100
+    price2 = price + 0.1
     return max(price1, price2)
 
 
@@ -282,7 +295,7 @@
 
 if __name__ == "__main__":
     printlog(trade_time_sub("13:00:01",
-                         "11:29:55"))
+                            "11:29:55"))
 
 
 class CodeDataCacheUtil:
@@ -324,6 +337,7 @@
         return 0.9
     else:
         return 0.8
+
 
 def get_thread_id():
     try:
@@ -377,5 +391,14 @@
     return get_market_type(code) == MARKET_TYPE_SZSE
 
 
+def is_cb_code(code):
+    """
+    鏄惁鏄彲杞��
+    @param code:
+    @return:
+    """
+    return code.find("11")==0 or code.find("12")==0
+
+
 if __name__ == "__main__":
-    pass
+    print(get_buy_max_price(100.123, is_cb=True))

--
Gitblit v1.8.0