Migrate bid/ask strategy to entry/exit pricing

This commit is contained in:
Matthias 2022-03-27 18:58:46 +02:00
parent bcf326a035
commit 9f863369bd
2 changed files with 57 additions and 0 deletions

View File

@ -217,6 +217,7 @@ def validate_migrated_strategy_settings(conf: Dict[str, Any]) -> None:
_validate_time_in_force(conf)
_validate_order_types(conf)
_validate_unfilledtimeout(conf)
_validate_pricing_rules(conf)
def _validate_time_in_force(conf: Dict[str, Any]) -> None:
@ -279,3 +280,25 @@ def _validate_unfilledtimeout(conf: Dict[str, Any]) -> None:
]:
process_deprecated_setting(conf, 'unfilledtimeout', o, 'unfilledtimeout', n)
def _validate_pricing_rules(conf: Dict[str, Any]) -> None:
if conf.get('ask_strategy') or conf.get('bid_strategy'):
if conf.get('trading_mode', TradingMode.SPOT) != TradingMode.SPOT:
raise OperationalException(
"Please migrate your pricing settings to use the new wording.")
else:
logger.warning(
"DEPRECATED: Using 'ask_strategy' and 'bid_strategy' is deprecated."
"Please migrate your settings to use 'entry_pricing' and 'exit_pricing'."
)
conf['entry_pricing'] = {}
for obj in list(conf.get('bid_strategy').keys()):
process_deprecated_setting(conf, 'bid_strategy', obj, 'entry_pricing', obj)
del conf['bid_strategy']
conf['exit_pricing'] = {}
for obj in list(conf.get('ask_strategy').keys()):
process_deprecated_setting(conf, 'ask_strategy', obj, 'exit_pricing', obj)
del conf['ask_strategy']

View File

@ -1023,6 +1023,40 @@ def test__validate_unfilledtimeout(default_conf, caplog) -> None:
validate_config_consistency(conf)
def test__validate_pricing_rules(default_conf, caplog) -> None:
def_conf = deepcopy(default_conf)
del def_conf['entry_pricing']
del def_conf['exit_pricing']
def_conf['ask_strategy'] = {
'price_side': 'ask',
'use_order_book': True,
}
def_conf['bid_strategy'] = {
'price_side': 'bid',
'use_order_book': False,
}
conf = deepcopy(def_conf)
validate_config_consistency(conf)
assert log_has_re(
r"DEPRECATED: Using 'ask_strategy' and 'bid_strategy' is.*", caplog)
assert conf['exit_pricing']['price_side'] == 'ask'
assert conf['exit_pricing']['use_order_book'] is True
assert conf['entry_pricing']['price_side'] == 'bid'
assert conf['entry_pricing']['use_order_book'] is False
assert 'ask_strategy' not in conf
assert 'bid_strategy' not in conf
conf = deepcopy(def_conf)
conf['trading_mode'] = 'futures'
with pytest.raises(
OperationalException,
match=r"Please migrate your pricing settings to use the new wording\."):
validate_config_consistency(conf)
def test_load_config_test_comments() -> None:
"""
Load config with comments