当我试图创建秩序时,我遇到了错误:
binance.exceptions.BinanceAPIException: APIError(code=-1111): Precision is over the maximum defined for this asset.我的代码:
pos = "SELL"
q = tbal / price
q = round(q, 2)
client.futures_change_leverage(symbol=symbol, leverage=info.laverage)
print(price * info.stopshort)
stop = client.futures_create_order(symbol=symbol, side="SELL", type="STOP_MARKET", stopPrice=price * info.stopshort, closePosition="true")
take = client.futures_create_order(symbol=symbol, side="SELL", type="TAKE_PROFIT_MARKET", stopPrice=price * info.takeshort, closePosition="true")
buyorder = client.futures_create_order(symbol=symbol, side=pos, type="LIMIT", quantity=q, price=price, timeInForce="GTC")我试图通过舍入止损价来解决这个问题,但这样我就出错了:
binance.exceptions.BinanceAPIException: APIError(code=-2021): Order would immediately trigger.发布于 2022-06-13 14:28:34
第一个错误1111只是因为您使用的价格高于允许的最大小数位数。例如,如果tickSize返回0.01,则该符号允许的最大小数位数为2。
至于错误2021,您正在接收此错误,因为您的止损价格是这样的,如果您下了订单,您的订单将立即执行。
为了止损市场订单在买入多头的情况下是成功的,你的止损价格需要高于当前的市场价格,而在卖空的情况下,你的止损价格需要低于当前的市场价格。
如果你做空,并想引入止损,你需要有side="BUY",而不是side="SELL",因为你想关闭卖空,并按你设定的市场价格回购。
stop = client.futures_create_order(symbol=symbol, side="BUY", type="STOP_MARKET", stopPrice=price * info.stopshort, closePosition="true")https://stackoverflow.com/questions/72604150
复制相似问题