From b4ba641131f9e0ab246091c4cac543dc2d551946 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 15 Jul 2018 09:01:08 +0200 Subject: [PATCH 1/2] Update config dict with attributes loaded from strategy --- freqtrade/strategy/resolver.py | 6 ++++++ freqtrade/tests/strategy/test_strategy.py | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/freqtrade/strategy/resolver.py b/freqtrade/strategy/resolver.py index 10cedb073..3334d1b17 100644 --- a/freqtrade/strategy/resolver.py +++ b/freqtrade/strategy/resolver.py @@ -41,12 +41,16 @@ class StrategyResolver(object): if 'minimal_roi' in config: self.strategy.minimal_roi = config['minimal_roi'] logger.info("Override strategy \'minimal_roi\' with value in config file.") + else: + config['minimal_roi'] = self.strategy.minimal_roi if 'stoploss' in config: self.strategy.stoploss = config['stoploss'] logger.info( "Override strategy \'stoploss\' with value in config file: %s.", config['stoploss'] ) + else: + config['stoploss'] = self.strategy.stoploss if 'ticker_interval' in config: self.strategy.ticker_interval = config['ticker_interval'] @@ -54,6 +58,8 @@ class StrategyResolver(object): "Override strategy \'ticker_interval\' with value in config file: %s.", config['ticker_interval'] ) + else: + config['ticker_interval'] = self.strategy.ticker_interval # Sort and apply type conversions self.strategy.minimal_roi = OrderedDict(sorted( diff --git a/freqtrade/tests/strategy/test_strategy.py b/freqtrade/tests/strategy/test_strategy.py index 1e082c380..f8723ebc2 100644 --- a/freqtrade/tests/strategy/test_strategy.py +++ b/freqtrade/tests/strategy/test_strategy.py @@ -74,13 +74,21 @@ def test_load_not_found_strategy(): def test_strategy(result): - resolver = StrategyResolver({'strategy': 'DefaultStrategy'}) + config = {'strategy': 'DefaultStrategy'} + + resolver = StrategyResolver(config) assert hasattr(resolver.strategy, 'minimal_roi') assert resolver.strategy.minimal_roi[0] == 0.04 + assert config.get("minimal_roi")['0'] == 0.04 assert hasattr(resolver.strategy, 'stoploss') assert resolver.strategy.stoploss == -0.10 + assert config['stoploss'] == -0.10 + + assert hasattr(resolver.strategy, 'ticker_interval') + assert resolver.strategy.ticker_interval == '5m' + assert config['ticker_interval'] == '5m' assert hasattr(resolver.strategy, 'populate_indicators') assert 'adx' in resolver.strategy.populate_indicators(result) From 158226012a2fe4eb280a2eb90b2ff6b69b64cf09 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 15 Jul 2018 09:08:14 +0200 Subject: [PATCH 2/2] consistent use of the config dict within the test --- freqtrade/tests/strategy/test_strategy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/tests/strategy/test_strategy.py b/freqtrade/tests/strategy/test_strategy.py index f8723ebc2..1aae8f3cc 100644 --- a/freqtrade/tests/strategy/test_strategy.py +++ b/freqtrade/tests/strategy/test_strategy.py @@ -80,7 +80,7 @@ def test_strategy(result): assert hasattr(resolver.strategy, 'minimal_roi') assert resolver.strategy.minimal_roi[0] == 0.04 - assert config.get("minimal_roi")['0'] == 0.04 + assert config["minimal_roi"]['0'] == 0.04 assert hasattr(resolver.strategy, 'stoploss') assert resolver.strategy.stoploss == -0.10