From ebcb530d4f0303ca0cb164296b92cd8ea269d032 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 9 Apr 2022 09:56:12 +0200 Subject: [PATCH] Log if no stake-amount is left for trade --- freqtrade/freqtradebot.py | 1 + freqtrade/rpc/rpc.py | 2 +- tests/rpc/test_rpc.py | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 6e1a0b208..dc2e21ed6 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -598,6 +598,7 @@ class FreqtradeBot(LoggingMixin): pair, price, stake_amount, trade_side, enter_tag, trade) if not stake_amount: + logger.info(f"No stake amount to enter a trade for {pair}.") return False if pos_adjust: diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 258754b90..8f3d57cf6 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -791,7 +791,7 @@ class RPC: trade = Trade.get_trades([Trade.is_open.is_(True), Trade.pair == pair]).first() return trade else: - return None + raise RPCException(f'Failed to enter position for {pair}.') def _rpc_delete(self, trade_id: int) -> Dict[str, Union[str, int]]: """ diff --git a/tests/rpc/test_rpc.py b/tests/rpc/test_rpc.py index 8bdb81072..e421b6fe5 100644 --- a/tests/rpc/test_rpc.py +++ b/tests/rpc/test_rpc.py @@ -1230,8 +1230,8 @@ def test_rpc_force_entry(mocker, default_conf, ticker, fee, limit_buy_order_open patch_get_signal(freqtradebot) rpc = RPC(freqtradebot) pair = 'TKN/BTC' - trade = rpc._rpc_force_entry(pair, None) - assert trade is None + with pytest.raises(RPCException, match=r"Failed to enter position for TKN/BTC."): + trade = rpc._rpc_force_entry(pair, None) def test_rpc_force_entry_stopped(mocker, default_conf) -> None: