diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index d14e1ee2f..7bfeab592 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -903,14 +903,14 @@ class FreqtradeBot(LoggingMixin): msg = ( f"Position adjust: about to create a new order for {pair} with stake_amount: " - f"{stake_amount} for {trade}" + f"{stake_amount} and price: {enter_limit_requested} for {trade}" if mode == "pos_adjust" else ( f"Replacing {side} order: about create a new order for {pair} with stake_amount: " - f"{stake_amount} ..." + f"{stake_amount} and price: {enter_limit_requested} ..." if mode == "replace" else f"{name} signal found: about create a new trade for {pair} with stake_amount: " - f"{stake_amount} ..." + f"{stake_amount} and price: {enter_limit_requested} ..." ) ) logger.info(msg) @@ -2590,4 +2590,15 @@ class FreqtradeBot(LoggingMixin): max_custom_price_allowed = proposed_price + (proposed_price * cust_p_max_dist_r) # Bracket between min_custom_price_allowed and max_custom_price_allowed - return max(min(valid_custom_price, max_custom_price_allowed), min_custom_price_allowed) + final_price = max( + min(valid_custom_price, max_custom_price_allowed), min_custom_price_allowed + ) + + # Log a warning if the custom price was adjusted by clamping. + if final_price != valid_custom_price: + logger.info( + f"Custom price adjusted from {valid_custom_price} to {final_price} based on " + "custom_price_max_distance_ratio of {cust_p_max_dist_r}." + ) + + return final_price diff --git a/tests/freqtradebot/test_freqtradebot.py b/tests/freqtradebot/test_freqtradebot.py index e66e5065c..3ff8fcb5e 100644 --- a/tests/freqtradebot/test_freqtradebot.py +++ b/tests/freqtradebot/test_freqtradebot.py @@ -701,9 +701,9 @@ def test_process_trade_creation( assert pytest.approx(trade.amount) == 0 assert pytest.approx(trade.amount_requested) == 60 / ticker_usdt.return_value[ticker_side] - assert log_has( + assert log_has_re( f"{'Short' if is_short else 'Long'} signal found: about create a new trade for ETH/USDT " - "with stake_amount: 60.0 ...", + r"with stake_amount: 60.0 and price: .*", caplog, ) mocker.patch("freqtrade.freqtradebot.FreqtradeBot._check_and_execute_exit")