diff --git a/docs/developer.md b/docs/developer.md index 127e8e5d5..401de07c1 100644 --- a/docs/developer.md +++ b/docs/developer.md @@ -241,7 +241,6 @@ No protection should use datetime directly, but use the provided `date_now` vari !!! Tip "Writing a new Protection" Best copy one of the existing Protections to have a good example. - Don't forget to register your protection in `constants.py` under the variable `AVAILABLE_PROTECTIONS` - otherwise it will not be selectable. #### Implementation of a new protection diff --git a/freqtrade/constants.py b/freqtrade/constants.py index 120f463f3..f1c44d204 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -57,7 +57,6 @@ AVAILABLE_PAIRLISTS = [ "SpreadFilter", "VolatilityFilter", ] -AVAILABLE_PROTECTIONS = ["CooldownPeriod", "LowProfitPairs", "MaxDrawdown", "StoplossGuard"] AVAILABLE_DATAHANDLERS = ["json", "jsongz", "hdf5", "feather", "parquet"] BACKTEST_BREAKDOWNS = ["day", "week", "month"] BACKTEST_CACHE_AGE = ["none", "day", "week", "month"] diff --git a/tests/plugins/test_protections.py b/tests/plugins/test_protections.py index 85c03f4fc..bec2671eb 100644 --- a/tests/plugins/test_protections.py +++ b/tests/plugins/test_protections.py @@ -3,7 +3,6 @@ from datetime import datetime, timedelta, timezone import pytest -from freqtrade import constants from freqtrade.enums import ExitType from freqtrade.exceptions import OperationalException from freqtrade.persistence import PairLocks, Trade @@ -12,6 +11,9 @@ from freqtrade.plugins.protectionmanager import ProtectionManager from tests.conftest import get_patched_freqtradebot, log_has_re +AVAILABLE_PROTECTIONS = ["CooldownPeriod", "LowProfitPairs", "MaxDrawdown", "StoplossGuard"] + + def generate_mock_trade( pair: str, fee: float, @@ -90,12 +92,12 @@ def generate_mock_trade( def test_protectionmanager(mocker, default_conf): default_conf["_strategy_protections"] = [ - {"method": protection} for protection in constants.AVAILABLE_PROTECTIONS + {"method": protection} for protection in AVAILABLE_PROTECTIONS ] freqtrade = get_patched_freqtradebot(mocker, default_conf) for handler in freqtrade.protections._protection_handlers: - assert handler.name in constants.AVAILABLE_PROTECTIONS + assert handler.name in AVAILABLE_PROTECTIONS if not handler.has_global_stop: assert handler.global_stop(datetime.now(timezone.utc), "*") is None if not handler.has_local_stop: