Raise exception when ticker_interval is set.

This commit is contained in:
Matthias 2022-03-20 09:01:18 +01:00
parent 95f69b905a
commit eb08b92180
7 changed files with 15 additions and 34 deletions

View File

@ -100,16 +100,11 @@ def process_temporary_deprecated_settings(config: Dict[str, Any]) -> None:
"from the edge configuration."
)
if 'ticker_interval' in config:
logger.warning(
"DEPRECATED: "
raise OperationalException(
"DEPRECATED: 'ticker_interval' detected. "
"Please use 'timeframe' instead of 'ticker_interval."
)
if 'timeframe' in config:
raise OperationalException(
"Both 'timeframe' and 'ticker_interval' detected."
"Please remove 'ticker_interval' from your configuration to continue operating."
)
config['timeframe'] = config['ticker_interval']
if 'protections' in config:
logger.warning("DEPRECATED: Setting 'protections' in the configuration is deprecated.")

View File

@ -314,16 +314,15 @@ def test_backtesting_init_no_timeframe(mocker, default_conf, caplog) -> None:
patch_exchange(mocker)
del default_conf['timeframe']
default_conf['strategy_list'] = ['StrategyTestV2',
'SampleStrategy']
'HyperoptableStrategy']
mocker.patch('freqtrade.exchange.Exchange.get_fee', MagicMock(return_value=0.5))
with pytest.raises(OperationalException):
with pytest.raises(OperationalException,
match=r"Timeframe needs to be set in either configuration"):
Backtesting(default_conf)
log_has("Ticker-interval needs to be set in either configuration "
"or as cli argument `--ticker-interval 5m`", caplog)
def test_data_with_fee(default_conf, mocker, testdatadir) -> None:
def test_data_with_fee(default_conf, mocker) -> None:
patch_exchange(mocker)
default_conf['fee'] = 0.1234

View File

@ -6,8 +6,7 @@ from unittest.mock import MagicMock
from freqtrade.commands.optimize_commands import setup_optimize_configuration, start_edge
from freqtrade.enums import RunMode
from freqtrade.optimize.edge_cli import EdgeCli
from tests.conftest import (get_args, log_has, log_has_re, patch_exchange,
patched_configuration_load_config_file)
from tests.conftest import get_args, log_has, patch_exchange, patched_configuration_load_config_file
def test_setup_optimize_configuration_without_arguments(mocker, default_conf, caplog) -> None:
@ -30,7 +29,6 @@ def test_setup_optimize_configuration_without_arguments(mocker, default_conf, ca
assert 'datadir' in config
assert log_has('Using data directory: {} ...'.format(config['datadir']), caplog)
assert 'timeframe' in config
assert not log_has_re('Parameter -i/--ticker-interval detected .*', caplog)
assert 'timerange' not in config
assert 'stoploss_range' not in config

View File

@ -63,7 +63,6 @@ def test_setup_hyperopt_configuration_without_arguments(mocker, default_conf, ca
assert 'datadir' in config
assert log_has('Using data directory: {} ...'.format(config['datadir']), caplog)
assert 'timeframe' in config
assert not log_has_re('Parameter -i/--ticker-interval detected .*', caplog)
assert 'position_stacking' not in config
assert not log_has('Parameter --enable-position-stacking detected ...', caplog)

View File

@ -111,7 +111,6 @@ def test_strategy(result, default_conf):
assert default_conf['stoploss'] == -0.10
assert strategy.timeframe == '5m'
assert strategy.ticker_interval == '5m'
assert default_conf['timeframe'] == '5m'
df_indicators = strategy.advise_indicators(result, metadata=metadata)
@ -376,7 +375,6 @@ def test_call_deprecated_function(result, monkeypatch, default_conf, caplog):
assert strategy._sell_fun_len == 2
assert strategy.INTERFACE_VERSION == 1
assert strategy.timeframe == '5m'
assert strategy.ticker_interval == '5m'
indicator_df = strategy.advise_indicators(result, metadata=metadata)
assert isinstance(indicator_df, DataFrame)

View File

@ -111,17 +111,17 @@ def test_parse_args_strategy_path_invalid() -> None:
def test_parse_args_backtesting_invalid() -> None:
with pytest.raises(SystemExit, match=r'2'):
Arguments(['backtesting --ticker-interval']).get_parsed_arg()
Arguments(['backtesting --timeframe']).get_parsed_arg()
with pytest.raises(SystemExit, match=r'2'):
Arguments(['backtesting --ticker-interval', 'abc']).get_parsed_arg()
Arguments(['backtesting --timeframe', 'abc']).get_parsed_arg()
def test_parse_args_backtesting_custom() -> None:
args = [
'backtesting',
'-c', 'test_conf.json',
'--ticker-interval', '1m',
'--timeframe', '1m',
'--strategy-list',
'StrategyTestV2',
'SampleStrategy'

View File

@ -443,7 +443,7 @@ def test_setup_configuration_with_arguments(mocker, default_conf, caplog) -> Non
'--strategy', 'StrategyTestV2',
'--datadir', '/foo/bar',
'--userdir', "/tmp/freqtrade",
'--ticker-interval', '1m',
'--timeframe', '1m',
'--enable-position-stacking',
'--disable-max-market-positions',
'--timerange', ':100',
@ -494,7 +494,7 @@ def test_setup_configuration_with_stratlist(mocker, default_conf, caplog) -> Non
arglist = [
'backtesting',
'--config', 'config.json',
'--ticker-interval', '1m',
'--timeframe', '1m',
'--export', 'trades',
'--strategy-list',
'StrategyTestV2',
@ -1320,22 +1320,14 @@ def test_process_removed_setting(mocker, default_conf, caplog):
def test_process_deprecated_ticker_interval(default_conf, caplog):
message = "DEPRECATED: Please use 'timeframe' instead of 'ticker_interval."
config = deepcopy(default_conf)
process_temporary_deprecated_settings(config)
assert not log_has(message, caplog)
del config['timeframe']
config['ticker_interval'] = '15m'
process_temporary_deprecated_settings(config)
assert log_has(message, caplog)
assert config['ticker_interval'] == '15m'
config = deepcopy(default_conf)
# Have both timeframe and ticker interval in config
# Can also happen when using ticker_interval in configuration, and --timeframe as cli argument
config['timeframe'] = '5m'
config['ticker_interval'] = '4h'
with pytest.raises(OperationalException,
match=r"Both 'timeframe' and 'ticker_interval' detected."):
match=r"DEPRECATED: 'ticker_interval' detected. Please use.*"):
process_temporary_deprecated_settings(config)