Repository: freqtrade/freqtrade

Issue:
freqtrade webserver + no config.json timeframe configured defaults timeframe to 5m
I could make a PR if you say in which direction the issue should be solved. contemplated several ways but there was no quick+easy way without maybe screwing with something else.  

## Describe your environment
reliable reproduction at freqtrade stable 2023.11 for docker and for bare metal
 

## Describe the problem:

*Explain the problem you have encountered*
not having timeframe configured in the config.json but always in the strategy.py file
when using webserver the webserver reads the config file and if it sees no configured timeframe in the config.json it defaults to 5m and pretends there would be stated it would be 5m.

### Steps to reproduce:

  1. make webserver start with your usual config but dont have timeframe configured in there
  2. start a backtest (any strategy would suffice) that is NOT 5m and have something like 1h configured in the strategy
  3. see in the config that it uses the 5m default since the config-reading was done and if none then it defaults back to 5m
  even overriding the strategy-file since config>strategy
  
### Observed Results:

not having timeframe configured in the config.json but in the strategy works when a backtest is done in terminal, but not from webserver.
Webserver reads the config previously already and defaults to 5m after writing the timeframes' default value to 5m despite in the strategy being something else like 1h

### Relevant code exceptions or logs

![image](https://github.com/freqtrade/freqtrade/assets/41228167/71e5ea6a-ee14-4b85-a150-f578c4200731)
2023-12-11 19:25:00,135 - freqtrade.rpc.api_server.webserver - INFO - Starting Local Rest Server.
2023-12-11 19:25:00,151 - uvicorn.error - INFO - Started server process [114914]
2023-12-11 19:25:00,151 - uvicorn.error - INFO - Waiting for application startup.
2023-12-11 19:25:00,151 - uvicorn.error - INFO - Application startup complete.
2023-12-11 19:25:00,152 - uvicorn.error - INFO - Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)

![image](https://github.com/freqtrade/freqtrade/assets/41228167/be963595-545e-421a-a62c-fead8d9893a5)

2023-12-11 19:26:03,766 - freqtrade.rpc.api_server.api_backtest - ERROR - Backtesting caused an error: Main timeframe of 1h must be smaller or equal to FreqAI `include_timeframes`.Offending include-timeframes: 5m
Traceback (most recent call last):
  File "/media/Daten_1TB/Programming/freqtrade_suite/freqtrade/rpc/api_server/api_backtest.py", line 42, in __run_backtest_bg
    validate_config_consistency(btconfig)
  File "/media/Daten_1TB/Programming/freqtrade_suite/freqtrade/configuration/config_validation.py", line 89, in validate_config_consistency
    _validate_freqai_include_timeframes(conf)
  File "/media/Daten_1TB/Programming/freqtrade_suite/freqtrade/configuration/config_validation.py", line 353, in _validate_freqai_include_timeframes
    raise OperationalException(
freqtrade.exceptions.OperationalException: Main timeframe of 1h must be smaller or equal to FreqAI `include_timeframes`.Offending include-timeframes: 5m

On a 2nd pass it pretends freqai inserted 5m as timeframe but as the 1st picture says it isnt.

The configuration directly from terminal works - the strategy and config itself is not relevant since this happens at anything if you don't have timeframe configured to something in your config.json used.

configuration used including model + strategy
https://drive.google.com/file/d/1ldHnZBSKn6OsrjyKLUF4X9v9zfqZOLo0/view?usp=sharing

webserver-command:

webserver --config=user_data/fullConfig_freqaiIssue.json --config=user_data/configs_drylive/config_QuickAdapterV3_1h.json


Discussion:

Resolving patch:
diff --git a/freqtrade/configuration/config_validation.py b/freqtrade/configuration/config_validation.py
--- a/freqtrade/configuration/config_validation.py
+++ b/freqtrade/configuration/config_validation.py
@@ -86,7 +86,7 @@ def validate_config_consistency(conf: Dict[str, Any], preliminary: bool = False)
     _validate_ask_orderbook(conf)
     _validate_freqai_hyperopt(conf)
     _validate_freqai_backtest(conf)
-    _validate_freqai_include_timeframes(conf)
+    _validate_freqai_include_timeframes(conf, preliminary=preliminary)
     _validate_consumers(conf)
     validate_migrated_strategy_settings(conf)
 
@@ -335,7 +335,7 @@ def _validate_freqai_hyperopt(conf: Dict[str, Any]) -> None:
             'Using analyze-per-epoch parameter is not supported with a FreqAI strategy.')
 
 
-def _validate_freqai_include_timeframes(conf: Dict[str, Any]) -> None:
+def _validate_freqai_include_timeframes(conf: Dict[str, Any], preliminary: bool) -> None:
     freqai_enabled = conf.get('freqai', {}).get('enabled', False)
     if freqai_enabled:
         main_tf = conf.get('timeframe', '5m')
@@ -355,7 +355,7 @@ def _validate_freqai_include_timeframes(conf: Dict[str, Any]) -> None:
                 f"`include_timeframes`.Offending include-timeframes: {', '.join(offending_lines)}")
 
         # Ensure that the base timeframe is included in the include_timeframes list
-        if main_tf not in freqai_include_timeframes:
+        if not preliminary and main_tf not in freqai_include_timeframes:
             feature_parameters = conf.get('freqai', {}).get('feature_parameters', {})
             include_timeframes = [main_tf] + freqai_include_timeframes
             conf.get('freqai', {}).get('feature_parameters', {}) \


Test patch: