feat: immediately triggering stoploss orders should cause emergency exits
closes #12824
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user