Convert ExchangeResolver to static loader class
This commit is contained in:
@@ -15,9 +15,8 @@ class ExchangeResolver(IResolver):
|
||||
This class contains all the logic to load a custom exchange class
|
||||
"""
|
||||
|
||||
__slots__ = ['exchange']
|
||||
|
||||
def __init__(self, exchange_name: str, config: dict, validate: bool = True) -> None:
|
||||
@staticmethod
|
||||
def load_exchange(exchange_name: str, config: dict, validate: bool = True) -> Exchange:
|
||||
"""
|
||||
Load the custom class from config parameter
|
||||
:param config: configuration dictionary
|
||||
@@ -25,17 +24,20 @@ class ExchangeResolver(IResolver):
|
||||
# Map exchange name to avoid duplicate classes for identical exchanges
|
||||
exchange_name = MAP_EXCHANGE_CHILDCLASS.get(exchange_name, exchange_name)
|
||||
exchange_name = exchange_name.title()
|
||||
exchange = None
|
||||
try:
|
||||
self.exchange = self._load_exchange(exchange_name, kwargs={'config': config,
|
||||
'validate': validate})
|
||||
exchange = ExchangeResolver._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, validate=validate)
|
||||
if not exchange:
|
||||
exchange = Exchange(config, validate=validate)
|
||||
return exchange
|
||||
|
||||
def _load_exchange(
|
||||
self, exchange_name: str, kwargs: dict) -> Exchange:
|
||||
@staticmethod
|
||||
def _load_exchange(exchange_name: str, kwargs: dict) -> Exchange:
|
||||
"""
|
||||
Loads the specified exchange.
|
||||
Only checks for exchanges exported in freqtrade.exchanges
|
||||
|
@@ -18,8 +18,6 @@ class PairListResolver(IResolver):
|
||||
This class contains all the logic to load custom PairList class
|
||||
"""
|
||||
|
||||
__slots__ = []
|
||||
|
||||
@staticmethod
|
||||
def load_pairlist(pairlist_name: str, exchange, pairlistmanager,
|
||||
config: dict, pairlistconfig: dict, pairlist_pos: int) -> IPairList:
|
||||
@@ -41,7 +39,6 @@ class PairListResolver(IResolver):
|
||||
'pairlistconfig': pairlistconfig,
|
||||
'pairlist_pos': pairlist_pos})
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _load_pairlist(pairlist_name: str, config: dict, kwargs: dict) -> IPairList:
|
||||
"""
|
||||
|
Reference in New Issue
Block a user