Repository: freqtrade/freqtrade

Issue:
No currency pairs in whitelist
## Step 1: Have you search for this issue before posting it?

Yes !

## Step 2: Describe your environment

  * Python Version: 3.6.7 (`python -V`)
  * CCXT version: 1.18.372  (`pip freeze | grep ccxt`)
  * Branch: Master | Develop
  * Last Commit ID: c8617e70a87cc2835738d5d2bad0cd46dc2e9d68 (`git log --format="%H" -n 1`)
  
## Step 3: Describe the problem:

Freqtrade is well launched but tells me some hours later:
'2019-03-20 09:22:58,649 - freqtrade.freqtradebot - WARNING - Unable to create trade: No currency pairs in whitelist'

Here is what is specified in my configuration file:
        "pair_whitelist": [
            "BTC/USDT"
        ],

When I launch the bot, telegram:
'Searching for USDT pairs to buy and sell based on StaticPairList: ['BTC/USDT']'

So I conclude that a currency pair is well configured....

Do you identify what I could have done wrong ?

Thank you
Regards
Xavier
No currency pairs in whitelist
## Step 1: Have you search for this issue before posting it?

Yes !

## Step 2: Describe your environment

  * Python Version: 3.6.7 (`python -V`)
  * CCXT version: 1.18.372  (`pip freeze | grep ccxt`)
  * Branch: Master | Develop
  * Last Commit ID: c8617e70a87cc2835738d5d2bad0cd46dc2e9d68 (`git log --format="%H" -n 1`)
  
## Step 3: Describe the problem:

Freqtrade is well launched but tells me some hours later:
'2019-03-20 09:22:58,649 - freqtrade.freqtradebot - WARNING - Unable to create trade: No currency pairs in whitelist'

Here is what is specified in my configuration file:
        "pair_whitelist": [
            "BTC/USDT"
        ],

When I launch the bot, telegram:
'Searching for USDT pairs to buy and sell based on StaticPairList: ['BTC/USDT']'

So I conclude that a currency pair is well configured....

Do you identify what I could have done wrong ?

Thank you
Regards
Xavier


Discussion:
how does your configuration look like (make sure to remove keys eventually)?
edge on or off?
please run `/status table` or `/status` on telegram - maybe the bot has a position open for BTC/USDT?
if edge is on, then probably we should enrich that warning
I think Edge warns itself when it removes them all ... but the log is kinda minimalistic ... 
Dear @xmatthias ,

No, edge is not enabled.

Here is my configuration (I am testing the soft, not strategies nor timers therefore values of the configuration are not customized):

Thank you very much
Xavier

```json
{
    "max_open_trades": 10,
    "stake_currency": "USDT",
    "stake_amount": 0.05,
    "fiat_display_currency": "USDT",
    "ticker_interval" : "15m",
    "dry_run": true,
    "trailing_stop": false,
    "unfilledtimeout": {
        "buy": 10,
        "sell": 30
    },
    "bid_strategy": {
        "ask_last_balance": 0.0,
        "use_order_book": false,
        "order_book_top": 1,
        "check_depth_of_market": {
            "enabled": false,
            "bids_to_ask_delta": 1
        }
    },
    "ask_strategy":{
        "use_order_book": false,
        "order_book_min": 1,
        "order_book_max": 9
    },
    "exchange": {
        "name": "binance",
        "key": "XXX",
        "secret": "YYY",
        "ccxt_config": {"enableRateLimit": true},
        "ccxt_async_config": {
            "enableRateLimit": false
        },
        "pair_whitelist": [
            "BTC/USDT"
        ],
        "pair_blacklist": [
            "ETH/USDT"
        ]
    },
    "experimental": {
        "use_sell_signal": true,
        "sell_profit_only": false,
        "ignore_roi_if_buy_signal": false
    },
    "edge": {
        "enabled": false,
        "process_throttle_secs": 3600,
        "calculate_since_number_of_days": 7,
        "capital_available_percentage": 0.5,
        "allowed_risk": 0.01,
        "stoploss_range_min": -0.01,
        "stoploss_range_max": -0.1,
        "stoploss_range_step": -0.01,
        "minimum_winrate": 0.60,
        "minimum_expectancy": 0.20,
        "min_trade_number": 10,
        "max_trade_duration_minute": 1440,
        "remove_pumps": false
    },
    "telegram": {
        "enabled": true,
        "token": "XXX",
        "chat_id": "YYY"
    },
    "initial_state": "running",
    "forcebuy_enable": false,
    "internals": {
        "process_throttle_secs": 5
    }
}
```


