Repository: freqtrade/freqtrade

Issue:
fails to get balances in Cobinhood
## Step 1: Have you search for this issue before posting it?

If you have discovered a bug in the bot, please [search our issue tracker](https://github.com/freqtrade/freqtrade/issues?q=is%3Aissue). 
If it hasn't been reported, please create a new issue.

## Step 2: Describe your environment

  * Python Version: 3.6.3 (`python -V`)
  * CCXT version:  1.14.267 (`pip freeze | grep ccxt`)
  * Branch: Develop
  * Last Commit ID: 4c7d1c90db1fd9200a6edcb8774f2316d369178f (`git log --format="%H" -n 1`)
  
## Step 3: Describe the problem:

When try to get balances from telegram it fails with below messages

### Steps to reproduce:

  1. press /balance button in Telegram
  2. _____
  3. _____
  
### Observed Results:

  * What happened? no text/message in Telegram
  * What did you expect to happen? Show balances in telegram. It seems it can't get the ticker to calculate BTC. This error should be treated in the code and ignore the missing pairs.

### Relevant code exceptions or logs:

  ```
 2018-06-26 10:53:11,366 - freqtrade.rpc.telegram - INFO - Executing handler: _balance for chat_id: 537131708
2018-06-26 10:53:11,632 - freqtrade.exchange - INFO - returning cached ticker-data for ABT/BTC
2018-06-26 10:53:11,633 - freqtrade.exchange - INFO - returning cached ticker-data for BDG/BTC
2018-06-26 10:53:11,633 - freqtrade.exchange - INFO - returning cached ticker-data for BRD/BTC
2018-06-26 10:53:11,633 - freqtrade.exchange - INFO - returning cached ticker-data for CMT/BTC
2018-06-26 10:53:11,633 - freqtrade.exchange - INFO - returning cached ticker-data for DENT/BTC
2018-06-26 10:53:11,633 - freqtrade.exchange - INFO - returning cached ticker-data for DXT/BTC
2018-06-26 10:53:11,633 - freqtrade.exchange - INFO - returning cached ticker-data for ETH/BTC
2018-06-26 10:53:11,633 - freqtrade.exchange - INFO - returning cached ticker-data for FXT/BTC
2018-06-26 10:53:11,633 - freqtrade.exchange - WARNING - get_ticker() returned exception: "Could not load ticker history due to ExchangeError. Message: cobinhood No market symbol HQX/BTC"
2018-06-26 10:53:11,633 - freqtrade.exchange - WARNING - retrying get_ticker() still for 3 times
2018-06-26 10:53:11,633 - freqtrade.exchange - WARNING - get_ticker() returned exception: "Could not load ticker history due to ExchangeError. Message: cobinhood No market symbol HQX/BTC"
2018-06-26 10:53:11,633 - freqtrade.exchange - WARNING - retrying get_ticker() still for 2 times
2018-06-26 10:53:11,633 - freqtrade.exchange - WARNING - get_ticker() returned exception: "Could not load ticker history due to ExchangeError. Message: cobinhood No market symbol HQX/BTC"
2018-06-26 10:53:11,633 - freqtrade.exchange - WARNING - retrying get_ticker() still for 1 times
2018-06-26 10:53:11,633 - freqtrade.exchange - WARNING - get_ticker() returned exception: "Could not load ticker history due to ExchangeError. Message: cobinhood No market symbol HQX/BTC"
2018-06-26 10:53:11,633 - freqtrade.exchange - WARNING - retrying get_ticker() still for 0 times
2018-06-26 10:53:11,633 - freqtrade.exchange - WARNING - get_ticker() returned exception: "Could not load ticker history due to ExchangeError. Message: cobinhood No market symbol HQX/BTC"
2018-06-26 10:53:11,633 - freqtrade.exchange - WARNING - Giving up retrying: get_ticker()
2018-06-26 10:53:11,633 - freqtrade.rpc.telegram - ERROR - Exception occurred within Telegram module
Traceback (most recent call last):
  File "/freqtrade/freqtrade/exchange/__init__.py", line 261, in get_ticker
    data = self._api.fetch_ticker(pair)
  File "/usr/local/lib/python3.6/site-packages/ccxt/cobinhood.py", line 267, in fetch_ticker
    market = self.market(symbol)
  File "/usr/local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 1271, in market
    self.raise_error(ExchangeError, details='No market symbol ' + str(symbol))
  File "/usr/local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 290, in raise_error
    raise exception_type(output)
ccxt.base.errors.ExchangeError: cobinhood No market symbol HQX/BTC
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/freqtrade/freqtrade/exchange/__init__.py", line 32, in wrapper
    return f(*args, **kwargs)
  File "/freqtrade/freqtrade/exchange/__init__.py", line 272, in get_ticker
    f'Could not load ticker history due to {e.__class__.__name__}. Message: {e}')
freqtrade.TemporaryError: Could not load ticker history due to ExchangeError. Message: cobinhood No market symbol HQX/BTC
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/freqtrade/freqtrade/exchange/__init__.py", line 261, in get_ticker
    data = self._api.fetch_ticker(pair)
  File "/usr/local/lib/python3.6/site-packages/ccxt/cobinhood.py", line 267, in fetch_ticker
    market = self.market(symbol)
  File "/usr/local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 1271, in market
    self.raise_error(ExchangeError, details='No market symbol ' + str(symbol))
  File "/usr/local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 290, in raise_error
    raise exception_type(output)
ccxt.base.errors.ExchangeError: cobinhood No market symbol HQX/BTC
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/freqtrade/freqtrade/exchange/__init__.py", line 32, in wrapper
    return f(*args, **kwargs)
  File "/freqtrade/freqtrade/exchange/__init__.py", line 272, in get_ticker
    f'Could not load ticker history due to {e.__class__.__name__}. Message: {e}')
freqtrade.TemporaryError: Could not load ticker history due to ExchangeError. Message: cobinhood No market symbol HQX/BTC
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/freqtrade/freqtrade/exchange/__init__.py", line 261, in get_ticker
    data = self._api.fetch_ticker(pair)
  File "/usr/local/lib/python3.6/site-packages/ccxt/cobinhood.py", line 267, in fetch_ticker
    market = self.market(symbol)
  File "/usr/local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 1271, in market
    self.raise_error(ExchangeError, details='No market symbol ' + str(symbol))
  File "/usr/local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 290, in raise_error
    raise exception_type(output)
ccxt.base.errors.ExchangeError: cobinhood No market symbol HQX/BTC
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/freqtrade/freqtrade/exchange/__init__.py", line 32, in wrapper
    return f(*args, **kwargs)
  File "/freqtrade/freqtrade/exchange/__init__.py", line 272, in get_ticker
    f'Could not load ticker history due to {e.__class__.__name__}. Message: {e}')
freqtrade.TemporaryError: Could not load ticker history due to ExchangeError. Message: cobinhood No market symbol HQX/BTC
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/freqtrade/freqtrade/exchange/__init__.py", line 261, in get_ticker
    data = self._api.fetch_ticker(pair)
  File "/usr/local/lib/python3.6/site-packages/ccxt/cobinhood.py", line 267, in fetch_ticker
    market = self.market(symbol)
  File "/usr/local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 1271, in market
    self.raise_error(ExchangeError, details='No market symbol ' + str(symbol))
  File "/usr/local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 290, in raise_error
    raise exception_type(output)
ccxt.base.errors.ExchangeError: cobinhood No market symbol HQX/BTC
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/freqtrade/freqtrade/exchange/__init__.py", line 32, in wrapper
    return f(*args, **kwargs)
  File "/freqtrade/freqtrade/exchange/__init__.py", line 272, in get_ticker
    f'Could not load ticker history due to {e.__class__.__name__}. Message: {e}')
freqtrade.TemporaryError: Could not load ticker history due to ExchangeError. Message: cobinhood No market symbol HQX/BTC
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/freqtrade/freqtrade/exchange/__init__.py", line 261, in get_ticker
    data = self._api.fetch_ticker(pair)
  File "/usr/local/lib/python3.6/site-packages/ccxt/cobinhood.py", line 267, in fetch_ticker
    market = self.market(symbol)
  File "/usr/local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 1271, in market
    self.raise_error(ExchangeError, details='No market symbol ' + str(symbol))
  File "/usr/local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 290, in raise_error
    raise exception_type(output)
ccxt.base.errors.ExchangeError: cobinhood No market symbol HQX/BTC
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/freqtrade/freqtrade/rpc/telegram.py", line 48, in wrapper
    return command_handler(self, *args, **kwargs)
  File "/freqtrade/freqtrade/rpc/telegram.py", line 243, in _balance
    self._rpc_balance(self._config['fiat_display_currency'])
  File "/freqtrade/freqtrade/rpc/rpc.py", line 270, in _rpc_balance
    rate = self._freqtrade.exchange.get_ticker(coin + '/BTC', False)['bid']
  File "/freqtrade/freqtrade/exchange/__init__.py", line 39, in wrapper
    return wrapper(*args, **kwargs)
  File "/freqtrade/freqtrade/exchange/__init__.py", line 39, in wrapper
    return wrapper(*args, **kwargs)
  File "/freqtrade/freqtrade/exchange/__init__.py", line 39, in wrapper
    return wrapper(*args, **kwargs)
  File "/freqtrade/freqtrade/exchange/__init__.py", line 42, in wrapper
    raise ex
  File "/freqtrade/freqtrade/exchange/__init__.py", line 32, in wrapper
    return f(*args, **kwargs)
  File "/freqtrade/freqtrade/exchange/__init__.py", line 272, in get_ticker
    f'Could not load ticker history due to {e.__class__.__name__}. Message: {e}')
freqtrade.TemporaryError: Could not load ticker history due to ExchangeError. Message: cobinhood No market symbol HQX/BTC
  ```



Discussion:
To be honest, i'm not sure if this is related to `/get_balance` ... 

the message says `ccxt.base.errors.ExchangeError: cobinhood No market symbol HQX/BTC` ... 
please try to remove non-existing pairs from your config.
I had 2 HQX winned coins with no HQX/BTC pair. Sold them and issue solved at the moment, though the bot should treat this case as I think is not unique between the trade sites. Now I have another issue which seems to be from the bot:


2018-06-26 16:55:04,122 - freqtrade - ERROR - Fatal exception!
Traceback (most recent call last):
  File "/freqtrade/freqtrade/main.py", line 48, in main
    state = freqtrade.worker(old_state=state)
  File "/freqtrade/freqtrade/freqtradebot.py", line 111, in worker
    nb_assets=nb_assets)
  File "/freqtrade/freqtrade/freqtradebot.py", line 123, in _throttle
    result = func(*args, **kwargs)
  File "/freqtrade/freqtrade/freqtradebot.py", line 159, in _process
    state_changed = self.process_maybe_execute_buy()
  File "/freqtrade/freqtrade/freqtradebot.py", line 389, in process_maybe_execute_buy
    if self.create_trade():
  File "/freqtrade/freqtrade/freqtradebot.py", line 340, in create_trade
    min_stake_amount = self._get_min_pair_stake_amount(pair_s, buy_limit)
  File "/freqtrade/freqtrade/freqtradebot.py", line 294, in _get_min_pair_stake_amount
    return min(min_stake_amounts)/amount_reserve_percent
