2020-10-13 06:06:29 +00:00
|
|
|
"""
|
|
|
|
This module load custom pairlists
|
|
|
|
"""
|
2024-05-12 14:21:12 +00:00
|
|
|
|
2020-10-13 06:06:29 +00:00
|
|
|
import logging
|
|
|
|
from pathlib import Path
|
|
|
|
|
2022-09-18 11:31:52 +00:00
|
|
|
from freqtrade.constants import Config
|
2020-10-13 06:06:29 +00:00
|
|
|
from freqtrade.plugins.protections import IProtection
|
|
|
|
from freqtrade.resolvers import IResolver
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class ProtectionResolver(IResolver):
|
|
|
|
"""
|
|
|
|
This class contains all the logic to load custom PairList class
|
|
|
|
"""
|
2024-05-12 14:21:12 +00:00
|
|
|
|
2020-10-13 06:06:29 +00:00
|
|
|
object_type = IProtection
|
|
|
|
object_type_str = "Protection"
|
|
|
|
user_subdir = None
|
2024-05-12 14:21:12 +00:00
|
|
|
initial_search_path = Path(__file__).parent.parent.joinpath("plugins/protections").resolve()
|
2020-10-13 06:06:29 +00:00
|
|
|
|
|
|
|
@staticmethod
|
2024-05-12 14:21:12 +00:00
|
|
|
def load_protection(
|
2024-10-04 05:02:57 +00:00
|
|
|
protection_name: str, config: Config, protection_config: dict
|
2024-05-12 14:21:12 +00:00
|
|
|
) -> IProtection:
|
2020-10-13 06:06:29 +00:00
|
|
|
"""
|
|
|
|
Load the protection with protection_name
|
|
|
|
:param protection_name: Classname of the pairlist
|
|
|
|
:param config: configuration dictionary
|
|
|
|
:param protection_config: Configuration dedicated to this pairlist
|
|
|
|
:return: initialized Protection class
|
|
|
|
"""
|
2024-05-12 14:21:12 +00:00
|
|
|
return ProtectionResolver.load_object(
|
|
|
|
protection_name,
|
|
|
|
config,
|
|
|
|
kwargs={
|
|
|
|
"config": config,
|
|
|
|
"protection_config": protection_config,
|
|
|
|
},
|
|
|
|
)
|