Update local variable

This commit is contained in:
Matthias 2022-04-03 19:22:59 +02:00
parent 8acffbc1d8
commit 9dfb3db1aa

View File

@ -876,7 +876,7 @@ class IStrategy(ABC, HyperStrategyMixin):
and self.min_roi_reached(trade=trade, current_profit=current_profit, and self.min_roi_reached(trade=trade, current_profit=current_profit,
current_time=current_time)) current_time=current_time))
sell_signal = ExitType.NONE exit_signal = ExitType.NONE
custom_reason = '' custom_reason = ''
# use provided rate in backtesting, not high/low. # use provided rate in backtesting, not high/low.
current_rate = rate current_rate = rate
@ -887,14 +887,14 @@ class IStrategy(ABC, HyperStrategyMixin):
pass pass
elif self.use_sell_signal and not enter: elif self.use_sell_signal and not enter:
if exit_: if exit_:
sell_signal = ExitType.SELL_SIGNAL exit_signal = ExitType.SELL_SIGNAL
else: else:
trade_type = "exit_short" if trade.is_short else "sell" trade_type = "exit_short" if trade.is_short else "sell"
custom_reason = strategy_safe_wrapper(self.custom_exit, default_retval=False)( custom_reason = strategy_safe_wrapper(self.custom_exit, default_retval=False)(
pair=trade.pair, trade=trade, current_time=current_time, pair=trade.pair, trade=trade, current_time=current_time,
current_rate=current_rate, current_profit=current_profit) current_rate=current_rate, current_profit=current_profit)
if custom_reason: if custom_reason:
sell_signal = ExitType.CUSTOM_SELL exit_signal = ExitType.CUSTOM_SELL
if isinstance(custom_reason, str): if isinstance(custom_reason, str):
if len(custom_reason) > CUSTOM_EXIT_MAX_LENGTH: if len(custom_reason) > CUSTOM_EXIT_MAX_LENGTH:
logger.warning(f'Custom {trade_type} reason returned from ' logger.warning(f'Custom {trade_type} reason returned from '
@ -903,11 +903,11 @@ class IStrategy(ABC, HyperStrategyMixin):
custom_reason = custom_reason[:CUSTOM_EXIT_MAX_LENGTH] custom_reason = custom_reason[:CUSTOM_EXIT_MAX_LENGTH]
else: else:
custom_reason = None custom_reason = None
if sell_signal in (ExitType.CUSTOM_SELL, ExitType.SELL_SIGNAL): if exit_signal in (ExitType.CUSTOM_SELL, ExitType.SELL_SIGNAL):
logger.debug(f"{trade.pair} - Sell signal received. " logger.debug(f"{trade.pair} - Sell signal received. "
f"exit_type=ExitType.{sell_signal.name}" + f"exit_type=ExitType.{exit_signal.name}" +
(f", custom_reason={custom_reason}" if custom_reason else "")) (f", custom_reason={custom_reason}" if custom_reason else ""))
return ExitCheckTuple(exit_type=sell_signal, exit_reason=custom_reason) return ExitCheckTuple(exit_type=exit_signal, exit_reason=custom_reason)
# Sequence: # Sequence:
# Exit-signal # Exit-signal