From 516217b6cbff7054fd31dad104c2c6a5278c8b7b Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 2 Jan 2019 13:34:08 +0100 Subject: [PATCH 1/2] Stop loss should also be shown when trailing is active --- freqtrade/strategy/interface.py | 3 ++- freqtrade/tests/test_freqtradebot.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 2d4de2358..4b7061f18 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -278,7 +278,8 @@ class IStrategy(ABC): # evaluate if the stoploss was hit if self.stoploss is not None and trade.stop_loss >= current_rate: selltype = SellType.STOP_LOSS - if trailing_stop: + # Trailing stop (and rate did move) + if trailing_stop and trade.open_rate != trade.max_rate: selltype = SellType.TRAILING_STOP_LOSS logger.debug( f"HIT STOP: current price at {current_rate:.6f}, " diff --git a/freqtrade/tests/test_freqtradebot.py b/freqtrade/tests/test_freqtradebot.py index 0b6a14112..2b14c586b 100644 --- a/freqtrade/tests/test_freqtradebot.py +++ b/freqtrade/tests/test_freqtradebot.py @@ -2066,6 +2066,7 @@ def test_trailing_stop_loss(default_conf, limit_buy_order, fee, markets, caplog, trade = Trade.query.first() trade.update(limit_buy_order) + trade.max_rate = trade.open_rate * 1.003 caplog.set_level(logging.DEBUG) # Sell as trailing-stop is reached assert freqtrade.handle_trade(trade) is True From 3329ffd071baf5b7c711082b3ffd2735d14dcecc Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 2 Jan 2019 14:44:17 +0100 Subject: [PATCH 2/2] improve comment --- freqtrade/strategy/interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 4b7061f18..694430fd6 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -278,7 +278,7 @@ class IStrategy(ABC): # evaluate if the stoploss was hit if self.stoploss is not None and trade.stop_loss >= current_rate: selltype = SellType.STOP_LOSS - # Trailing stop (and rate did move) + # If Trailing stop (and max-rate did move above open rate) if trailing_stop and trade.open_rate != trade.max_rate: selltype = SellType.TRAILING_STOP_LOSS logger.debug(