From 3f669147f18b3fe6398b6324a432b56fcbc482e1 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 26 Jun 2021 17:47:41 +0200 Subject: [PATCH] Simplify strategy-resolver moving --- freqtrade/resolvers/strategy_resolver.py | 64 ++++++++++-------------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/freqtrade/resolvers/strategy_resolver.py b/freqtrade/resolvers/strategy_resolver.py index 23688bcb8..ccd7cea69 100644 --- a/freqtrade/resolvers/strategy_resolver.py +++ b/freqtrade/resolvers/strategy_resolver.py @@ -45,10 +45,6 @@ class StrategyResolver(IResolver): strategy_name, config=config, extra_dir=config.get('strategy_path')) - # make sure ask_strategy dict is available - if 'ask_strategy' not in config: - config['ask_strategy'] = {} - if hasattr(strategy, 'ticker_interval') and not hasattr(strategy, 'timeframe'): # Assign ticker_interval to timeframe to keep compatibility if 'timeframe' not in config: @@ -60,42 +56,36 @@ class StrategyResolver(IResolver): # Set attributes # Check if we need to override configuration # (Attribute name, default, subkey) - attributes = [("minimal_roi", {"0": 10.0}, None), - ("timeframe", None, None), - ("stoploss", None, None), - ("trailing_stop", None, None), - ("trailing_stop_positive", None, None), - ("trailing_stop_positive_offset", 0.0, None), - ("trailing_only_offset_is_reached", None, None), - ("use_custom_stoploss", None, None), - ("process_only_new_candles", None, None), - ("order_types", None, None), - ("order_time_in_force", None, None), - ("stake_currency", None, None), - ("stake_amount", None, None), - ("protections", None, None), - ("startup_candle_count", None, None), - ("unfilledtimeout", None, None), - ("use_sell_signal", True, None), - ("sell_profit_only", False, None), - ("ignore_roi_if_buy_signal", False, None), - ("sell_profit_offset", 0.0, None), - ("disable_dataframe_checks", False, None), - ("ignore_buying_expired_candle_after", 0, None) + attributes = [("minimal_roi", {"0": 10.0}), + ("timeframe", None), + ("stoploss", None), + ("trailing_stop", None), + ("trailing_stop_positive", None), + ("trailing_stop_positive_offset", 0.0), + ("trailing_only_offset_is_reached", None), + ("use_custom_stoploss", None), + ("process_only_new_candles", None), + ("order_types", None), + ("order_time_in_force", None), + ("stake_currency", None), + ("stake_amount", None), + ("protections", None), + ("startup_candle_count", None), + ("unfilledtimeout", None), + ("use_sell_signal", True), + ("sell_profit_only", False), + ("ignore_roi_if_buy_signal", False), + ("sell_profit_offset", 0.0), + ("disable_dataframe_checks", False), + ("ignore_buying_expired_candle_after", 0) ] - for attribute, default, subkey in attributes: - if subkey: - StrategyResolver._override_attribute_helper(strategy, config.get(subkey, {}), - attribute, default) - else: - StrategyResolver._override_attribute_helper(strategy, config, - attribute, default) + for attribute, default in attributes: + StrategyResolver._override_attribute_helper(strategy, config, + attribute, default) # Loop this list again to have output combined - for attribute, _, subkey in attributes: - if subkey and attribute in config[subkey]: - logger.info("Strategy using %s: %s", attribute, config[subkey][attribute]) - elif attribute in config: + for attribute, _ in attributes: + if attribute in config: logger.info("Strategy using %s: %s", attribute, config[attribute]) StrategyResolver._normalize_attributes(strategy)