mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-13 03:33:55 +00:00
Merge pull request #1460 from freqtrade/fix/stop_loss_result
Stop loss should also be shown when trailing is active
This commit is contained in:
commit
3b5785884f
|
@ -278,7 +278,8 @@ class IStrategy(ABC):
|
||||||
# evaluate if the stoploss was hit
|
# evaluate if the stoploss was hit
|
||||||
if self.stoploss is not None and trade.stop_loss >= current_rate:
|
if self.stoploss is not None and trade.stop_loss >= current_rate:
|
||||||
selltype = SellType.STOP_LOSS
|
selltype = SellType.STOP_LOSS
|
||||||
if trailing_stop:
|
# 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
|
selltype = SellType.TRAILING_STOP_LOSS
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"HIT STOP: current price at {current_rate:.6f}, "
|
f"HIT STOP: current price at {current_rate:.6f}, "
|
||||||
|
|
|
@ -2066,6 +2066,7 @@ def test_trailing_stop_loss(default_conf, limit_buy_order, fee, markets, caplog,
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
trade.update(limit_buy_order)
|
trade.update(limit_buy_order)
|
||||||
|
trade.max_rate = trade.open_rate * 1.003
|
||||||
caplog.set_level(logging.DEBUG)
|
caplog.set_level(logging.DEBUG)
|
||||||
# Sell as trailing-stop is reached
|
# Sell as trailing-stop is reached
|
||||||
assert freqtrade.handle_trade(trade) is True
|
assert freqtrade.handle_trade(trade) is True
|
||||||
|
|
Loading…
Reference in New Issue
Block a user