fix #3463 by explicitly failing if no stoploss is defined
This commit is contained in:
parent
72ae4b1500
commit
ab0003f565
@ -5,7 +5,7 @@ import logging
|
|||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
from freqtrade.pairlist.IPairList import IPairList
|
from freqtrade.pairlist.IPairList import IPairList
|
||||||
|
from freqtrade.exceptions import OperationalException
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -17,6 +17,10 @@ class PrecisionFilter(IPairList):
|
|||||||
pairlist_pos: int) -> None:
|
pairlist_pos: int) -> None:
|
||||||
super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos)
|
super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos)
|
||||||
|
|
||||||
|
if 'stoploss' not in self._config:
|
||||||
|
raise OperationalException(
|
||||||
|
'PrecisionFilter can only work with stoploss defined. Please add the '
|
||||||
|
'stoploss key to your configuration (overwrites eventual strategy settings).')
|
||||||
self._stoploss = self._config['stoploss']
|
self._stoploss = self._config['stoploss']
|
||||||
self._enabled = self._stoploss != 0
|
self._enabled = self._stoploss != 0
|
||||||
|
|
||||||
|
@ -362,6 +362,17 @@ def test_VolumePairList_whitelist_gen(mocker, whitelist_conf, shitcoinmarkets, t
|
|||||||
assert not log_has(logmsg, caplog)
|
assert not log_has(logmsg, caplog)
|
||||||
|
|
||||||
|
|
||||||
|
def test_PrecisionFilter_error(mocker, whitelist_conf, tickers) -> None:
|
||||||
|
whitelist_conf['pairlists'] = [{"method": "StaticPairList"}, {"method": "PrecisionFilter"}]
|
||||||
|
del whitelist_conf['stoploss']
|
||||||
|
|
||||||
|
mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True))
|
||||||
|
|
||||||
|
with pytest.raises(OperationalException,
|
||||||
|
match=r"PrecisionFilter can only work with stoploss defined\..*"):
|
||||||
|
PairListManager(MagicMock, whitelist_conf)
|
||||||
|
|
||||||
|
|
||||||
def test_gen_pair_whitelist_not_supported(mocker, default_conf, tickers) -> None:
|
def test_gen_pair_whitelist_not_supported(mocker, default_conf, tickers) -> None:
|
||||||
default_conf['pairlists'] = [{'method': 'VolumePairList', 'number_assets': 10}]
|
default_conf['pairlists'] = [{'method': 'VolumePairList', 'number_assets': 10}]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user