2020-10-13 06:06:29 +00:00
|
|
|
|
|
|
|
import logging
|
|
|
|
from abc import ABC, abstractmethod
|
2020-10-14 05:40:44 +00:00
|
|
|
from datetime import datetime
|
2020-10-13 06:06:29 +00:00
|
|
|
from typing import Any, Dict
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class IProtection(ABC):
|
|
|
|
|
2020-10-14 05:40:44 +00:00
|
|
|
def __init__(self, config: Dict[str, Any], protection_config: Dict[str, Any]) -> None:
|
2020-10-13 06:06:29 +00:00
|
|
|
self._config = config
|
2020-10-14 05:40:44 +00:00
|
|
|
self._protection_config = protection_config
|
2020-10-13 06:06:29 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def name(self) -> str:
|
|
|
|
return self.__class__.__name__
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def short_desc(self) -> str:
|
|
|
|
"""
|
|
|
|
Short method description - used for startup-messages
|
|
|
|
-> Please overwrite in subclasses
|
|
|
|
"""
|
2020-10-14 05:40:44 +00:00
|
|
|
|
|
|
|
@abstractmethod
|
2020-10-14 18:03:56 +00:00
|
|
|
def global_stop(self, date_now: datetime) -> bool:
|
2020-10-14 05:40:44 +00:00
|
|
|
"""
|
|
|
|
Stops trading (position entering) for all pairs
|
|
|
|
This must evaluate to true for the whole period of the "cooldown period".
|
|
|
|
"""
|