use local config-object for check_exchange
fix AttributeError: 'NoneType' object has no attribute 'get' when starting the bot.
This commit is contained in:
parent
5420bb9f6d
commit
0203a48f3e
@ -102,7 +102,7 @@ class Configuration(object):
|
|||||||
self.logger.info('Dry run is disabled. (--dry_run_db ignored)')
|
self.logger.info('Dry run is disabled. (--dry_run_db ignored)')
|
||||||
|
|
||||||
# Check if the exchange set by the user is supported
|
# Check if the exchange set by the user is supported
|
||||||
self.check_exchange()
|
self.check_exchange(config)
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@ -203,12 +203,12 @@ class Configuration(object):
|
|||||||
|
|
||||||
return self.config
|
return self.config
|
||||||
|
|
||||||
def check_exchange(self) -> bool:
|
def check_exchange(self, config: Dict[str, Any]) -> bool:
|
||||||
"""
|
"""
|
||||||
Check if the exchange name in the config file is supported by Freqtrade
|
Check if the exchange name in the config file is supported by Freqtrade
|
||||||
:return: True or raised an exception if the exchange if not supported
|
:return: True or raised an exception if the exchange if not supported
|
||||||
"""
|
"""
|
||||||
exchange = self.config.get('exchange', {}).get('name').lower()
|
exchange = config.get('exchange', {}).get('name').lower()
|
||||||
if exchange not in ccxt.exchanges:
|
if exchange not in ccxt.exchanges:
|
||||||
|
|
||||||
exception_msg = 'Exchange "{}" not supported.\n' \
|
exception_msg = 'Exchange "{}" not supported.\n' \
|
||||||
|
@ -326,13 +326,11 @@ def test_check_exchange(default_conf) -> None:
|
|||||||
|
|
||||||
# Test a valid exchange
|
# Test a valid exchange
|
||||||
conf.get('exchange').update({'name': 'BITTREX'})
|
conf.get('exchange').update({'name': 'BITTREX'})
|
||||||
configuration.config = conf
|
assert configuration.check_exchange(conf)
|
||||||
assert configuration.check_exchange()
|
|
||||||
|
|
||||||
# Test a valid exchange
|
# Test a valid exchange
|
||||||
conf.get('exchange').update({'name': 'binance'})
|
conf.get('exchange').update({'name': 'binance'})
|
||||||
configuration.config = conf
|
assert configuration.check_exchange(conf)
|
||||||
assert configuration.check_exchange()
|
|
||||||
|
|
||||||
# Test a invalid exchange
|
# Test a invalid exchange
|
||||||
conf.get('exchange').update({'name': 'unknown_exchange'})
|
conf.get('exchange').update({'name': 'unknown_exchange'})
|
||||||
@ -342,4 +340,4 @@ def test_check_exchange(default_conf) -> None:
|
|||||||
OperationalException,
|
OperationalException,
|
||||||
match=r'.*Exchange "unknown_exchange" not supported.*'
|
match=r'.*Exchange "unknown_exchange" not supported.*'
|
||||||
):
|
):
|
||||||
configuration.check_exchange()
|
configuration.check_exchange(conf)
|
||||||
|
Loading…
Reference in New Issue
Block a user