From 16a54b3616efa47bd394ddb660a00881d1fda989 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 20 Mar 2021 13:08:02 +0100 Subject: [PATCH] Don't require non-mandatory arguments --- freqtrade/configuration/config_validation.py | 8 ++++---- tests/test_freqtradebot.py | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/freqtrade/configuration/config_validation.py b/freqtrade/configuration/config_validation.py index b6029b6a5..c7e49f33d 100644 --- a/freqtrade/configuration/config_validation.py +++ b/freqtrade/configuration/config_validation.py @@ -100,12 +100,12 @@ def _validate_price_config(conf: Dict[str, Any]) -> None: """ When using market orders, price sides must be using the "other" side of the price """ - if (conf['order_types'].get('buy') == 'market' - and conf['bid_strategy'].get('price_side') != 'ask'): + if (conf.get('order_types', {}).get('buy') == 'market' + and conf.get('bid_strategy', {}).get('price_side') != 'ask'): raise OperationalException('Market buy orders require bid_strategy.price_side = "ask".') - if (conf['order_types'].get('sell') == 'market' - and conf['ask_strategy'].get('price_side') != 'bid'): + if (conf.get('order_types', {}).get('sell') == 'market' + and conf.get('ask_strategy', {}).get('price_side') != 'bid'): raise OperationalException('Market sell orders require ask_strategy.price_side = "bid".') diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index d7d2e19f6..5ef9960ab 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -94,6 +94,7 @@ def test_order_dict_dry_run(default_conf, mocker, caplog) -> None: 'stoploss': 'limit', 'stoploss_on_exchange': True, } + conf['bid_strategy']['price_side'] = 'ask' freqtrade = FreqtradeBot(conf) assert freqtrade.strategy.order_types['stoploss_on_exchange'] @@ -128,6 +129,7 @@ def test_order_dict_live(default_conf, mocker, caplog) -> None: 'stoploss': 'limit', 'stoploss_on_exchange': True, } + conf['bid_strategy']['price_side'] = 'ask' freqtrade = FreqtradeBot(conf) assert not log_has_re(".*stoploss_on_exchange .* dry-run", caplog)