diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index c16b1ad60..62c81fccb 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -549,7 +549,7 @@ class FreqtradeBot(LoggingMixin): return else: logger.debug("Max adjustment entries is set to unlimited.") - self.execute_entry(trade.pair, stake_amount, current_entry_rate, + self.execute_entry(trade.pair, stake_amount, None and current_entry_rate, trade=trade, is_short=trade.is_short) if stake_amount is not None and stake_amount < 0.0: diff --git a/freqtrade/persistence/trade_model.py b/freqtrade/persistence/trade_model.py index 10dc3cf8e..2c66d8fe2 100644 --- a/freqtrade/persistence/trade_model.py +++ b/freqtrade/persistence/trade_model.py @@ -581,6 +581,12 @@ class LocalTrade(): payment = "BUY" if self.is_short else "SELL" # * On margin shorts, you buy a little bit more than the amount (amount + interest) logger.info(f'{order.order_type.upper()}_{payment} has been fulfilled for {self}.') + # condition to avoid reset value when updating fees + if self.open_order_id == order.order_id: + self.open_order_id = None + else: + logger.warning( + f'Got different open_order_id {self.open_order_id} != {order.order_id}') if isclose(order.safe_amount_after_fee, self.amount, abs_tol=MATH_CLOSE_PREC): self.close(order.safe_price) diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index aee8f8cef..60263dcc8 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -3213,7 +3213,7 @@ def test_execute_trade_exit_up(default_conf_usdt, ticker_usdt, fee, ticker_usdt_ 'close_date': ANY, 'close_rate': ANY, 'sub_trade': False, - 'stake_amount': 60.0, + 'stake_amount': pytest.approx(60), } == last_msg @@ -3275,7 +3275,7 @@ def test_execute_trade_exit_down(default_conf_usdt, ticker_usdt, fee, ticker_usd 'close_date': ANY, 'close_rate': ANY, 'sub_trade': False, - 'stake_amount': 60.0, + 'stake_amount': pytest.approx(60), } == last_msg @@ -3358,7 +3358,7 @@ def test_execute_trade_exit_custom_exit_price( 'close_date': ANY, 'close_rate': ANY, 'sub_trade': False, - 'stake_amount': 60.0, + 'stake_amount': pytest.approx(60), } == last_msg @@ -3428,7 +3428,7 @@ def test_execute_trade_exit_down_stoploss_on_exchange_dry_run( 'close_date': ANY, 'close_rate': ANY, 'sub_trade': False, - 'stake_amount': 60.0, + 'stake_amount': pytest.approx(60), } == last_msg @@ -3688,7 +3688,7 @@ def test_execute_trade_exit_market_order( 'close_date': ANY, 'close_rate': ANY, 'sub_trade': False, - 'stake_amount': 60.0, + 'stake_amount': pytest.approx(60), } == last_msg @@ -5613,7 +5613,7 @@ def test_position_adjust2(mocker, default_conf_usdt, fee) -> None: assert trade.stake_amount == bid * amount assert not trade.fee_updated('buy') - freqtrade.check_handle_timedout() + freqtrade.manage_open_orders() trade = Trade.query.first() assert trade