From 74b03d05291408003032eb4e4b0b926e0dc28c76 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 24 Jan 2019 07:03:41 +0100 Subject: [PATCH] Add tests and default values for all experimental features --- freqtrade/resolvers/strategy_resolver.py | 4 +- freqtrade/tests/strategy/test_strategy.py | 56 +++++++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/freqtrade/resolvers/strategy_resolver.py b/freqtrade/resolvers/strategy_resolver.py index 7a6292c8d..ab506131f 100644 --- a/freqtrade/resolvers/strategy_resolver.py +++ b/freqtrade/resolvers/strategy_resolver.py @@ -56,8 +56,8 @@ class StrategyResolver(IResolver): ("order_types", None, False), ("order_time_in_force", None, False), ("use_sell_signal", False, True), - ("sell_profit_only", None, True), - ("ignore_roi_if_buy_signal", None, True), + ("sell_profit_only", False, True), + ("ignore_roi_if_buy_signal", False, True), ] for attribute, default, experimental in attributes: if experimental: diff --git a/freqtrade/tests/strategy/test_strategy.py b/freqtrade/tests/strategy/test_strategy.py index b2315f381..e9240de99 100644 --- a/freqtrade/tests/strategy/test_strategy.py +++ b/freqtrade/tests/strategy/test_strategy.py @@ -294,6 +294,62 @@ def test_strategy_override_order_tif(caplog): StrategyResolver(config) +def test_strategy_override_use_sell_signal(caplog): + caplog.set_level(logging.INFO) + config = { + 'strategy': 'DefaultStrategy', + } + resolver = StrategyResolver(config) + assert not resolver.strategy.use_sell_signal + assert isinstance(resolver.strategy.use_sell_signal, bool) + # must be inserted to configuration + assert 'use_sell_signal' in config['experimental'] + assert not config['experimental']['use_sell_signal'] + + config = { + 'strategy': 'DefaultStrategy', + 'experimental': { + 'use_sell_signal': True, + }, + } + resolver = StrategyResolver(config) + + assert resolver.strategy.use_sell_signal + assert isinstance(resolver.strategy.use_sell_signal, bool) + assert ('freqtrade.resolvers.strategy_resolver', + logging.INFO, + "Override strategy 'use_sell_signal' with value in config file: True." + ) in caplog.record_tuples + + +def test_strategy_override_use_sell_profit_only(caplog): + caplog.set_level(logging.INFO) + config = { + 'strategy': 'DefaultStrategy', + } + resolver = StrategyResolver(config) + assert not resolver.strategy.sell_profit_only + assert isinstance(resolver.strategy.sell_profit_only, bool) + # must be inserted to configuration + assert 'sell_profit_only' in config['experimental'] + assert not config['experimental']['sell_profit_only'] + + config = { + 'strategy': 'DefaultStrategy', + 'experimental': { + 'sell_profit_only': True, + }, + } + resolver = StrategyResolver(config) + + assert resolver.strategy.sell_profit_only + assert isinstance(resolver.strategy.sell_profit_only, bool) + assert ('freqtrade.resolvers.strategy_resolver', + logging.INFO, + "Override strategy 'sell_profit_only' with value in config file: True." + ) in caplog.record_tuples + + def test_deprecate_populate_indicators(result): default_location = path.join(path.dirname(path.realpath(__file__))) resolver = StrategyResolver({'strategy': 'TestStrategyLegacy',