strategy.should_exit: custom sell reason -> custom exit long reason

This commit is contained in:
Sam Germain 2022-01-04 23:30:04 -06:00
parent 295050b80b
commit 6b4971026d
2 changed files with 4 additions and 4 deletions

View File

@ -797,7 +797,6 @@ class IStrategy(ABC, HyperStrategyMixin):
if exit_: if exit_:
exit_signal = ExitType.EXIT_SIGNAL exit_signal = ExitType.EXIT_SIGNAL
else: else:
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=date, current_rate=current_rate, pair=trade.pair, trade=trade, current_time=date, current_rate=current_rate,
current_profit=current_profit) current_profit=current_profit)
@ -805,8 +804,8 @@ class IStrategy(ABC, HyperStrategyMixin):
exit_signal = ExitType.CUSTOM_EXIT exit_signal = ExitType.CUSTOM_EXIT
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 exit reason returned from '
f'custom_{trade_type} is too long and was trimmed' f'custom_exit is too long and was trimmed'
f'to {CUSTOM_EXIT_MAX_LENGTH} characters.') f'to {CUSTOM_EXIT_MAX_LENGTH} characters.')
custom_reason = custom_reason[:CUSTOM_EXIT_MAX_LENGTH] custom_reason = custom_reason[:CUSTOM_EXIT_MAX_LENGTH]
else: else:

View File

@ -507,7 +507,8 @@ def test_custom_exit(default_conf, fee, caplog) -> None:
assert res.exit_type == ExitType.CUSTOM_EXIT assert res.exit_type == ExitType.CUSTOM_EXIT
assert res.exit_flag is True assert res.exit_flag is True
assert res.exit_reason == 'h' * 64 assert res.exit_reason == 'h' * 64
assert log_has_re('Custom exit reason returned from custom_exit is too long.*', caplog) assert log_has_re(
'Custom exit reason returned from custom_exit is too long.*', caplog)
@pytest.mark.parametrize('side', TRADE_SIDES) @pytest.mark.parametrize('side', TRADE_SIDES)