Repository: freqtrade/freqtrade

Issue:
Permanent "all balances are zero" on kraken
## 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.516 (`pip freeze | grep ccxt`)
  * Branch: Develop
  * Last Commit ID: 867f9ae362354be7ecd70f73b9570a2f4c124a9e (`git log --format="%H" -n 1`)
  
## Step 3: Describe the problem:
### Steps to reproduce:
### Observed Results:

The bot runs on kraken -> starts well.
Dry mode is disabled.
On Telegram, if I ask for /balance, I obtain  'All balances are at zero' whereas my kraken account has some euros.

### Relevant code exceptions or logs:
In the command line, I obtain the following output.
(Warning: the configured pair is BTC/EUR, with EUR as stake_currency, not EUR/BTC ! -> I do not know why it makes the invertion)
  ```
2019-05-11 12:38:22,308 - freqtrade.rpc.telegram - INFO - Executing handler: _balance for chat_id: XXXXXXXXXX
2019-05-11 12:38:22,636 - freqtrade.exchange.exchange - WARNING - get_ticker() returned exception: "Pair EUR/BTC not available"
2019-05-11 12:38:22,636 - freqtrade.exchange.exchange - WARNING - retrying get_ticker() still for 3 times
2019-05-11 12:38:22,637 - freqtrade.exchange.exchange - WARNING - get_ticker() returned exception: "Pair EUR/BTC not available"
2019-05-11 12:38:22,637 - freqtrade.exchange.exchange - WARNING - retrying get_ticker() still for 2 times
2019-05-11 12:38:22,638 - freqtrade.exchange.exchange - WARNING - get_ticker() returned exception: "Pair EUR/BTC not available"
2019-05-11 12:38:22,638 - freqtrade.exchange.exchange - WARNING - retrying get_ticker() still for 1 times
2019-05-11 12:38:22,639 - freqtrade.exchange.exchange - WARNING - get_ticker() returned exception: "Pair EUR/BTC not available"
2019-05-11 12:38:22,639 - freqtrade.exchange.exchange - WARNING - retrying get_ticker() still for 0 times
2019-05-11 12:38:22,639 - freqtrade.exchange.exchange - WARNING - get_ticker() returned exception: "Pair EUR/BTC not available"
2019-05-11 12:38:22,639 - freqtrade.exchange.exchange - WARNING - Giving up retrying: get_ticker()

  ```

Please note that kraken previously made you trade bitcoin with the XBT symbol.
It now makes you trade with BTC symbol.

I tried to fallback on XBT/EUR pair and it output this:
  ```
2019-05-11 12:43:06,855 - freqtrade - ERROR - Pair XBT/EUR is not available on Kraken. Please remove XBT/EUR from your whitelist.

  ```



Discussion:
Can you please post your configuration (remember to remove keys!) so we can verify this, thanks.
> 
> 
> Can you please post your configuration (remember to remove keys!) so we can verify this, thanks.

Yes!
  ```
{
    "max_open_trades": 1,
    "stake_currency": "EUR",
    "stake_amount": 5,
    "fiat_display_currency": "EUR",
    "ticker_interval" : "5m",
    "dry_run": false,
    "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": "kraken",
        "key": "ZZZZ",
        "secret": "ZZZZ",
        "ccxt_config": {"enableRateLimit": true},
        "ccxt_async_config": {
            "enableRateLimit": true,
            "rateLimit": 100
        },
        "pair_whitelist": [
            "BTC/EUR"
        ],
        "pair_blacklist": [
        ]
    },
    "experimental": {
        "use_sell_signal": true,
        "sell_profit_only": false,
        "ignore_roi_if_buy_signal": true
    },
    "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": "ZZZZ",
        "chat_id": "ZZZZ"
    },
    "initial_state": "running",
    "forcebuy_enable": false,
    "internals": {
        "process_throttle_secs": 5
    }
}

  ```
Hi there,

your configuration lists ` "dry_run": true,` ... so it's enabled.
If i disable dry-run, the balances are reported correctly with kraken using your configuration.

> 
> 
> Hi there,
> 
> your configuration lists ` "dry_run": true,` ... so it's enabled.
> If i disable dry-run, the balances are reported correctly with kraken using your configuration.

It is true right now because I launched a dry mode trade based on this configuration.
Nevertheless it does not work with false....

I just re-did the test and I really got the issue.

I change my previous post to put false on dry mode to avoid confusion.

It does take a few seconds, however i do get the result.

Maybe it's related to the currencies? (i have 0 EUR, and 0 BTC on kraken, but a few alt-coins...)
@xmatthias 
Do you want a ro API Key on m'y account ?
I can create a key which can only be used for querying funds. 
I can recreate the message `get_ticker() returned exception: "Pair EUR/BTC not available"` too.
however - it's returning all currencies apart from EUR just fine.

I don't want an API key (and you should not offer that, even if it's just a RO key ...)
Do you have any currency other than EUR in your account?

Resolving patch:
diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py
--- a/freqtrade/rpc/rpc.py
+++ b/freqtrade/rpc/rpc.py
@@ -276,11 +276,12 @@ def _rpc_balance(self, fiat_display_currency: str) -> Dict:
                 rate = 1.0
             else:
                 try:
-                    if coin == 'USDT':
-                        rate = 1.0 / self._freqtrade.get_sell_rate('BTC/USDT', False)
+                    if coin in('USDT', 'USD', 'EUR'):
+                        rate = 1.0 / self._freqtrade.get_sell_rate('BTC/' + coin, False)
                     else:
                         rate = self._freqtrade.get_sell_rate(coin + '/BTC', False)
                 except (TemporaryError, DependencyException):
+                    logger.warning(f" Could not get rate for pair {coin}.")
                     continue
             est_btc: float = rate * balance['total']
             total = total + est_btc


Test patch:
diff --git a/freqtrade/tests/rpc/test_rpc_telegram.py b/freqtrade/tests/rpc/test_rpc_telegram.py
--- a/freqtrade/tests/rpc/test_rpc_telegram.py
+++ b/freqtrade/tests/rpc/test_rpc_telegram.py
@@ -522,6 +522,11 @@ def test_telegram_balance_handle(default_conf, update, mocker) -> None:
             'total': 1.0,
             'free': 1.0,
             'used': 0.0
+            },
+        'EUR': {
+            'total': 10.0,
+            'free': 10.0,
+            'used': 0.0
             }
     }
 
@@ -565,6 +570,7 @@ def mock_ticker(symbol, refresh):
     assert '*BTC:*' in result
     assert '*ETH:*' not in result
     assert '*USDT:*' in result
+    assert '*EUR:*' in result
     assert 'Balance:' in result
     assert 'Est. BTC:' in result
     assert 'BTC:  12.00000000' in result