mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Add test for ask_orderbook validation
This commit is contained in:
parent
8c542e4028
commit
59a33d0fa9
|
@ -193,7 +193,7 @@ def _validate_ask_orderbook(conf: Dict[str, Any]) -> None:
|
|||
ask_strategy = conf.get('ask_strategy', {})
|
||||
ob_min = ask_strategy.get('order_book_min')
|
||||
ob_max = ask_strategy.get('order_book_max')
|
||||
if ob_min is not None and ob_max is not None:
|
||||
if ob_min is not None and ob_max is not None and ask_strategy.get('use_order_book'):
|
||||
if ob_min != ob_max:
|
||||
raise OperationalException(
|
||||
"Using order_book_max != order_book_min in ask_strategy is no longer supported."
|
||||
|
|
|
@ -1071,8 +1071,8 @@ class Exchange:
|
|||
rate = order_book[f"{ask_strategy['price_side']}s"][order_book_top - 1][0]
|
||||
except (IndexError, KeyError) as e:
|
||||
logger.warning(
|
||||
"Sell Price at location from orderbook could not be determined."
|
||||
f"Orderbook: {order_book}"
|
||||
f"Sell Price at location {order_book_top} from orderbook could not be "
|
||||
f"determined. Orderbook: {order_book}"
|
||||
)
|
||||
raise PricingError from e
|
||||
else:
|
||||
|
|
|
@ -1869,7 +1869,8 @@ def test_get_sell_rate_orderbook_exception(default_conf, mocker, caplog):
|
|||
exchange = get_patched_exchange(mocker, default_conf)
|
||||
with pytest.raises(PricingError):
|
||||
exchange.get_sell_rate(pair, True)
|
||||
assert log_has_re(r"Sell Price at location 1 from orderbook could not be determined\..*", caplog)
|
||||
assert log_has_re(r"Sell Price at location 1 from orderbook could not be determined\..*",
|
||||
caplog)
|
||||
|
||||
|
||||
def test_get_sell_rate_exception(default_conf, mocker, caplog):
|
||||
|
|
|
@ -935,6 +935,23 @@ def test_validate_protections(default_conf, protconf, expected):
|
|||
validate_config_consistency(conf)
|
||||
|
||||
|
||||
def test_validate_ask_orderbook(default_conf, caplog) -> None:
|
||||
conf = deepcopy(default_conf)
|
||||
conf['ask_strategy']['use_order_book'] = True
|
||||
conf['ask_strategy']['order_book_min'] = 2
|
||||
conf['ask_strategy']['order_book_max'] = 2
|
||||
|
||||
validate_config_consistency(conf)
|
||||
assert log_has_re(r"DEPRECATED: Please use `order_book_top` instead of.*", caplog)
|
||||
assert conf['ask_strategy']['order_book_top'] == 2
|
||||
|
||||
conf['ask_strategy']['order_book_max'] = 5
|
||||
|
||||
with pytest.raises(OperationalException,
|
||||
match=r"Using order_book_max != order_book_min in ask_strategy.*"):
|
||||
validate_config_consistency(conf)
|
||||
|
||||
|
||||
def test_load_config_test_comments() -> None:
|
||||
"""
|
||||
Load config with comments
|
||||
|
|
|
@ -4026,7 +4026,8 @@ def test_order_book_ask_strategy(default_conf, limit_buy_order_open, limit_buy_o
|
|||
return_value={'bids': [[]], 'asks': [[]]})
|
||||
with pytest.raises(PricingError):
|
||||
freqtrade.handle_trade(trade)
|
||||
assert log_has_re(r'Sell Price at location 1 from orderbook could not be determined\..*', caplog)
|
||||
assert log_has_re(r'Sell Price at location 1 from orderbook could not be determined\..*',
|
||||
caplog)
|
||||
|
||||
|
||||
def test_startup_state(default_conf, mocker):
|
||||
|
|
Loading…
Reference in New Issue
Block a user