No specific handling for trailing_stop_positive

This commit is contained in:
hroff-1902 2019-10-11 22:59:13 +03:00
parent ff7a3cc885
commit 4c1705fb1e
2 changed files with 6 additions and 4 deletions

View File

@ -95,7 +95,10 @@ class StrategyResolver(IResolver):
logger.info("Override strategy '%s' with value in config file: %s.", logger.info("Override strategy '%s' with value in config file: %s.",
attribute, config[attribute]) attribute, config[attribute])
elif hasattr(self.strategy, attribute): elif hasattr(self.strategy, attribute):
config[attribute] = getattr(self.strategy, attribute) val = getattr(self.strategy, attribute)
# None's cannot exist in the config, so do not copy them
if val is not None:
config[attribute] = val
# Explicitly check for None here as other "falsy" values are possible # Explicitly check for None here as other "falsy" values are possible
elif default is not None: elif default is not None:
setattr(self.strategy, attribute, default) setattr(self.strategy, attribute, default)

View File

@ -78,7 +78,7 @@ class IStrategy(ABC):
# trailing stoploss # trailing stoploss
trailing_stop: bool = False trailing_stop: bool = False
trailing_stop_positive: float trailing_stop_positive: Optional[float] = None
trailing_stop_positive_offset: float = 0.0 trailing_stop_positive_offset: float = 0.0
trailing_only_offset_is_reached = False trailing_only_offset_is_reached = False
@ -361,8 +361,7 @@ class IStrategy(ABC):
# Don't update stoploss if trailing_only_offset_is_reached is true. # Don't update stoploss if trailing_only_offset_is_reached is true.
if not (self.trailing_only_offset_is_reached 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 self.trailing_stop_positive is not None and high_profit > sl_offset:
if 'trailing_stop_positive' in self.__dict__ and high_profit > sl_offset:
# Ignore mypy error check in configuration that this is a float # Ignore mypy error check in configuration that this is a float
stop_loss_value = self.trailing_stop_positive stop_loss_value = self.trailing_stop_positive
logger.debug(f"{trade.pair} - Using positive stoploss: {stop_loss_value} " logger.debug(f"{trade.pair} - Using positive stoploss: {stop_loss_value} "