diff --git a/docs/developer.md b/docs/developer.md index 6ea641edd..05b518184 100644 --- a/docs/developer.md +++ b/docs/developer.md @@ -94,6 +94,8 @@ Below is an outline of exception inheritance hierarchy: +---+ StrategyError ``` +--- + ## Plugins ### Pairlists @@ -203,6 +205,8 @@ The `until` portion should be calculated using the provided `calculate_lock_end( All Protections should use `"stop_duration"` to define how long a a pair (or all pairs) should be locked. The content of this is made available as `self._stop_duration` to the each Protection. +If your protection requires a look-back period, please use `"lookback_period"` to keep different protections aligned. + #### Global vs. local stops Protections can have 2 different ways to stop trading for a limited : @@ -221,6 +225,13 @@ These Protections should do their evaluation across all pairs, and consequently Global protection must set `has_global_stop=True` to be evaluated for global stops. The method `global_stop()` will be called whenever a trade closed (sell order completed). +##### Protections - calculating lock end time + +Protections should calculate the lock end time based on the last trade it considers. +This avoids relocking should the lookback-period be longer than the actual lock period. + +--- + ## Implement a new Exchange (WIP) !!! Note diff --git a/freqtrade/constants.py b/freqtrade/constants.py index bc8acc8b3..add9aae95 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -204,8 +204,8 @@ CONF_SCHEMA = { 'properties': { 'method': {'type': 'string', 'enum': AVAILABLE_PROTECTIONS}, 'stop_duration': {'type': 'number', 'minimum': 0.0}, - 'trade_limit': {'type': 'number', 'integer': 1}, - 'lookback_period': {'type': 'number', 'integer': 1}, + 'trade_limit': {'type': 'number', 'minimum': 1}, + 'lookback_period': {'type': 'number', 'minimum': 1}, }, 'required': ['method'], } diff --git a/tests/plugins/test_protections.py b/tests/plugins/test_protections.py index 7eac737ef..24594c3ac 100644 --- a/tests/plugins/test_protections.py +++ b/tests/plugins/test_protections.py @@ -54,6 +54,7 @@ def test_stoploss_guard(mocker, default_conf, fee, caplog): default_conf['protections'] = [{ "method": "StoplossGuard", "lookback_period": 60, + "stop_duration": 40, "trade_limit": 2 }] freqtrade = get_patched_freqtradebot(mocker, default_conf)