Combine load_object methods into one
This commit is contained in:
@@ -6,7 +6,6 @@ This module load custom pairlists
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from freqtrade import OperationalException
|
||||
from freqtrade.pairlist.IPairList import IPairList
|
||||
from freqtrade.resolvers import IResolver
|
||||
|
||||
@@ -18,6 +17,9 @@ class PairListResolver(IResolver):
|
||||
This class contains all the logic to load custom PairList class
|
||||
"""
|
||||
object_type = IPairList
|
||||
object_type_str = "Pairlist"
|
||||
user_subdir = None
|
||||
initial_search_path = Path(__file__).parent.parent.joinpath('pairlist').resolve()
|
||||
|
||||
@staticmethod
|
||||
def load_pairlist(pairlist_name: str, exchange, pairlistmanager,
|
||||
@@ -32,34 +34,10 @@ class PairListResolver(IResolver):
|
||||
:param pairlist_pos: Position of the pairlist in the list of pairlists
|
||||
:return: initialized Pairlist class
|
||||
"""
|
||||
|
||||
return PairListResolver._load_pairlist(pairlist_name, config,
|
||||
kwargs={'exchange': exchange,
|
||||
'pairlistmanager': pairlistmanager,
|
||||
'config': config,
|
||||
'pairlistconfig': pairlistconfig,
|
||||
'pairlist_pos': pairlist_pos})
|
||||
|
||||
@staticmethod
|
||||
def _load_pairlist(pairlist_name: str, config: dict, kwargs: dict) -> IPairList:
|
||||
"""
|
||||
Search and loads the specified pairlist.
|
||||
:param pairlist_name: name of the module to import
|
||||
:param config: configuration dictionary
|
||||
:param extra_dir: additional directory to search for the given pairlist
|
||||
:return: PairList instance or None
|
||||
"""
|
||||
current_path = Path(__file__).parent.parent.joinpath('pairlist').resolve()
|
||||
|
||||
abs_paths = IResolver.build_search_paths(config, current_path=current_path,
|
||||
user_subdir=None, extra_dir=None)
|
||||
|
||||
pairlist = PairListResolver._load_object(paths=abs_paths,
|
||||
object_name=pairlist_name,
|
||||
kwargs=kwargs)
|
||||
if pairlist:
|
||||
return pairlist
|
||||
raise OperationalException(
|
||||
f"Impossible to load Pairlist '{pairlist_name}'. This class does not exist "
|
||||
"or contains Python code errors."
|
||||
)
|
||||
return PairListResolver.load_object(pairlist_name, config,
|
||||
kwargs={'exchange': exchange,
|
||||
'pairlistmanager': pairlistmanager,
|
||||
'config': config,
|
||||
'pairlistconfig': pairlistconfig,
|
||||
'pairlist_pos': pairlist_pos},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user