feat: immediately triggering stoploss orders should cause emergency exits

closes #12824
pull/12829/head
Matthias 3 days ago
parent a42c8faeca
commit c999de6291

@ -1301,6 +1301,7 @@ class Exchange:
Check dry-run limit order fill and update fee (if it filled). Check dry-run limit order fill and update fee (if it filled).
""" """
if order["status"] != "closed" and order.get("ft_order_type") == "stoploss": if order["status"] != "closed" and order.get("ft_order_type") == "stoploss":
# Stoploss branch
pair = order["symbol"] pair = order["symbol"]
if not orderbook and self.exchange_has("fetchL2OrderBook"): if not orderbook and self.exchange_has("fetchL2OrderBook"):
orderbook = self.fetch_l2_order_book(pair, 20) orderbook = self.fetch_l2_order_book(pair, 20)
@ -1308,6 +1309,11 @@ class Exchange:
crossed = self._dry_is_price_crossed( crossed = self._dry_is_price_crossed(
pair, order["side"], price, orderbook, is_stop=True pair, order["side"], price, orderbook, is_stop=True
) )
if crossed and immediate:
raise InvalidOrderException(
"Could not create dry stoploss order. Stoploss would trigger immediately."
)
if crossed: if crossed:
average = self.get_dry_market_fill_price( average = self.get_dry_market_fill_price(
pair, pair,

Loading…
Cancel
Save