Skip to content

Commit c83ea0d

Browse files
committed
chore: fix default behavior for crossed mode
1 parent ad25636 commit c83ea0d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

freqtrade/exchange/exchange.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,8 @@ def _dry_is_price_crossed(
12571257
is_stop: bool = False,
12581258
) -> bool:
12591259
if not self.exchange_has("fetchL2OrderBook"):
1260-
return True
1260+
# True unless checking a stoploss order
1261+
return not is_stop
12611262
if not orderbook:
12621263
orderbook = self.fetch_l2_order_book(pair, 1)
12631264
try:

tests/exchange/test_exchange.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,10 @@ def test__dry_is_price_crossed_without_orderbook_support(default_conf, mocker):
11731173
exchange.fetch_l2_order_book = MagicMock()
11741174
mocker.patch(f"{EXMS}.exchange_has", return_value=False)
11751175
assert exchange._dry_is_price_crossed("LTC/USDT", "buy", 1.0)
1176+
assert exchange._dry_is_price_crossed("LTC/USDT", "sell", 1.0)
11761177
assert exchange.fetch_l2_order_book.call_count == 0
1178+
assert not exchange._dry_is_price_crossed("LTC/USDT", "buy", 1.0, is_stop=True)
1179+
assert not exchange._dry_is_price_crossed("LTC/USDT", "sell", 1.0, is_stop=True)
11771180

11781181

11791182
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)