admin
2 天以前 055a6e8fc94c2bb7b124059f1b58a327e5330690
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,13 +294,17 @@
        return min(price1, price2)
# 获取买入价格笼子的最高价
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 +361,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 +445,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))