From f0b2798c37b7ad9dbda736cf92217a060ab514d9 Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Mon, 1 Apr 2019 14:08:03 +0300 Subject: [PATCH 1/7] fix #1704 --- freqtrade/freqtradebot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 6f1fb2c99..c14f0d31a 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -363,7 +363,8 @@ class FreqtradeBot(object): logger.debug('Ignoring %s in pair whitelist', trade.pair) if not whitelist: - raise DependencyException('No currency pairs in whitelist') + logger.info("No currency pairs left in whitelist, no trades can be created.") + return False # running get_signal on historical data fetched for _pair in whitelist: From 77d2479c7584954fdd30568756453051d34ac87b Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Mon, 1 Apr 2019 14:08:41 +0300 Subject: [PATCH 2/7] tests adjusted --- freqtrade/tests/test_freqtradebot.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/freqtrade/tests/test_freqtradebot.py b/freqtrade/tests/test_freqtradebot.py index e4f0415f7..4e145c354 100644 --- a/freqtrade/tests/test_freqtradebot.py +++ b/freqtrade/tests/test_freqtradebot.py @@ -545,8 +545,7 @@ def test_create_trade_too_small_stake_amount(default_conf, ticker, limit_buy_ord freqtrade = FreqtradeBot(default_conf) patch_get_signal(freqtrade) - result = freqtrade.create_trade() - assert result is False + assert not freqtrade.create_trade() def test_create_trade_limit_reached(default_conf, ticker, limit_buy_order, @@ -567,7 +566,7 @@ def test_create_trade_limit_reached(default_conf, ticker, limit_buy_order, freqtrade = FreqtradeBot(default_conf) patch_get_signal(freqtrade) - assert freqtrade.create_trade() is False + assert not freqtrade.create_trade() assert freqtrade._get_trade_stake_amount('ETH/BTC') is None @@ -588,9 +587,7 @@ def test_create_trade_no_pairs(default_conf, ticker, limit_buy_order, fee, marke patch_get_signal(freqtrade) freqtrade.create_trade() - - with pytest.raises(DependencyException, match=r'.*No currency pairs in whitelist.*'): - freqtrade.create_trade() + assert not freqtrade.create_trade() def test_create_trade_no_pairs_after_blacklist(default_conf, ticker, @@ -610,9 +607,7 @@ def test_create_trade_no_pairs_after_blacklist(default_conf, ticker, patch_get_signal(freqtrade) freqtrade.create_trade() - - with pytest.raises(DependencyException, match=r'.*No currency pairs in whitelist.*'): - freqtrade.create_trade() + assert not freqtrade.create_trade() def test_create_trade_no_signal(default_conf, fee, mocker) -> None: From 8546db9dfdccd813fc3e0400fb8cb6aff84bcf1a Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Mon, 1 Apr 2019 20:23:13 +0300 Subject: [PATCH 3/7] wording in the log message --- freqtrade/freqtradebot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index c14f0d31a..e9b8b1956 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -363,7 +363,7 @@ class FreqtradeBot(object): logger.debug('Ignoring %s in pair whitelist', trade.pair) if not whitelist: - logger.info("No currency pairs left in whitelist, no trades can be created.") + logger.info("No currency pair left in whitelist, no more trade can be created.") return False # running get_signal on historical data fetched From 34b40500c33dbddbd60f45ae9e8dcf4e619b0b18 Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Mon, 1 Apr 2019 20:45:59 +0300 Subject: [PATCH 4/7] Check whitelist fetched from config for emptiness --- freqtrade/freqtradebot.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index e9b8b1956..42013c85f 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -79,6 +79,9 @@ class FreqtradeBot(object): self.config.get('edge', {}).get('enabled', False) else None self.active_pair_whitelist: List[str] = self.config['exchange']['pair_whitelist'] + if not self.active_pair_whitelist: + raise DependencyException('Whitelist is empty.') + self._init_modules() # Tell the systemd that we completed initialization phase From ab0e657d7711bdb4a1ff7b60652a4e2030b8cbc3 Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Mon, 1 Apr 2019 21:36:53 +0300 Subject: [PATCH 5/7] Check for empty whitelist moved to _process() --- freqtrade/freqtradebot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 42013c85f..e5400c1d0 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -79,8 +79,6 @@ class FreqtradeBot(object): self.config.get('edge', {}).get('enabled', False) else None self.active_pair_whitelist: List[str] = self.config['exchange']['pair_whitelist'] - if not self.active_pair_whitelist: - raise DependencyException('Whitelist is empty.') self._init_modules() @@ -198,6 +196,9 @@ class FreqtradeBot(object): # Refresh whitelist self.pairlists.refresh_pairlist() self.active_pair_whitelist = self.pairlists.whitelist + if not self.active_pair_whitelist: + logger.warning('Whitelist is empty.') + return False # Calculating Edge positioning if self.edge: From 3c399fbe3fe1edd1ea1dab04898201edcf1026a3 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 3 Apr 2019 19:51:46 +0200 Subject: [PATCH 6/7] Improve whitelist wordings --- freqtrade/freqtradebot.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index e5400c1d0..bf445e56d 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -79,7 +79,6 @@ class FreqtradeBot(object): self.config.get('edge', {}).get('enabled', False) else None self.active_pair_whitelist: List[str] = self.config['exchange']['pair_whitelist'] - self._init_modules() # Tell the systemd that we completed initialization phase @@ -196,9 +195,6 @@ class FreqtradeBot(object): # Refresh whitelist self.pairlists.refresh_pairlist() self.active_pair_whitelist = self.pairlists.whitelist - if not self.active_pair_whitelist: - logger.warning('Whitelist is empty.') - return False # Calculating Edge positioning if self.edge: @@ -360,6 +356,10 @@ class FreqtradeBot(object): interval = self.strategy.ticker_interval whitelist = copy.deepcopy(self.active_pair_whitelist) + if not whitelist: + logger.warning("Whitelist is empty.") + return False + # Remove currently opened and latest pairs from whitelist for trade in Trade.get_open_trades(): if trade.pair in whitelist: @@ -367,7 +367,7 @@ class FreqtradeBot(object): logger.debug('Ignoring %s in pair whitelist', trade.pair) if not whitelist: - logger.info("No currency pair left in whitelist, no more trade can be created.") + logger.info("No currency pair in whitelist, but checking to sell open trades.") return False # running get_signal on historical data fetched From 1a5b0969b952603fa54a6dedd446ad93fcaf2caf Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 3 Apr 2019 19:52:06 +0200 Subject: [PATCH 7/7] Fix tests (both tests where testing the same thing) --- freqtrade/tests/test_freqtradebot.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/freqtrade/tests/test_freqtradebot.py b/freqtrade/tests/test_freqtradebot.py index 4e145c354..fc13bc0f1 100644 --- a/freqtrade/tests/test_freqtradebot.py +++ b/freqtrade/tests/test_freqtradebot.py @@ -570,7 +570,8 @@ def test_create_trade_limit_reached(default_conf, ticker, limit_buy_order, assert freqtrade._get_trade_stake_amount('ETH/BTC') is None -def test_create_trade_no_pairs(default_conf, ticker, limit_buy_order, fee, markets, mocker) -> None: +def test_create_trade_no_pairs_let(default_conf, ticker, limit_buy_order, fee, + markets, mocker, caplog) -> None: patch_RPCManager(mocker) patch_exchange(mocker) mocker.patch.multiple( @@ -582,16 +583,17 @@ def test_create_trade_no_pairs(default_conf, ticker, limit_buy_order, fee, marke ) default_conf['exchange']['pair_whitelist'] = ["ETH/BTC"] - default_conf['exchange']['pair_blacklist'] = ["ETH/BTC"] freqtrade = FreqtradeBot(default_conf) patch_get_signal(freqtrade) - freqtrade.create_trade() + assert freqtrade.create_trade() assert not freqtrade.create_trade() + assert log_has("No currency pair in whitelist, but checking to sell open trades.", + caplog.record_tuples) -def test_create_trade_no_pairs_after_blacklist(default_conf, ticker, - limit_buy_order, fee, markets, mocker) -> None: +def test_create_trade_no_pairs_in_whitelist(default_conf, ticker, limit_buy_order, fee, + markets, mocker, caplog) -> None: patch_RPCManager(mocker) patch_exchange(mocker) mocker.patch.multiple( @@ -601,13 +603,12 @@ def test_create_trade_no_pairs_after_blacklist(default_conf, ticker, get_fee=fee, markets=PropertyMock(return_value=markets) ) - default_conf['exchange']['pair_whitelist'] = ["ETH/BTC"] - default_conf['exchange']['pair_blacklist'] = ["ETH/BTC"] + default_conf['exchange']['pair_whitelist'] = [] freqtrade = FreqtradeBot(default_conf) patch_get_signal(freqtrade) - freqtrade.create_trade() assert not freqtrade.create_trade() + assert log_has("Whitelist is empty.", caplog.record_tuples) def test_create_trade_no_signal(default_conf, fee, mocker) -> None: