Implement *candle definitions
This commit is contained in:
@@ -3,9 +3,10 @@ from datetime import datetime, timedelta
|
||||
|
||||
import pytest
|
||||
|
||||
from freqtrade.persistence import PairLocks, Trade
|
||||
from freqtrade.strategy.interface import SellType
|
||||
from freqtrade import constants
|
||||
from freqtrade.persistence import PairLocks, Trade
|
||||
from freqtrade.plugins.protectionmanager import ProtectionManager
|
||||
from freqtrade.strategy.interface import SellType
|
||||
from tests.conftest import get_patched_freqtradebot, log_has_re
|
||||
|
||||
|
||||
@@ -49,6 +50,33 @@ def test_protectionmanager(mocker, default_conf):
|
||||
assert handler.stop_per_pair('XRP/BTC', datetime.utcnow()) == (False, None, None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('timeframe,expected,protconf', [
|
||||
('1m', [20, 10],
|
||||
[{"method": "StoplossGuard", "lookback_period_candles": 20, "stop_duration": 10}]),
|
||||
('5m', [100, 15],
|
||||
[{"method": "StoplossGuard", "lookback_period_candles": 20, "stop_duration": 15}]),
|
||||
('1h', [1200, 40],
|
||||
[{"method": "StoplossGuard", "lookback_period_candles": 20, "stop_duration": 40}]),
|
||||
('1d', [1440, 5],
|
||||
[{"method": "StoplossGuard", "lookback_period_candles": 1, "stop_duration": 5}]),
|
||||
('1m', [20, 5],
|
||||
[{"method": "StoplossGuard", "lookback_period": 20, "stop_duration_candles": 5}]),
|
||||
('5m', [15, 25],
|
||||
[{"method": "StoplossGuard", "lookback_period": 15, "stop_duration_candles": 5}]),
|
||||
('1h', [50, 600],
|
||||
[{"method": "StoplossGuard", "lookback_period": 50, "stop_duration_candles": 10}]),
|
||||
('1h', [60, 540],
|
||||
[{"method": "StoplossGuard", "lookback_period_candles": 1, "stop_duration_candles": 9}]),
|
||||
])
|
||||
def test_protections_init(mocker, default_conf, timeframe, expected, protconf):
|
||||
default_conf['timeframe'] = timeframe
|
||||
default_conf['protections'] = protconf
|
||||
man = ProtectionManager(default_conf)
|
||||
assert len(man._protection_handlers) == len(protconf)
|
||||
assert man._protection_handlers[0]._lookback_period == expected[0]
|
||||
assert man._protection_handlers[0]._stop_duration == expected[1]
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_stoploss_guard(mocker, default_conf, fee, caplog):
|
||||
default_conf['protections'] = [{
|
||||
|
@@ -879,11 +879,12 @@ def test_validate_whitelist(default_conf):
|
||||
|
||||
validate_config_consistency(conf)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('protconf,expected', [
|
||||
([], None),
|
||||
([{"method": "StoplossGuard", "lookback_period": 2000, "stop_duration_candles": 10}], None),
|
||||
([{"method": "StoplossGuard", "lookback_period_candle": 20, "stop_duration": 10}], None),
|
||||
([{"method": "StoplossGuard", "lookback_period_candle": 20, "lookback_period": 2000,
|
||||
([{"method": "StoplossGuard", "lookback_period_candles": 20, "stop_duration": 10}], None),
|
||||
([{"method": "StoplossGuard", "lookback_period_candles": 20, "lookback_period": 2000,
|
||||
"stop_duration": 10}], r'Protections must specify either `lookback_period`.*'),
|
||||
([{"method": "StoplossGuard", "lookback_period": 20, "stop_duration": 10,
|
||||
"stop_duration_candles": 10}], r'Protections must specify either `stop_duration`.*'),
|
||||
|
Reference in New Issue
Block a user