freqtrade/freqtrade · error · OperationalException
Please set a timerange. Usually a few months are enough depe
Error message
Please set a timerange. Usually a few months are enough depending on your needs and strategy.
What it means
Thrown by LookaheadAnalysisSubFunctions.calculate_config_overrides when the config for a lookahead-analysis run has no 'timerange' key. Lookahead analysis compares backtest results across time segments, which is only meaningful for an explicitly bounded period, so freqtrade refuses to guess one. All other config overrides (max_open_trades=-1, dry_run_wallet=1e9, stake_amount=10000) are applied before/after this check, but a missing timerange aborts the run.
Source
Thrown at freqtrade/optimize/analysis/lookahead_helpers.py:186
if config["targeted_trade_amount"] < config["minimum_trade_amount"]:
# this combo doesn't make any sense.
raise OperationalException(
"Targeted trade amount can't be smaller than minimum trade amount."
)
config["max_open_trades"] = -1
logger.info("Forced max_open_trades to -1 (same amount as there are pairs)")
min_dry_run_wallet = 1000000000
if get_dry_run_wallet(config) < min_dry_run_wallet:
logger.info(
"Dry run wallet was not set to 1 billion, pushing it up there "
"just to avoid false positives"
)
config["dry_run_wallet"] = min_dry_run_wallet
if "timerange" not in config:
# setting a timerange is enforced here
raise OperationalException(
"Please set a timerange. "
"Usually a few months are enough depending on your needs and strategy."
)
# fix stake_amount to 10k.
# in a combination with a wallet size of 1 billion it should always be able to trade
# no matter if they use custom_stake_amount as a small percentage of wallet size
# or fixate custom_stake_amount to a certain value.
logger.info("fixing stake_amount to 10k")
config["stake_amount"] = 10000
# enforce cache to be 'none', shift it to 'none' if not already
# (since the default value is 'day')
if config.get("backtest_cache") is None:
config["backtest_cache"] = "none"
elif config["backtest_cache"] != "none":
logger.info(
f"backtest_cache = "
f"{config['backtest_cache']} detected. "View on GitHub (pinned to 1c8edfe4d1)
Solutions
- Add an explicit timerange: `freqtrade lookahead-analysis --timerange 20240101-20240601 --strategy MyStrat`.
- Or add "timerange": "20240101-" to the config file used for the run.
- Use a range of at least a few months so enough trades occur for the comparison to be meaningful.
Example fix
# before freqtrade lookahead-analysis --strategy MyStrat # after freqtrade lookahead-analysis --strategy MyStrat --timerange 20240101-20240601
Defensive patterns
Strategy: validation
Validate before calling
def has_timerange(config) -> bool:
return "timerange" in config and bool(config["timerange"]) Prevention
- Keep a dedicated lookahead-analysis config that always includes a timerange entry.
- Script wrappers should require a --timerange argument before calling freqtrade lookahead-analysis.
When it happens
Trigger: Running `freqtrade lookahead-analysis` without `--timerange 20240101-20240401` and without a `timerange` entry in config.json or strategy config.
Common situations: User copies a backtest config that relies on the full downloaded data range; backtest tolerates a missing timerange but lookahead-analysis does not.
Related errors
- Targeted trade amount can't be smaller than minimum trade am
- No Strategy specified. Please specify a strategy via --strat
- Please set a timerange. A timerange of 5000 candles are enou
- Using timerange parameter is not supported with --freqai-bac
- Please pass --timerange if you intend to use FreqAI for back
AI-assisted analysis of freqtrade/freqtrade@1c8edfe4d1 (2026-08-15).
Data as JSON: /api/errors/bcbea81fcf3abf6d.
Report an issue: GitHub.