我正在尝试使用ccxt ccxt-1.39.93,Python 3来平仓Binance Futures。
# fetch position
position = binance.fetch_balance()['info']['positions']
pos = [p for p in position if p['symbol'] == "ETHUSDT"][0]
ticker = get_binance_futures(fetch_only=True)
close_position = binance.create_order(symbol=symbol, type="TAKE_PROFIT_MARKET", side="buy", amount=pos['positionAmt'], price=ticker , params={"closePosition": True, "stopPrice": ticker}) 我想关闭当前位置。但是得到了这个错误:
ccxt.base.errors.ExchangeError: binance {"code":-2021,"msg":"Order would immediately trigger."}对于给定的符号,有没有一种简单的方法来平仓当前的市场或现货价格?
发布于 2020-12-31 17:57:41
经过一番挣扎,我终于找到了解决方案。
close_position = binance.create_order(symbol=symbol, type="MARKET", side="buy", amount=pos['positionAmt'], params={"reduceOnly": True}) 使用reduceOnly参数做到了这一点。不需要设定价格,因为这是市场。
https://stackoverflow.com/questions/65514350
复制相似问题