Add test for "allow adjustment in other direction"

This commit is contained in:
Matthias 2023-08-13 15:56:43 +02:00
parent 4da8c91161
commit 6249392526

View File

@ -87,6 +87,13 @@ def test_set_stop_loss_liquidation(fee):
assert trade.stop_loss_pct == -0.2
assert trade.initial_stop_loss == 1.8
# Lower stop with "allow_refresh" does move stoploss
trade.adjust_stop_loss(1.8, 0.22, allow_refresh=True)
assert trade.liquidation_price == 0.11
assert trade.stop_loss == 1.602
assert trade.stop_loss_pct == -0.22
assert trade.initial_stop_loss == 1.8
# higher stop does move stoploss
trade.adjust_stop_loss(2.1, 0.1)
assert trade.liquidation_price == 0.11
@ -143,6 +150,13 @@ def test_set_stop_loss_liquidation(fee):
assert trade.stop_loss_pct == -0.2
assert trade.initial_stop_loss == 2.2
# Stop does move stop higher with "allow_refresh"
trade.adjust_stop_loss(2.0, 0.3, allow_refresh=True)
assert trade.liquidation_price == 3.8
assert trade.stop_loss == 2.3
assert trade.stop_loss_pct == -0.3
assert trade.initial_stop_loss == 2.2
# Stoploss does move lower
trade.set_liquidation_price(1.5)
trade.adjust_stop_loss(1.8, 0.1)