Merge branch 'develop' into feat/new_args_system

This commit is contained in:
hroff-1902
2019-10-23 22:45:06 +03:00
committed by GitHub
20 changed files with 785 additions and 73 deletions

View File

@@ -17,7 +17,7 @@ class ExchangeResolver(IResolver):
__slots__ = ['exchange']
def __init__(self, exchange_name: str, config: dict) -> None:
def __init__(self, exchange_name: str, config: dict, validate: bool = True) -> None:
"""
Load the custom class from config parameter
:param config: configuration dictionary
@@ -26,12 +26,13 @@ class ExchangeResolver(IResolver):
exchange_name = MAP_EXCHANGE_CHILDCLASS.get(exchange_name, exchange_name)
exchange_name = exchange_name.title()
try:
self.exchange = self._load_exchange(exchange_name, kwargs={'config': config})
self.exchange = self._load_exchange(exchange_name, kwargs={'config': config,
'validate': validate})
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)
self.exchange = Exchange(config, validate=validate)
def _load_exchange(
self, exchange_name: str, kwargs: dict) -> Exchange:
@@ -45,7 +46,7 @@ class ExchangeResolver(IResolver):
try:
ex_class = getattr(exchanges, exchange_name)
exchange = ex_class(kwargs['config'])
exchange = ex_class(**kwargs)
if exchange:
logger.info(f"Using resolved exchange '{exchange_name}'...")
return exchange