From 4d1488498cb3b884d21eb8c4d3690810bb5d79bc Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 11 Oct 2019 08:55:31 +0200 Subject: [PATCH] stoploss_reached should not use config --- freqtrade/strategy/interface.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index b35ebabbb..4d18e5232 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -79,7 +79,7 @@ class IStrategy(ABC): # trailing stoploss trailing_stop: bool = False trailing_stop_positive: float - trailing_stop_positive_offset: float + trailing_stop_positive_offset: float = 0.0 trailing_only_offset_is_reached = False # associated ticker interval @@ -347,22 +347,20 @@ class IStrategy(ABC): decides to sell or not :param current_profit: current profit in percent """ - trailing_stop = self.config.get('trailing_stop', False) stop_loss_value = force_stoploss if force_stoploss else self.stoploss # Initiate stoploss with open_rate. Does nothing if stoploss is already set. trade.adjust_stop_loss(trade.open_rate, stop_loss_value, initial=True) - if trailing_stop: + if self.trailing_stop: # trailing stoploss handling - sl_offset = self.config.get('trailing_stop_positive_offset') or 0.0 - tsl_only_offset = self.config.get('trailing_only_offset_is_reached', False) + sl_offset = self.trailing_stop_positive_offset # Make sure current_profit is calculated using high for backtesting. high_profit = current_profit if not high else trade.calc_profit_percent(high) # Don't update stoploss if trailing_only_offset_is_reached is true. - if not (tsl_only_offset and high_profit < sl_offset): + if not (self.trailing_only_offset_is_reached and high_profit < sl_offset): # Specific handling for trailing_stop_positive if 'trailing_stop_positive' in self.config and high_profit > sl_offset: # Ignore mypy error check in configuration that this is a float