freqtrade_origin/freqtrade/resolvers/pairlist_resolver.py

58 lines
1.6 KiB
Python
Raw Normal View History

2018-12-05 19:44:56 +00:00
# pragma pylint: disable=attribute-defined-outside-init
"""
This module load custom pairlists
2018-12-05 19:44:56 +00:00
"""
2024-05-12 14:21:12 +00:00
2018-12-05 19:44:56 +00:00
import logging
from pathlib import Path
2022-09-18 11:31:52 +00:00
from freqtrade.constants import Config
from freqtrade.plugins.pairlist.IPairList import IPairList
2018-12-05 19:44:56 +00:00
from freqtrade.resolvers import IResolver
2020-09-28 17:39:41 +00:00
2018-12-05 19:44:56 +00:00
logger = logging.getLogger(__name__)
class PairListResolver(IResolver):
"""
This class contains all the logic to load custom PairList class
2018-12-05 19:44:56 +00:00
"""
2024-05-12 14:21:12 +00:00
2019-12-24 12:34:37 +00:00
object_type = IPairList
2019-12-24 12:54:46 +00:00
object_type_str = "Pairlist"
user_subdir = None
2024-05-12 14:21:12 +00:00
initial_search_path = Path(__file__).parent.parent.joinpath("plugins/pairlist").resolve()
2018-12-05 19:44:56 +00:00
@staticmethod
2024-05-12 14:21:12 +00:00
def load_pairlist(
pairlist_name: str,
exchange,
pairlistmanager,
config: Config,
pairlistconfig: dict,
pairlist_pos: int,
) -> IPairList:
2018-12-05 19:44:56 +00:00
"""
Load the pairlist with pairlist_name
:param pairlist_name: Classname of the pairlist
:param exchange: Initialized exchange class
:param pairlistmanager: Initialized pairlist manager
:param config: configuration dictionary
:param pairlistconfig: Configuration dedicated to this pairlist
:param pairlist_pos: Position of the pairlist in the list of pairlists
:return: initialized Pairlist class
2018-12-05 19:44:56 +00:00
"""
2024-05-12 14:21:12 +00:00
return PairListResolver.load_object(
pairlist_name,
config,
kwargs={
"exchange": exchange,
"pairlistmanager": pairlistmanager,
"config": config,
"pairlistconfig": pairlistconfig,
"pairlist_pos": pairlist_pos,
},
)