Repository: freqtrade/freqtrade

Issue:
Hyperopts --live backtesting with old data
backtesting --live does backtesting from the 30th of April. Isn't meant to be live testing from now until it stops?


Discussion:
No, the start-date will depend on the ticker-interval used.

`--live` uses the last 500 (ish) candles from the current time. 
Backtesting will never run from "now" until it stops, but always use historic data - that's running the bot regularily and setting "dry_run" to true.


This again, is a option i don't see having much sense (you always want to backtest more than 500 candles). 

@hroff-1902 - comments on removing `--live` ? 
it's misleading by name - and does not make much sense since backtesting 500 candles only will rarely make sense.



I think we can actually mark `--live` as deprecated, right.

Say, add a deprecation warning and keep the current behaviour right now, then in, say, 3 months leave deprecation warning and quit, and then after 3 months remove the option.


Resolving patch:
diff --git a/freqtrade/configuration/configuration.py b/freqtrade/configuration/configuration.py
--- a/freqtrade/configuration/configuration.py
+++ b/freqtrade/configuration/configuration.py
@@ -4,6 +4,7 @@
 import json
 import logging
 import sys
+import warnings
 from argparse import Namespace
 from typing import Any, Callable, Dict, Optional
 
@@ -15,7 +16,6 @@
 from freqtrade.misc import deep_merge_dicts
 from freqtrade.state import RunMode
 
-
 logger = logging.getLogger(__name__)
 
 
@@ -187,7 +187,8 @@ def _process_optimize_options(self, config: Dict[str, Any]) -> None:
                              'Using ticker_interval: {} ...')
 
         self._args_to_config(config, argname='live',
-                             logstring='Parameter -l/--live detected ...')
+                             logstring='Parameter -l/--live detected ...',
+                             deprecated_msg='--live will be removed soon.')
 
         self._args_to_config(config, argname='position_stacking',
                              logstring='Parameter --enable-position-stacking detected ...')
@@ -323,7 +324,8 @@ def _validate_trailing_stoploss(self, conf: Dict[str, Any]) -> None:
                 'to be greater than trailing_stop_positive_offset in your config.')
 
     def _args_to_config(self, config: Dict[str, Any], argname: str,
-                        logstring: str, logfun: Optional[Callable] = None) -> None:
+                        logstring: str, logfun: Optional[Callable] = None,
+                        deprecated_msg: Optional[str] = None) -> None:
         """
         :param config: Configuration dictionary
         :param argname: Argumentname in self.args - will be copied to config dict.
@@ -340,3 +342,5 @@ def _args_to_config(self, config: Dict[str, Any], argname: str,
                 logger.info(logstring.format(logfun(config[argname])))
             else:
                 logger.info(logstring.format(config[argname]))
+            if deprecated_msg:
+                warnings.warn(f"DEPRECATED: {deprecated_msg}", DeprecationWarning)


Test patch:
diff --git a/freqtrade/tests/test_configuration.py b/freqtrade/tests/test_configuration.py
--- a/freqtrade/tests/test_configuration.py
+++ b/freqtrade/tests/test_configuration.py
@@ -1,10 +1,11 @@
 # pragma pylint: disable=missing-docstring, protected-access, invalid-name
 import json
 import logging
+import warnings
 from argparse import Namespace
 from copy import deepcopy
-from unittest.mock import MagicMock
 from pathlib import Path
+from unittest.mock import MagicMock
 
 import pytest
 from jsonschema import Draft4Validator, ValidationError, validate
@@ -62,6 +63,32 @@ def test_load_config_file(default_conf, mocker, caplog) -> None:
     assert validated_conf.items() >= default_conf.items()
 
 
+def test__args_to_config(caplog):
+
+    arg_list = ['--strategy-path', 'TestTest']
+    args = Arguments(arg_list, '').get_parsed_arg()
+    configuration = Configuration(args)
+    config = {}
+    with warnings.catch_warnings(record=True) as w:
+        # No warnings ...
+        configuration._args_to_config(config, argname="strategy_path", logstring="DeadBeef")
+        assert len(w) == 0
+        assert log_has("DeadBeef", caplog.record_tuples)
+        assert config['strategy_path'] == "TestTest"
+
+    configuration = Configuration(args)
+    config = {}
+    with warnings.catch_warnings(record=True) as w:
+        # Deprecation warnings!
+        configuration._args_to_config(config, argname="strategy_path", logstring="DeadBeef",
+                                      deprecated_msg="Going away soon!")
+        assert len(w) == 1
+        assert issubclass(w[-1].category, DeprecationWarning)
+        assert "DEPRECATED: Going away soon!" in str(w[-1].message)
+        assert log_has("DeadBeef", caplog.record_tuples)
+        assert config['strategy_path'] == "TestTest"
+
+
 def test_load_config_max_open_trades_zero(default_conf, mocker, caplog) -> None:
     default_conf['max_open_trades'] = 0
     patched_configuration_load_config_file(mocker, default_conf)