Improve logic for initially placed stoploss

This commit is contained in:
Matthias 2023-02-07 19:42:18 +01:00
parent 2b0e281113
commit c15e10fe1f

View File

@ -1170,15 +1170,13 @@ class FreqtradeBot(LoggingMixin):
# If enter order is fulfilled but there is no stoploss, we add a stoploss on exchange
if not stoploss_order:
stoploss = (
self.edge.stoploss(pair=trade.pair)
if self.edge else
trade.stop_loss_pct / trade.leverage
stop_price = trade.stoploss_or_liquidation
if self.edge:
stoploss = self.edge.stoploss(pair=trade.pair)
stop_price = (
trade.open_rate * (1 - stoploss) if trade.is_short
else trade.open_rate * (1 + stoploss)
)
if trade.is_short:
stop_price = trade.open_rate * (1 - stoploss)
else:
stop_price = trade.open_rate * (1 + stoploss)
if self.create_stoploss_order(trade=trade, stop_price=stop_price):
# The above will return False if the placement failed and the trade was force-sold.