freqtrade/freqtrade · error · ConfigurationError

Start date is after stop date for timerange "{text}"

Error message

Start date is after stop date for timerange "{text}"

What it means

ConfigurationError from TimeRange parsing when the parsed start timestamp is greater than the stop timestamp (and stop > 0). The timerange string is valid syntactically but chronologically reversed, which would produce an empty data window.

Source

Thrown at freqtrade/configuration/timerange.py:183

                            datetime.strptime(starts, "%Y%m%d").replace(tzinfo=UTC).timestamp()
                        )
                    elif len(starts) == 13:
                        start = int(starts) // 1000
                    else:
                        start = int(starts)
                    index += 1
                if stype[1]:
                    stops = rvals[index]
                    if stype[1] == "date" and len(stops) == 8:
                        stop = int(
                            datetime.strptime(stops, "%Y%m%d").replace(tzinfo=UTC).timestamp()
                        )
                    elif len(stops) == 13:
                        stop = int(stops) // 1000
                    else:
                        stop = int(stops)
                if start > stop > 0:
                    raise ConfigurationError(
                        f'Start date is after stop date for timerange "{text}"'
                    )
                return cls(stype[0], stype[1], start, stop)
        raise ConfigurationError(f'Incorrect syntax for timerange "{text}"')

View on GitHub (pinned to 1c8edfe4d1)

Solutions

  1. Swap the dates so the earlier date comes first: `--timerange 20230101-20240101`
  2. Double-check the format: both sides must be YYYYMMDD or YYYYMMDDHHMMSS
  3. Omit the start (`-20240101`) or stop (`20230101-`) for open-ended ranges

Example fix

# before
freqtrade backtesting --timerange 20240101-20230101

# after
freqtrade backtesting --timerange 20230101-20240101
Defensive patterns

Strategy: validation

Validate before calling

from datetime import datetime, timezone
def timerange_ok(text: str) -> bool:
    try:
        parts = text.split('-')
        starts = [datetime.strptime(p, '%Y%m%d').replace(tzinfo=timezone.utc).timestamp() for p in parts if len(p) == 8]
        return len(starts) < 2 or starts[0] <= starts[1]
    except ValueError:
        return False

Try / catch

from freqtrade.exceptions import ConfigurationError
from freqtrade.configuration import TimeRange
try:
    tr = TimeRange.parse(args_timerange)
except ConfigurationError as e:
    sys.exit(str(e))

Prevention

When it happens

Trigger: Passing `--timerange 20240101-20230101` (start 2024-01-01, stop 2023-01-01): after parsing both dates, `start > stop > 0` holds and the error is raised.

Common situations: Swapping the two dates when hand-writing a timerange; YYYYMMDD vs YYYYMMDDHHMMSS confusion leading to wrong ordering; timezone mix-ups when computing ranges in scripts.

Related errors


AI-assisted analysis of freqtrade/freqtrade@1c8edfe4d1 (2026-08-15). Data as JSON: /api/errors/bfca7201fe39c44f. Report an issue: GitHub.