mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-14 20:23:57 +00:00
chore: move available_protections constant to test file (it's only used there)
This commit is contained in:
parent
39c582dac2
commit
f77fedbea4
|
@ -241,7 +241,6 @@ No protection should use datetime directly, but use the provided `date_now` vari
|
||||||
|
|
||||||
!!! Tip "Writing a new Protection"
|
!!! Tip "Writing a new Protection"
|
||||||
Best copy one of the existing Protections to have a good example.
|
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
|
#### Implementation of a new protection
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ AVAILABLE_PAIRLISTS = [
|
||||||
"SpreadFilter",
|
"SpreadFilter",
|
||||||
"VolatilityFilter",
|
"VolatilityFilter",
|
||||||
]
|
]
|
||||||
AVAILABLE_PROTECTIONS = ["CooldownPeriod", "LowProfitPairs", "MaxDrawdown", "StoplossGuard"]
|
|
||||||
AVAILABLE_DATAHANDLERS = ["json", "jsongz", "hdf5", "feather", "parquet"]
|
AVAILABLE_DATAHANDLERS = ["json", "jsongz", "hdf5", "feather", "parquet"]
|
||||||
BACKTEST_BREAKDOWNS = ["day", "week", "month"]
|
BACKTEST_BREAKDOWNS = ["day", "week", "month"]
|
||||||
BACKTEST_CACHE_AGE = ["none", "day", "week", "month"]
|
BACKTEST_CACHE_AGE = ["none", "day", "week", "month"]
|
||||||
|
|
|
@ -3,7 +3,6 @@ from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from freqtrade import constants
|
|
||||||
from freqtrade.enums import ExitType
|
from freqtrade.enums import ExitType
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.persistence import PairLocks, Trade
|
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
|
from tests.conftest import get_patched_freqtradebot, log_has_re
|
||||||
|
|
||||||
|
|
||||||
|
AVAILABLE_PROTECTIONS = ["CooldownPeriod", "LowProfitPairs", "MaxDrawdown", "StoplossGuard"]
|
||||||
|
|
||||||
|
|
||||||
def generate_mock_trade(
|
def generate_mock_trade(
|
||||||
pair: str,
|
pair: str,
|
||||||
fee: float,
|
fee: float,
|
||||||
|
@ -90,12 +92,12 @@ def generate_mock_trade(
|
||||||
|
|
||||||
def test_protectionmanager(mocker, default_conf):
|
def test_protectionmanager(mocker, default_conf):
|
||||||
default_conf["_strategy_protections"] = [
|
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)
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
|
|
||||||
for handler in freqtrade.protections._protection_handlers:
|
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:
|
if not handler.has_global_stop:
|
||||||
assert handler.global_stop(datetime.now(timezone.utc), "*") is None
|
assert handler.global_stop(datetime.now(timezone.utc), "*") is None
|
||||||
if not handler.has_local_stop:
|
if not handler.has_local_stop:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user