Fix logic lapsus in check_exit_amount

This commit is contained in:
Matthias 2023-04-26 06:45:09 +02:00
parent d0b5c7d216
commit b0b036c457
2 changed files with 4 additions and 1 deletions

View File

@ -463,6 +463,7 @@ class FreqtradeBot(LoggingMixin):
if trade_order:
continue
logger.info(f"Found previously unknown order {order['id']} for {trade.pair}.")
order_obj = Order.parse_from_ccxt_object(order, trade.pair, order['side'])
order_obj.order_filled_date = datetime.fromtimestamp(
safe_value_fallback(order, 'lastTradeTimestamp', 'timestamp') // 1000,
@ -473,6 +474,7 @@ class FreqtradeBot(LoggingMixin):
prev_exit_reason = trade.exit_reason
trade.exit_reason = ExitType.SOLD_ON_EXCHANGE.value
self.update_trade_state(trade, order['id'], order)
logger.info(f"handled order {order['id']}")
if not trade.is_open:
# Trade was just closed
@ -481,6 +483,7 @@ class FreqtradeBot(LoggingMixin):
break
else:
trade.exit_reason = prev_exit_reason
Trade.commit()
except ExchangeError:
logger.warning("Error finding onexchange order")

View File

@ -184,7 +184,7 @@ class Wallets:
def _check_exit_amount(self, trade: Trade) -> bool:
if trade.trading_mode != TradingMode.FUTURES:
# Slightly higher offset than in safe_exit_amount.
wallet_amount: float = self.get_total(trade.safe_base_currency) * 0.981
wallet_amount: float = self.get_total(trade.safe_base_currency) * (2 - 0.981)
else:
# wallet_amount: float = self.wallets.get_free(trade.safe_base_currency)
position = self._positions.get(trade.pair)