From 782f4112cd33b1ae4a86eac58fd57bf1d8db1c5d Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 22 Aug 2019 19:49:30 +0200 Subject: [PATCH] Add test checking stoploss == 0 values --- freqtrade/tests/test_configuration.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/freqtrade/tests/test_configuration.py b/freqtrade/tests/test_configuration.py index a2a87c2cf..838f0372f 100644 --- a/freqtrade/tests/test_configuration.py +++ b/freqtrade/tests/test_configuration.py @@ -648,6 +648,12 @@ def test_create_userdata_dir_exists_exception(mocker, default_conf, caplog) -> N def test_validate_tsl(default_conf): + default_conf['stoploss'] = 0.0 + with pytest.raises(OperationalException, match='The config stoploss needs to be more ' + 'than 0 to avoid problems with sell orders.'): + validate_config_consistency(default_conf) + default_conf['stoploss'] = -0.10 + default_conf['trailing_stop'] = True default_conf['trailing_stop_positive'] = 0 default_conf['trailing_stop_positive_offset'] = 0 @@ -669,6 +675,15 @@ def test_validate_tsl(default_conf): default_conf['trailing_stop_positive_offset'] = 0.015 validate_config_consistency(default_conf) + # 0 trailing stop positive - results in "Order would trigger immediately" + default_conf['trailing_stop_positive'] = 0 + default_conf['trailing_stop_positive_offset'] = 0.02 + default_conf['trailing_only_offset_is_reached'] = False + with pytest.raises(OperationalException, + match='The config trailing_stop_positive needs to be more than 0' + 'to avoid problems with sell orders'): + validate_config_consistency(default_conf) + def test_validate_edge(edge_conf): edge_conf.update({"pairlist": {