2019-10-08 23:37:29 +00:00
|
|
|
"""
|
2019-10-09 00:12:30 +00:00
|
|
|
Functions to handle deprecated settings
|
2019-10-08 23:37:29 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
import logging
|
2022-09-18 11:20:36 +00:00
|
|
|
from typing import Optional
|
2019-10-08 23:37:29 +00:00
|
|
|
|
2022-09-18 11:20:36 +00:00
|
|
|
from freqtrade.constants import Config
|
2019-12-30 14:02:17 +00:00
|
|
|
from freqtrade.exceptions import OperationalException
|
2019-10-08 23:37:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2022-09-18 11:20:36 +00:00
|
|
|
def check_conflicting_settings(config: Config,
|
2022-04-06 17:09:34 +00:00
|
|
|
section_old: Optional[str], name_old: str,
|
2021-06-26 15:15:05 +00:00
|
|
|
section_new: Optional[str], name_new: str) -> None:
|
2021-06-26 14:46:21 +00:00
|
|
|
section_new_config = config.get(section_new, {}) if section_new else config
|
2022-04-06 17:09:34 +00:00
|
|
|
section_old_config = config.get(section_old, {}) if section_old else config
|
2021-06-26 14:46:21 +00:00
|
|
|
if name_new in section_new_config and name_old in section_old_config:
|
|
|
|
new_name = f"{section_new}.{name_new}" if section_new else f"{name_new}"
|
2022-04-06 17:09:34 +00:00
|
|
|
old_name = f"{section_old}.{name_old}" if section_old else f"{name_old}"
|
2019-10-08 23:37:29 +00:00
|
|
|
raise OperationalException(
|
2022-04-06 17:09:34 +00:00
|
|
|
f"Conflicting settings `{new_name}` and `{old_name}` "
|
2019-10-08 23:37:29 +00:00
|
|
|
"(DEPRECATED) detected in the configuration file. "
|
|
|
|
"This deprecated setting will be removed in the next versions of Freqtrade. "
|
2021-06-26 14:46:21 +00:00
|
|
|
f"Please delete it from your configuration and use the `{new_name}` "
|
2019-10-08 23:37:29 +00:00
|
|
|
"setting instead."
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-09-18 11:20:36 +00:00
|
|
|
def process_removed_setting(config: Config,
|
2020-11-27 19:24:04 +00:00
|
|
|
section1: str, name1: str,
|
2021-06-26 15:15:05 +00:00
|
|
|
section2: Optional[str], name2: str) -> None:
|
2020-11-27 19:24:04 +00:00
|
|
|
"""
|
|
|
|
:param section1: Removed section
|
|
|
|
:param name1: Removed setting name
|
|
|
|
:param section2: new section for this key
|
|
|
|
:param name2: new setting name
|
|
|
|
"""
|
|
|
|
section1_config = config.get(section1, {})
|
|
|
|
if name1 in section1_config:
|
2021-06-26 14:46:21 +00:00
|
|
|
section_2 = f"{section2}.{name2}" if section2 else f"{name2}"
|
2020-11-27 19:24:04 +00:00
|
|
|
raise OperationalException(
|
2021-06-26 14:46:21 +00:00
|
|
|
f"Setting `{section1}.{name1}` has been moved to `{section_2}. "
|
|
|
|
f"Please delete it from your configuration and use the `{section_2}` "
|
2020-11-27 19:24:04 +00:00
|
|
|
"setting instead."
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-09-18 11:20:36 +00:00
|
|
|
def process_deprecated_setting(config: Config,
|
2022-04-06 17:09:34 +00:00
|
|
|
section_old: Optional[str], name_old: str,
|
2021-06-26 15:15:05 +00:00
|
|
|
section_new: Optional[str], name_new: str
|
2021-06-26 14:46:21 +00:00
|
|
|
) -> None:
|
|
|
|
check_conflicting_settings(config, section_old, name_old, section_new, name_new)
|
2022-04-06 17:09:34 +00:00
|
|
|
section_old_config = config.get(section_old, {}) if section_old else config
|
2021-06-26 14:46:21 +00:00
|
|
|
|
|
|
|
if name_old in section_old_config:
|
2022-04-08 11:39:41 +00:00
|
|
|
section_1 = f"{section_old}.{name_old}" if section_old else f"{name_old}"
|
2021-06-26 14:46:21 +00:00
|
|
|
section_2 = f"{section_new}.{name_new}" if section_new else f"{name_new}"
|
2019-10-08 23:37:29 +00:00
|
|
|
logger.warning(
|
|
|
|
"DEPRECATED: "
|
2022-04-08 11:39:41 +00:00
|
|
|
f"The `{section_1}` setting is deprecated and "
|
2019-10-08 23:37:29 +00:00
|
|
|
"will be removed in the next versions of Freqtrade. "
|
2021-06-26 14:46:21 +00:00
|
|
|
f"Please use the `{section_2}` setting in your configuration instead."
|
2019-10-08 23:37:29 +00:00
|
|
|
)
|
2021-06-26 14:46:21 +00:00
|
|
|
|
|
|
|
section_new_config = config.get(section_new, {}) if section_new else config
|
|
|
|
section_new_config[name_new] = section_old_config[name_old]
|
2022-03-08 05:59:30 +00:00
|
|
|
del section_old_config[name_old]
|
2019-10-08 23:37:29 +00:00
|
|
|
|
|
|
|
|
2022-09-18 11:20:36 +00:00
|
|
|
def process_temporary_deprecated_settings(config: Config) -> None:
|
2019-10-08 23:37:29 +00:00
|
|
|
|
2020-11-27 19:28:17 +00:00
|
|
|
# Kept for future deprecated / moved settings
|
|
|
|
# check_conflicting_settings(config, 'ask_strategy', 'use_sell_signal',
|
|
|
|
# 'experimental', 'use_sell_signal')
|
2022-04-05 18:00:35 +00:00
|
|
|
|
2021-06-26 14:46:21 +00:00
|
|
|
process_deprecated_setting(config, 'ask_strategy', 'ignore_buying_expired_candle_after',
|
|
|
|
None, 'ignore_buying_expired_candle_after')
|
2022-04-08 11:39:41 +00:00
|
|
|
|
|
|
|
process_deprecated_setting(config, None, 'forcebuy_enable', None, 'force_entry_enable')
|
|
|
|
|
2022-04-04 17:17:11 +00:00
|
|
|
# New settings
|
|
|
|
if config.get('telegram'):
|
|
|
|
process_deprecated_setting(config['telegram'], 'notification_settings', 'sell',
|
|
|
|
'notification_settings', 'exit')
|
|
|
|
process_deprecated_setting(config['telegram'], 'notification_settings', 'sell_fill',
|
|
|
|
'notification_settings', 'exit_fill')
|
|
|
|
process_deprecated_setting(config['telegram'], 'notification_settings', 'sell_cancel',
|
|
|
|
'notification_settings', 'exit_cancel')
|
2022-04-04 17:29:15 +00:00
|
|
|
process_deprecated_setting(config['telegram'], 'notification_settings', 'buy',
|
|
|
|
'notification_settings', 'entry')
|
|
|
|
process_deprecated_setting(config['telegram'], 'notification_settings', 'buy_fill',
|
|
|
|
'notification_settings', 'entry_fill')
|
|
|
|
process_deprecated_setting(config['telegram'], 'notification_settings', 'buy_cancel',
|
|
|
|
'notification_settings', 'entry_cancel')
|
2022-04-04 17:19:54 +00:00
|
|
|
if config.get('webhook'):
|
2022-04-04 17:32:27 +00:00
|
|
|
process_deprecated_setting(config, 'webhook', 'webhookbuy', 'webhook', 'webhookentry')
|
|
|
|
process_deprecated_setting(config, 'webhook', 'webhookbuycancel',
|
|
|
|
'webhook', 'webhookentrycancel')
|
|
|
|
process_deprecated_setting(config, 'webhook', 'webhookbuyfill',
|
|
|
|
'webhook', 'webhookentryfill')
|
2022-04-04 17:19:54 +00:00
|
|
|
process_deprecated_setting(config, 'webhook', 'webhooksell', 'webhook', 'webhookexit')
|
|
|
|
process_deprecated_setting(config, 'webhook', 'webhooksellcancel',
|
|
|
|
'webhook', 'webhookexitcancel')
|
|
|
|
process_deprecated_setting(config, 'webhook', 'webhooksellfill',
|
|
|
|
'webhook', 'webhookexitfill')
|
2021-06-26 14:46:21 +00:00
|
|
|
|
|
|
|
# Legacy way - having them in experimental ...
|
2022-04-05 18:00:35 +00:00
|
|
|
|
2022-04-05 18:20:51 +00:00
|
|
|
process_removed_setting(config, 'experimental', 'use_sell_signal', None, 'use_exit_signal')
|
|
|
|
process_removed_setting(config, 'experimental', 'sell_profit_only', None, 'exit_profit_only')
|
2020-11-27 19:24:04 +00:00
|
|
|
process_removed_setting(config, 'experimental', 'ignore_roi_if_buy_signal',
|
2022-04-05 18:20:51 +00:00
|
|
|
None, 'ignore_roi_if_entry_signal')
|
2019-10-30 15:32:22 +00:00
|
|
|
|
2022-05-26 01:12:50 +00:00
|
|
|
process_removed_setting(config, 'ask_strategy', 'use_sell_signal', None, 'use_exit_signal')
|
2022-04-05 18:20:51 +00:00
|
|
|
process_removed_setting(config, 'ask_strategy', 'sell_profit_only', None, 'exit_profit_only')
|
|
|
|
process_removed_setting(config, 'ask_strategy', 'sell_profit_offset',
|
|
|
|
None, 'exit_profit_offset')
|
|
|
|
process_removed_setting(config, 'ask_strategy', 'ignore_roi_if_buy_signal',
|
|
|
|
None, 'ignore_roi_if_entry_signal')
|
2020-01-03 10:34:17 +00:00
|
|
|
if (config.get('edge', {}).get('enabled', False)
|
|
|
|
and 'capital_available_percentage' in config.get('edge', {})):
|
2020-06-01 17:58:28 +00:00
|
|
|
raise OperationalException(
|
2020-01-03 09:58:31 +00:00
|
|
|
"DEPRECATED: "
|
|
|
|
"Using 'edge.capital_available_percentage' has been deprecated in favor of "
|
|
|
|
"'tradable_balance_ratio'. Please migrate your configuration to "
|
|
|
|
"'tradable_balance_ratio' and remove 'capital_available_percentage' "
|
|
|
|
"from the edge configuration."
|
|
|
|
)
|
2020-06-02 07:50:56 +00:00
|
|
|
if 'ticker_interval' in config:
|
2022-03-20 08:01:18 +00:00
|
|
|
|
|
|
|
raise OperationalException(
|
|
|
|
"DEPRECATED: 'ticker_interval' detected. "
|
2020-06-02 07:50:56 +00:00
|
|
|
"Please use 'timeframe' instead of 'ticker_interval."
|
|
|
|
)
|
2021-08-04 17:43:16 +00:00
|
|
|
|
|
|
|
if 'protections' in config:
|
|
|
|
logger.warning("DEPRECATED: Setting 'protections' in the configuration is deprecated.")
|