Simplify strategy-resolver moving

This commit is contained in:
Matthias 2021-06-26 17:47:41 +02:00
parent 158cb415a9
commit 3f669147f1

View File

@ -45,10 +45,6 @@ class StrategyResolver(IResolver):
strategy_name, config=config, strategy_name, config=config,
extra_dir=config.get('strategy_path')) 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'): if hasattr(strategy, 'ticker_interval') and not hasattr(strategy, 'timeframe'):
# Assign ticker_interval to timeframe to keep compatibility # Assign ticker_interval to timeframe to keep compatibility
if 'timeframe' not in config: if 'timeframe' not in config:
@ -60,42 +56,36 @@ class StrategyResolver(IResolver):
# Set attributes # Set attributes
# Check if we need to override configuration # Check if we need to override configuration
# (Attribute name, default, subkey) # (Attribute name, default, subkey)
attributes = [("minimal_roi", {"0": 10.0}, None), attributes = [("minimal_roi", {"0": 10.0}),
("timeframe", None, None), ("timeframe", None),
("stoploss", None, None), ("stoploss", None),
("trailing_stop", None, None), ("trailing_stop", None),
("trailing_stop_positive", None, None), ("trailing_stop_positive", None),
("trailing_stop_positive_offset", 0.0, None), ("trailing_stop_positive_offset", 0.0),
("trailing_only_offset_is_reached", None, None), ("trailing_only_offset_is_reached", None),
("use_custom_stoploss", None, None), ("use_custom_stoploss", None),
("process_only_new_candles", None, None), ("process_only_new_candles", None),
("order_types", None, None), ("order_types", None),
("order_time_in_force", None, None), ("order_time_in_force", None),
("stake_currency", None, None), ("stake_currency", None),
("stake_amount", None, None), ("stake_amount", None),
("protections", None, None), ("protections", None),
("startup_candle_count", None, None), ("startup_candle_count", None),
("unfilledtimeout", None, None), ("unfilledtimeout", None),
("use_sell_signal", True, None), ("use_sell_signal", True),
("sell_profit_only", False, None), ("sell_profit_only", False),
("ignore_roi_if_buy_signal", False, None), ("ignore_roi_if_buy_signal", False),
("sell_profit_offset", 0.0, None), ("sell_profit_offset", 0.0),
("disable_dataframe_checks", False, None), ("disable_dataframe_checks", False),
("ignore_buying_expired_candle_after", 0, None) ("ignore_buying_expired_candle_after", 0)
] ]
for attribute, default, subkey in attributes: for attribute, default in attributes:
if subkey: StrategyResolver._override_attribute_helper(strategy, config,
StrategyResolver._override_attribute_helper(strategy, config.get(subkey, {}), attribute, default)
attribute, default)
else:
StrategyResolver._override_attribute_helper(strategy, config,
attribute, default)
# Loop this list again to have output combined # Loop this list again to have output combined
for attribute, _, subkey in attributes: for attribute, _ in attributes:
if subkey and attribute in config[subkey]: if attribute in config:
logger.info("Strategy using %s: %s", attribute, config[subkey][attribute])
elif attribute in config:
logger.info("Strategy using %s: %s", attribute, config[attribute]) logger.info("Strategy using %s: %s", attribute, config[attribute])
StrategyResolver._normalize_attributes(strategy) StrategyResolver._normalize_attributes(strategy)