From ac3285003487d14542827152f491d35bda054d33 Mon Sep 17 00:00:00 2001 From: xsmile <> Date: Sat, 7 Oct 2017 17:38:33 +0200 Subject: [PATCH] simplify exchange initialization --- freqtrade/exchange.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/freqtrade/exchange.py b/freqtrade/exchange.py index 35db8469d..fa25b5bf5 100644 --- a/freqtrade/exchange.py +++ b/freqtrade/exchange.py @@ -37,15 +37,12 @@ def init(config: dict) -> None: logger.info('Instance is running with dry_run enabled') exchange_config = config['exchange'] - name = exchange_config['name'] # Find matching class for the given exchange name - exchange_class = None - for exchange in Exchanges: - if name.upper() == exchange.name: - exchange_class = exchange.value - break - if not exchange_class: + name = exchange_config['name'] + try: + exchange_class = Exchanges[name.upper()].value + except KeyError: raise RuntimeError('Exchange {} is not supported'.format(name)) EXCHANGE = exchange_class(exchange_config)