persistence.adjust_stop_loss accounts for leverage
This commit is contained in:
parent
ac433eebfe
commit
78194559f4
@ -566,13 +566,14 @@ class LocalTrade():
|
|||||||
# Don't modify if called with initial and nothing to do
|
# Don't modify if called with initial and nothing to do
|
||||||
return
|
return
|
||||||
|
|
||||||
|
leverage = self.leverage or 1.0
|
||||||
if self.is_short:
|
if self.is_short:
|
||||||
new_loss = float(current_price * (1 + abs(stoploss)))
|
new_loss = float(current_price * (1 + abs(stoploss / leverage)))
|
||||||
# If trading with leverage, don't set the stoploss below the liquidation price
|
# If trading with leverage, don't set the stoploss below the liquidation price
|
||||||
if self.isolated_liq:
|
if self.isolated_liq:
|
||||||
new_loss = min(self.isolated_liq, new_loss)
|
new_loss = min(self.isolated_liq, new_loss)
|
||||||
else:
|
else:
|
||||||
new_loss = float(current_price * (1 - abs(stoploss)))
|
new_loss = float(current_price * (1 - abs(stoploss / leverage)))
|
||||||
# If trading with leverage, don't set the stoploss below the liquidation price
|
# If trading with leverage, don't set the stoploss below the liquidation price
|
||||||
if self.isolated_liq:
|
if self.isolated_liq:
|
||||||
new_loss = max(self.isolated_liq, new_loss)
|
new_loss = max(self.isolated_liq, new_loss)
|
||||||
|
Loading…
Reference in New Issue
Block a user