Implement *candle definitions
This commit is contained in:
@@ -170,7 +170,7 @@ def _validate_protections(conf: Dict[str, Any]) -> None:
|
||||
f"Please fix the protection {prot.get('method')}"
|
||||
)
|
||||
|
||||
if ('lookback_period' in prot and 'lookback_period_candle' in prot):
|
||||
if ('lookback_period' in prot and 'lookback_period_candles' in prot):
|
||||
raise OperationalException(
|
||||
"Protections must specify either `lookback_period` or `lookback_period_candles`.\n"
|
||||
f"Please fix the protection {prot.get('method')}"
|
||||
|
@@ -4,6 +4,7 @@ from abc import ABC, abstractmethod
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
from freqtrade.exchange import timeframe_to_minutes
|
||||
from freqtrade.mixins import LoggingMixin
|
||||
from freqtrade.persistence import Trade
|
||||
|
||||
@@ -23,8 +24,15 @@ 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
|
||||
self._stop_duration = protection_config.get('stop_duration', 60)
|
||||
self._lookback_period = protection_config.get('lookback_period', 60)
|
||||
tf_in_min = timeframe_to_minutes(config['timeframe'])
|
||||
if 'stop_duration_candles' in protection_config:
|
||||
self._stop_duration = (tf_in_min * protection_config.get('stop_duration_candles'))
|
||||
else:
|
||||
self._stop_duration = protection_config.get('stop_duration', 60)
|
||||
if 'lookback_period_candles' in protection_config:
|
||||
self._lookback_period = tf_in_min * protection_config.get('lookback_period_candles', 60)
|
||||
else:
|
||||
self._lookback_period = protection_config.get('lookback_period', 60)
|
||||
|
||||
LoggingMixin.__init__(self, logger)
|
||||
|
||||
|
Reference in New Issue
Block a user