Add first version of protection manager

This commit is contained in:
Matthias
2020-10-13 08:06:29 +02:00
parent b6b9c8e5cc
commit a0bd2ce837
6 changed files with 122 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ from freqtrade.resolvers.exchange_resolver import ExchangeResolver
# Don't import HyperoptResolver to avoid loading the whole Optimize tree
# from freqtrade.resolvers.hyperopt_resolver import HyperOptResolver
from freqtrade.resolvers.pairlist_resolver import PairListResolver
from freqtrade.resolvers.protection_resolver import ProtectionResolver
from freqtrade.resolvers.strategy_resolver import StrategyResolver

View File

@@ -0,0 +1,44 @@
# pragma pylint: disable=attribute-defined-outside-init
"""
This module load custom pairlists
"""
import logging
from pathlib import Path
from typing import Dict
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
"""
object_type = IProtection
object_type_str = "Protection"
user_subdir = None
initial_search_path = Path(__file__).parent.parent.joinpath('plugins/protections').resolve()
@staticmethod
def load_protection(protection_name: str, exchange, protectionmanager,
config: Dict, protection_config: Dict) -> IProtection:
"""
Load the protection with protection_name
:param protection_name: Classname of the pairlist
:param exchange: Initialized exchange class
:param protectionmanager: Initialized protection manager
:param config: configuration dictionary
:param protection_config: Configuration dedicated to this pairlist
:return: initialized Protection class
"""
return ProtectionResolver.load_object(protection_name, config,
kwargs={'exchange': exchange,
'pairlistmanager': protectionmanager,
'config': config,
'pairlistconfig': protection_config,
},
)