sell_type -> exit_type

This commit is contained in:
Matthias 2022-04-03 11:18:36 +02:00
parent 2d2bea17e7
commit 8acffbc1d8
2 changed files with 11 additions and 11 deletions

View File

@ -905,7 +905,7 @@ class IStrategy(ABC, HyperStrategyMixin):
custom_reason = None
if sell_signal in (ExitType.CUSTOM_SELL, ExitType.SELL_SIGNAL):
logger.debug(f"{trade.pair} - Sell signal received. "
f"sell_type=ExitType.{sell_signal.name}" +
f"exit_type=ExitType.{sell_signal.name}" +
(f", custom_reason={custom_reason}" if custom_reason else ""))
return ExitCheckTuple(exit_type=sell_signal, exit_reason=custom_reason)
@ -914,12 +914,12 @@ class IStrategy(ABC, HyperStrategyMixin):
# ROI (if not stoploss)
# Stoploss
if roi_reached and stoplossflag.exit_type != ExitType.STOP_LOSS:
logger.debug(f"{trade.pair} - Required profit reached. sell_type=ExitType.ROI")
logger.debug(f"{trade.pair} - Required profit reached. exit_type=ExitType.ROI")
return ExitCheckTuple(exit_type=ExitType.ROI)
if stoplossflag.exit_flag:
logger.debug(f"{trade.pair} - Stoploss hit. sell_type={stoplossflag.exit_type}")
logger.debug(f"{trade.pair} - Stoploss hit. exit_type={stoplossflag.exit_type}")
return stoplossflag
# This one is noisy, commented out...
@ -988,11 +988,11 @@ class IStrategy(ABC, HyperStrategyMixin):
if ((sl_higher_long or sl_lower_short) and
(not self.order_types.get('stoploss_on_exchange') or self.config['dry_run'])):
sell_type = ExitType.STOP_LOSS
exit_type = ExitType.STOP_LOSS
# If initial stoploss is not the same as current one then it is trailing.
if trade.initial_stop_loss != trade.stop_loss:
sell_type = ExitType.TRAILING_STOP_LOSS
exit_type = ExitType.TRAILING_STOP_LOSS
logger.debug(
f"{trade.pair} - HIT STOP: current price at "
f"{((high if trade.is_short else low) or current_rate):.6f}, "
@ -1007,7 +1007,7 @@ class IStrategy(ABC, HyperStrategyMixin):
logger.debug(f"{trade.pair} - Trailing stop saved "
f"{new_stoploss:.6f}")
return ExitCheckTuple(exit_type=sell_type)
return ExitCheckTuple(exit_type=exit_type)
return ExitCheckTuple(exit_type=ExitType.NONE)

View File

@ -2268,7 +2268,7 @@ def test_handle_trade_roi(default_conf_usdt, ticker_usdt, limit_order_open, fee,
caplog.clear()
patch_get_signal(freqtrade)
assert freqtrade.handle_trade(trade)
assert log_has("ETH/USDT - Required profit reached. sell_type=ExitType.ROI",
assert log_has("ETH/USDT - Required profit reached. exit_type=ExitType.ROI",
caplog)
@ -2310,7 +2310,7 @@ def test_handle_trade_use_sell_signal(
else:
patch_get_signal(freqtrade, enter_long=False, exit_long=True)
assert freqtrade.handle_trade(trade)
assert log_has("ETH/USDT - Sell signal received. sell_type=ExitType.SELL_SIGNAL",
assert log_has("ETH/USDT - Sell signal received. exit_type=ExitType.SELL_SIGNAL",
caplog)
@ -3628,7 +3628,7 @@ def test_execute_trade_exit_insufficient_funds_error(default_conf_usdt, ticker_u
assert mock_insuf.call_count == 1
@pytest.mark.parametrize('profit_only,bid,ask,handle_first,handle_second,sell_type,is_short', [
@pytest.mark.parametrize('profit_only,bid,ask,handle_first,handle_second,exit_type,is_short', [
# Enable profit
(True, 2.18, 2.2, False, True, ExitType.SELL_SIGNAL.value, False),
(True, 2.18, 2.2, False, True, ExitType.SELL_SIGNAL.value, True),
@ -3645,7 +3645,7 @@ def test_execute_trade_exit_insufficient_funds_error(default_conf_usdt, ticker_u
])
def test_sell_profit_only(
default_conf_usdt, limit_order, limit_order_open, is_short,
fee, mocker, profit_only, bid, ask, handle_first, handle_second, sell_type) -> None:
fee, mocker, profit_only, bid, ask, handle_first, handle_second, exit_type) -> None:
patch_RPCManager(mocker)
patch_exchange(mocker)
eside = enter_side(is_short)
@ -3669,7 +3669,7 @@ def test_sell_profit_only(
})
freqtrade = FreqtradeBot(default_conf_usdt)
patch_get_signal(freqtrade, enter_short=is_short, enter_long=not is_short)
if sell_type == ExitType.SELL_SIGNAL.value:
if exit_type == ExitType.SELL_SIGNAL.value:
freqtrade.strategy.min_roi_reached = MagicMock(return_value=False)
else:
freqtrade.strategy.stop_loss_reached = MagicMock(return_value=ExitCheckTuple(