TypeError: '<' not supported between instances of 'float' and 'NoneType'
2018-06-26 16:55:04,123 - freqtrade.rpc.rpc_manager - INFO - Sending rpc message: *Status:* `Process died ...`


Can you check? Tks!
do you have stoploss configured in your strategy (as shown in the Default strategy):

https://github.com/freqtrade/freqtrade/blob/e1d8a59b69c9389e61e7dcd13573460178acb872/freqtrade/strategy/default_strategy.py#L26
Hi,

Yes I do. See my config.json:

{
    "max_open_trades": 3,
    "stake_currency": "ETH",
    "stake_amount": 0.03,
    "fiat_display_currency": "USD",
    "dry_run": false,
    "stoploss": -0.25,
    "unfilledtimeout": 5,
    "bid_strategy": {
        "ask_last_balance": 0.9
    },

just crashed again:
2018-06-27 14:45:00,316 - freqtrade.freqtradebot - INFO - Found no sell signals for whitelisted currencies. Trying again..
2018-06-27 14:45:00,571 - freqtrade.freqtradebot - INFO - Checking buy signals to create a new trade with stake_amount: 0.030000 ...
2018-06-27 14:45:04,761 - freqtrade - ERROR - Fatal exception!
Traceback (most recent call last):
  File "/freqtrade/freqtrade/main.py", line 48, in main
    state = freqtrade.worker(old_state=state)
  File "/freqtrade/freqtrade/freqtradebot.py", line 111, in worker
    nb_assets=nb_assets)
  File "/freqtrade/freqtrade/freqtradebot.py", line 123, in _throttle
    result = func(*args, **kwargs)
  File "/freqtrade/freqtrade/freqtradebot.py", line 159, in _process
    state_changed = self.process_maybe_execute_buy()
  File "/freqtrade/freqtrade/freqtradebot.py", line 389, in process_maybe_execute_buy
    if self.create_trade():
  File "/freqtrade/freqtrade/freqtradebot.py", line 340, in create_trade
    min_stake_amount = self._get_min_pair_stake_amount(pair_s, buy_limit)
  File "/freqtrade/freqtrade/freqtradebot.py", line 294, in _get_min_pair_stake_amount
    return min(min_stake_amounts)/amount_reserve_percent
