diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index c4792a275..b18b8eac5 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -426,21 +426,17 @@ class FreqtradeBot(object): return True - def process_maybe_execute_buy(self) -> bool: + def process_maybe_execute_buy(self) -> None: """ Tries to execute a buy trade in a safe way :return: True if executed """ try: # Create entity and execute trade - if self.create_trade(): - return True - - logger.info('Found no buy signals for whitelisted currencies. Trying again..') - return False + if not self.create_trade(): + logger.info('Found no buy signals for whitelisted currencies. Trying again...') except DependencyException as exception: logger.warning('Unable to create trade: %s', exception) - return False def process_maybe_execute_sell(self, trade: Trade) -> bool: """ diff --git a/freqtrade/tests/test_freqtradebot.py b/freqtrade/tests/test_freqtradebot.py index 7ad9cba7a..f70b5374e 100644 --- a/freqtrade/tests/test_freqtradebot.py +++ b/freqtrade/tests/test_freqtradebot.py @@ -1385,14 +1385,12 @@ def test_tsl_on_exchange_compatible_with_edge(mocker, edge_conf, fee, caplog, stop_price=0.00002344 * 0.99) -def test_process_maybe_execute_buy(mocker, default_conf) -> None: +def test_process_maybe_execute_buy(mocker, default_conf, caplog) -> None: freqtrade = get_patched_freqtradebot(mocker, default_conf) - mocker.patch('freqtrade.freqtradebot.FreqtradeBot.create_trade', MagicMock(return_value=True)) - assert freqtrade.process_maybe_execute_buy() - mocker.patch('freqtrade.freqtradebot.FreqtradeBot.create_trade', MagicMock(return_value=False)) - assert not freqtrade.process_maybe_execute_buy() + freqtrade.process_maybe_execute_buy() + assert log_has('Found no buy signals for whitelisted currencies. Trying again...', caplog) def test_process_maybe_execute_buy_exception(mocker, default_conf, caplog) -> None: