Improve protections work
This commit is contained in:
@@ -4,15 +4,18 @@ from abc import ABC, abstractmethod
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict
|
||||
|
||||
from freqtrade.mixins import LoggingMixin
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class IProtection(ABC):
|
||||
class IProtection(LoggingMixin, ABC):
|
||||
|
||||
def __init__(self, config: Dict[str, Any], protection_config: Dict[str, Any]) -> None:
|
||||
self._config = config
|
||||
self._protection_config = protection_config
|
||||
LoggingMixin.__init__(self, logger)
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
|
@@ -3,7 +3,7 @@ import logging
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Any, Dict
|
||||
|
||||
from sqlalchemy import or_, and_
|
||||
from sqlalchemy import and_, or_
|
||||
|
||||
from freqtrade.persistence import Trade
|
||||
from freqtrade.plugins.protections import IProtection
|
||||
@@ -42,7 +42,9 @@ class StoplossGuard(IProtection):
|
||||
filters.append(Trade.pair == pair)
|
||||
trades = Trade.get_trades(filters).all()
|
||||
|
||||
if len(trades) > self.trade_limit:
|
||||
if len(trades) > self._trade_limit:
|
||||
self.log_on_refresh(logger.info, f"Trading stopped due to {self._trade_limit} "
|
||||
f"stoplosses within {self._lookback_period} minutes.")
|
||||
return True
|
||||
|
||||
return False
|
||||
|
Reference in New Issue
Block a user