From 4d52732d30b8f55ec683de156c3ee87203398a08 Mon Sep 17 00:00:00 2001 From: Patrick Brunier Date: Thu, 18 Mar 2021 22:38:54 +0100 Subject: [PATCH] Added a small snippet to give users a descent error message, when their start date is afer the stop date. Also updated the tests. --- freqtrade/configuration/timerange.py | 2 ++ tests/test_timerange.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/freqtrade/configuration/timerange.py b/freqtrade/configuration/timerange.py index 32bbd02a0..2075b38c6 100644 --- a/freqtrade/configuration/timerange.py +++ b/freqtrade/configuration/timerange.py @@ -103,5 +103,7 @@ class TimeRange: stop = int(stops) // 1000 else: stop = int(stops) + if start > stop > 0: + raise Exception('Start date is after stop date for timerange "%s"' % text) return TimeRange(stype[0], stype[1], start, stop) raise Exception('Incorrect syntax for timerange "%s"' % text) diff --git a/tests/test_timerange.py b/tests/test_timerange.py index 5c35535f0..cd10e219f 100644 --- a/tests/test_timerange.py +++ b/tests/test_timerange.py @@ -30,6 +30,9 @@ def test_parse_timerange_incorrect(): with pytest.raises(Exception, match=r'Incorrect syntax.*'): TimeRange.parse_timerange('-') + with pytest.raises(Exception, match=r'Start date is after stop date for timerange.*'): + TimeRange.parse_timerange('20100523-20100522') + def test_subtract_start(): x = TimeRange('date', 'date', 1274486400, 1438214400)