Check if timeframes is available and fail gracefully otherwise

This commit is contained in:
Matthias 2019-06-30 20:30:31 +02:00
parent cdeb649d0b
commit 0c7d14fe50
2 changed files with 8 additions and 0 deletions

View File

@ -269,6 +269,13 @@ class Exchange(object):
"""
Checks if ticker interval from config is a supported timeframe on the exchange
"""
logger.warning("validate_timerames")
if not hasattr(self._api, "timeframes"):
# If timeframes is missing, the exchange probably has no fetchOHLCV method.
# Therefore we also show that.
raise OperationalException(
f"This exchange ({self.name}) does not have a `timeframes` attribute and "
f"is therefore not supported. fetchOHLCV: {self.exchange_has('fetchOHLCV')}")
timeframes = self._api.timeframes
if timeframe not in timeframes:
raise OperationalException(

View File

@ -28,6 +28,7 @@ class ExchangeResolver(IResolver):
except ImportError:
logger.info(
f"No {exchange_name} specific subclass found. Using the generic class instead.")
if not hasattr(self, "exchange"):
self.exchange = Exchange(config)
def _load_exchange(