From 6249392526d3343e8b9867dd56008e7477b636cb Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 13 Aug 2023 15:56:43 +0200 Subject: [PATCH] Add test for "allow adjustment in other direction" --- tests/persistence/test_persistence.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/persistence/test_persistence.py b/tests/persistence/test_persistence.py index a80b54244..63c3ec321 100644 --- a/tests/persistence/test_persistence.py +++ b/tests/persistence/test_persistence.py @@ -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)