Loading ...

自动获取币安永续合约交易精度&最小开仓u(施工中)

Author: GCC, Date: 2021-10-10 22:42:12
Tags:


def init():
    global symbols, min_value
    # 获取交易规则
    rule = exchange.IO("api", "GET", "/fapi/v1/exchangeInfo", "", "")["symbols"]
    Log(rule)
    exit()
    # 获取交易对名称
    for i in range(len(exchanges)):
        exchanges[i].SetMarginLevel(M)
        exchanges[i].SetContractType("swap")  # 设置永续合约
        _symbol = exchanges[i].GetCurrency().split("_")[0]   # +'USDT'币本位交易对名称
        # 设置交易精度
        j = 0
        flag1 = False
        flag2 = False
        #Log(rule)
        while (j < len(rule)) and flag1 == False and flag2 == False:
            if str(rule[j]["symbol"]).rfind(_symbol)>=0:
                for x in rule[j]["filters"]:
                    if x["filterType"] == "PRICE_FILTER" and flag1 == False:
                        #Log("价格",x["tickSize"])
                        #Log(len(str(float(x["tickSize"])).split('.')[-1]))
                        price_precision = len(str(float(x["tickSize"])).split('.')[-1])
                        flag1 = True
                    elif x["filterType"] == "LOT_SIZE" and flag2 == False:
                        amount_precision = len(x["minQty"].split('.')[-1])
                        flag2 = True
            j = j + 1
        exchanges[i].SetPrecision(price_precision, amount_precision)
    Log("初始化结束")

More