From eb952d77be2c9eaff24cab9d42a5111d28fefd13 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 7 Dec 2020 08:27:14 +0100 Subject: [PATCH] Move lookback_period to parent __init__ --- docs/includes/protections.md | 2 ++ freqtrade/plugins/protections/iprotection.py | 1 + freqtrade/plugins/protections/low_profit_pairs.py | 1 - freqtrade/plugins/protections/max_drawdown_protection.py | 1 - freqtrade/plugins/protections/stoploss_guard.py | 1 - 5 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/includes/protections.md b/docs/includes/protections.md index f5639565f..25d59a992 100644 --- a/docs/includes/protections.md +++ b/docs/includes/protections.md @@ -21,8 +21,10 @@ All protection end times are rounded up to the next candle to avoid sudden, unex ### Common settings to all Protections +* `method` - Protection name to use. * `stop_duration` (minutes) - how long should protections be locked. * `lookback_period` (minutes) - Only trades that completed after `current_time - lookback_period` will be considered (may be ignored by some Protections). +* `trade_limit` - How many trades are required at minimum (not used by all Protections). #### Stoploss Guard diff --git a/freqtrade/plugins/protections/iprotection.py b/freqtrade/plugins/protections/iprotection.py index 2053ae741..60f83eea6 100644 --- a/freqtrade/plugins/protections/iprotection.py +++ b/freqtrade/plugins/protections/iprotection.py @@ -24,6 +24,7 @@ class IProtection(LoggingMixin, ABC): 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) LoggingMixin.__init__(self, logger) diff --git a/freqtrade/plugins/protections/low_profit_pairs.py b/freqtrade/plugins/protections/low_profit_pairs.py index 515f81521..70ef5b080 100644 --- a/freqtrade/plugins/protections/low_profit_pairs.py +++ b/freqtrade/plugins/protections/low_profit_pairs.py @@ -18,7 +18,6 @@ class LowProfitPairs(IProtection): def __init__(self, config: Dict[str, Any], protection_config: Dict[str, Any]) -> None: super().__init__(config, protection_config) - self._lookback_period = protection_config.get('lookback_period', 60) self._trade_limit = protection_config.get('trade_limit', 1) self._required_profit = protection_config.get('required_profit', 0.0) diff --git a/freqtrade/plugins/protections/max_drawdown_protection.py b/freqtrade/plugins/protections/max_drawdown_protection.py index e5625733c..2a83cdeba 100644 --- a/freqtrade/plugins/protections/max_drawdown_protection.py +++ b/freqtrade/plugins/protections/max_drawdown_protection.py @@ -21,7 +21,6 @@ class MaxDrawdown(IProtection): def __init__(self, config: Dict[str, Any], protection_config: Dict[str, Any]) -> None: super().__init__(config, protection_config) - self._lookback_period = protection_config.get('lookback_period', 60) self._trade_limit = protection_config.get('trade_limit', 1) self._max_allowed_drawdown = protection_config.get('max_allowed_drawdown', 0.0) # TODO: Implement checks to limit max_drawdown to sensible values diff --git a/freqtrade/plugins/protections/stoploss_guard.py b/freqtrade/plugins/protections/stoploss_guard.py index b6f430085..520607337 100644 --- a/freqtrade/plugins/protections/stoploss_guard.py +++ b/freqtrade/plugins/protections/stoploss_guard.py @@ -21,7 +21,6 @@ class StoplossGuard(IProtection): def __init__(self, config: Dict[str, Any], protection_config: Dict[str, Any]) -> None: super().__init__(config, protection_config) - self._lookback_period = protection_config.get('lookback_period', 60) self._trade_limit = protection_config.get('trade_limit', 10) self._disable_global_stop = protection_config.get('only_per_pair', False)