Disable stoploss on exchange for dry-runs

This commit is contained in:
Matthias 2019-08-11 14:14:51 +02:00
parent 8ba7657007
commit 176beefa88
1 changed files with 8 additions and 2 deletions

View File

@ -81,7 +81,7 @@ class StrategyResolver(IResolver):
key=lambda t: t[0]))
self.strategy.stoploss = float(self.strategy.stoploss)
self._strategy_sanity_validations()
self._strategy_sanity_validations(config)
def _override_attribute_helper(self, config, attribute: str, default):
"""
@ -102,7 +102,7 @@ class StrategyResolver(IResolver):
setattr(self.strategy, attribute, default)
config[attribute] = default
def _strategy_sanity_validations(self):
def _strategy_sanity_validations(self, config):
if not all(k in self.strategy.order_types for k in constants.REQUIRED_ORDERTYPES):
raise ImportError(f"Impossible to load Strategy '{self.strategy.__class__.__name__}'. "
f"Order-types mapping is incomplete.")
@ -111,6 +111,12 @@ class StrategyResolver(IResolver):
raise ImportError(f"Impossible to load Strategy '{self.strategy.__class__.__name__}'. "
f"Order-time-in-force mapping is incomplete.")
# Stoploss on exchange does not make sense, therefore we need to disable that.
if config.get('dry_run'):
logger.info("Disabling stoploss_on_exchange during dry-run.")
self.strategy.order_types['stoploss_on_exchange'] = False
config['order_types']['stoploss_on_exchange'] = False
def _load_strategy(
self, strategy_name: str, config: dict, extra_dir: Optional[str] = None) -> IStrategy:
"""