Add amount_to_contracts and order_contracts_to_amount to stoploss

This commit is contained in:
Sam Germain 2022-03-25 06:56:05 -06:00
parent 35a4053dbe
commit 054b637001

View File

@ -1103,11 +1103,12 @@ class Exchange:
if self.trading_mode == TradingMode.FUTURES: if self.trading_mode == TradingMode.FUTURES:
params['reduceOnly'] = True params['reduceOnly'] = True
amount = self.amount_to_precision(pair, amount) amount = self.amount_to_precision(pair, self._amount_to_contracts(pair, amount))
self._lev_prep(pair, leverage, side) self._lev_prep(pair, leverage, side)
order = self._api.create_order(symbol=pair, type=ordertype, side=side, order = self._api.create_order(symbol=pair, type=ordertype, side=side,
amount=amount, price=rate, params=params) amount=amount, price=rate, params=params)
order = self._order_contracts_to_amount(order)
logger.info(f"stoploss {user_order_type} order added for {pair}. " logger.info(f"stoploss {user_order_type} order added for {pair}. "
f"stop price: {stop_price}. limit: {rate}") f"stop price: {stop_price}. limit: {rate}")
self._log_exchange_response('create_stoploss_order', order) self._log_exchange_response('create_stoploss_order', order)