TypeError: '<' not supported between instances of 'float' and 'NoneType'
2018-06-27 14:45:04,762 - freqtrade.rpc.rpc_manager - INFO - Sending rpc message: *Status:* `Process died ...`
does this happen on every buy - or does it work "sometimes" - but not others?

It happen with every buy signal. Used to work in the past.

Resolving patch:
diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py
--- a/freqtrade/freqtradebot.py
+++ b/freqtrade/freqtradebot.py
@@ -277,11 +277,14 @@ def _get_min_pair_stake_amount(self, pair: str, price: float) -> Optional[float]
             return None
 
         min_stake_amounts = []
-        if 'cost' in market['limits'] and 'min' in market['limits']['cost']:
-            min_stake_amounts.append(market['limits']['cost']['min'])
-
-        if 'amount' in market['limits'] and 'min' in market['limits']['amount']:
-            min_stake_amounts.append(market['limits']['amount']['min'] * price)
+        limits = market['limits']
+        if ('cost' in limits and 'min' in limits['cost']
+                and limits['cost']['min'] is not None):
+            min_stake_amounts.append(limits['cost']['min'])
+
+        if ('amount' in limits and 'min' in limits['amount']
+                and limits['amount']['min'] is not None):
+            min_stake_amounts.append(limits['amount']['min'] * price)
 
         if not min_stake_amounts:
             return None


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
@@ -348,6 +348,34 @@ def test_get_min_pair_stake_amount(mocker, default_conf) -> None:
     result = freqtrade._get_min_pair_stake_amount('ETH/BTC', 1)
     assert result is None
 
+    # no cost Min
+    mocker.patch(
+        'freqtrade.exchange.Exchange.get_markets',
+        MagicMock(return_value=[{
+            'symbol': 'ETH/BTC',
+            'limits': {
+                'cost': {"min": None},
+                'amount': {}
+            }
+        }])
+    )
+    result = freqtrade._get_min_pair_stake_amount('ETH/BTC', 1)
+    assert result is None
+
+    # no amount Min
+    mocker.patch(
+        'freqtrade.exchange.Exchange.get_markets',
+        MagicMock(return_value=[{
+            'symbol': 'ETH/BTC',
+            'limits': {
+                'cost': {},
+                'amount': {"min": None}
+            }
+        }])
+    )
+    result = freqtrade._get_min_pair_stake_amount('ETH/BTC', 1)
+    assert result is None
+
     # empty 'cost'/'amount' section
     mocker.patch(
         'freqtrade.exchange.Exchange.get_markets',