From 36731498e1b7c65a69cd15d626fedca4c92c1042 Mon Sep 17 00:00:00 2001 From: admin <admin@example.com> Date: 星期四, 20 二月 2025 17:39:54 +0800 Subject: [PATCH] 增加撤单 --- utils/tool.py | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/utils/tool.py b/utils/tool.py index 5ee4947..9336ce5 100644 --- a/utils/tool.py +++ b/utils/tool.py @@ -281,7 +281,8 @@ # 鑾峰彇涔板叆浠锋牸绗煎瓙鐨勬渶浣庝环 def get_buy_min_price(price, is_cb=False): - price1 = price * (1 - 0.02) + # price1 = price * (1 - 0.015) # 鏈嶅姟鍣ㄧ増 + price1 = price * (1 - 0.005) # 鏈湴鐗� if is_cb: price1 = math.ceil(price1 * 1000) / 1000 else: @@ -293,8 +294,10 @@ return min(price1, price2) +# 鑾峰彇涔板叆浠锋牸绗煎瓙鐨勬渶楂樹环 def get_buy_max_price(price, is_cb=False): - price1 = price * (1 + 0.02) + # price1 = price * (1 + 0.015) # 鏈嶅姟鍣ㄧ増 + price1 = price * (1 + 0.005) # 鏈湴鐗� if is_cb: price1 = math.ceil(price1 * 1000) / 1000 else: @@ -356,6 +359,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(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(): @@ -435,5 +450,7 @@ 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