As I see from the code, this message ("Unable to create trade: No currency pairs in whitelist") is issued every time after positions are open for all pairs in the whitelist at next throttling iteration. So if you have only one pair, this message will be issued after buying that pair. Is it really as intended? ('Cause, yes, no actually pairs in whitelist since a pair is removed from the whitelist when it has open position...)

Maybe it should not be a warning (info message?) and should not contain "Unable to create trade" because no trades can even be created in this *normal* situation...

@hroff-1902 ,
You are right.
I tested by adding a second pair and the message only shows up when there are two open positions.
Therefore it does not seem to be an issue to trade but at most a not-easy-to-understand message.

Thank you very much

how does your configuration look like (make sure to remove keys eventually)?
edge on or off?
please run `/status table` or `/status` on telegram - maybe the bot has a position open for BTC/USDT?
if edge is on, then probably we should enrich that warning
I think Edge warns itself when it removes them all ... but the log is kinda minimalistic ... 
Dear @xmatthias ,

No, edge is not enabled.

Here is my configuration (I am testing the soft, not strategies nor timers therefore values of the configuration are not customized):

Thank you very much
Xavier

```json
{
    "max_open_trades": 10,
    "stake_currency": "USDT",
    "stake_amount": 0.05,
    "fiat_display_currency": "USDT",
    "ticker_interval" : "15m",
    "dry_run": true,
    "trailing_stop": false,
    "unfilledtimeout": {
        "buy": 10,
        "sell": 30
    },
    "bid_strategy": {
        "ask_last_balance": 0.0,
        "use_order_book": false,
        "order_book_top": 1,
        "check_depth_of_market": {
            "enabled": false,
            "bids_to_ask_delta": 1
        }
    },
    "ask_strategy":{
        "use_order_book": false,
        "order_book_min": 1,
        "order_book_max": 9
    },
    "exchange": {
        "name": "binance",
        "key": "XXX",
        "secret": "YYY",
        "ccxt_config": {"enableRateLimit": true},
        "ccxt_async_config": {
            "enableRateLimit": false
        },
        "pair_whitelist": [
            "BTC/USDT"
        ],
        "pair_blacklist": [
            "ETH/USDT"
        ]
    },
    "experimental": {
        "use_sell_signal": true,
        "sell_profit_only": false,
        "ignore_roi_if_buy_signal": false
    },
    "edge": {
        "enabled": false,
        "process_throttle_secs": 3600,
        "calculate_since_number_of_days": 7,
        "capital_available_percentage": 0.5,
        "allowed_risk": 0.01,
        "stoploss_range_min": -0.01,
        "stoploss_range_max": -0.1,
        "stoploss_range_step": -0.01,
        "minimum_winrate": 0.60,
        "minimum_expectancy": 0.20,
        "min_trade_number": 10,
        "max_trade_duration_minute": 1440,
        "remove_pumps": false
    },
    "telegram": {
        "enabled": true,
        "token": "XXX",
        "chat_id": "YYY"
    },
    "initial_state": "running",
    "forcebuy_enable": false,
    "internals": {
        "process_throttle_secs": 5
    }
}
```


As I see from the code, this message ("Unable to create trade: No currency pairs in whitelist") is issued every time after positions are open for all pairs in the whitelist at next throttling iteration. So if you have only one pair, this message will be issued after buying that pair. Is it really as intended? ('Cause, yes, no actually pairs in whitelist since a pair is removed from the whitelist when it has open position...)

Maybe it should not be a warning (info message?) and should not contain "Unable to create trade" because no trades can even be created in this *normal* situation...

@hroff-1902 ,
You are right.
I tested by adding a second pair and the message only shows up when there are two open positions.
Therefore it does not seem to be an issue to trade but at most a not-easy-to-understand message.

Thank you very much


Resolving patch:
diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py
--- a/freqtrade/freqtradebot.py
+++ b/freqtrade/freqtradebot.py
@@ -356,6 +356,10 @@ def create_trade(self) -> bool:
         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:
@@ -363,7 +367,8 @@ def create_trade(self) -> bool:
                 logger.debug('Ignoring %s in pair whitelist', trade.pair)
 
         if not whitelist:
-            raise DependencyException('No currency pairs in whitelist')
+            logger.info("No currency pair in whitelist, but checking to sell open trades.")
+            return False
 
         # running get_signal on historical data fetched
         for _pair in whitelist:


Test patch:
diff --git a/freqtrade/tests/test_freqtradebot.py b/freqtrade/tests/test_freqtradebot.py
--- 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,11 +566,12 @@ 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
 
 
-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(
@@ -583,18 +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()
-
-    with pytest.raises(DependencyException, match=r'.*No currency pairs in whitelist.*'):
-        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(
@@ -604,15 +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()
-
-    with pytest.raises(DependencyException, match=r'.*No currency pairs in whitelist.*'):
-        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: