mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
sell_type -> exit_type
This commit is contained in:
parent
2d2bea17e7
commit
8acffbc1d8
|
@ -905,7 +905,7 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||||
custom_reason = None
|
custom_reason = None
|
||||||
if sell_signal in (ExitType.CUSTOM_SELL, ExitType.SELL_SIGNAL):
|
if sell_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"sell_type=ExitType.{sell_signal.name}" +
|
f"exit_type=ExitType.{sell_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=sell_signal, exit_reason=custom_reason)
|
||||||
|
|
||||||
|
@ -914,12 +914,12 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||||
# ROI (if not stoploss)
|
# ROI (if not stoploss)
|
||||||
# Stoploss
|
# Stoploss
|
||||||
if roi_reached and stoplossflag.exit_type != ExitType.STOP_LOSS:
|
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)
|
return ExitCheckTuple(exit_type=ExitType.ROI)
|
||||||
|
|
||||||
if stoplossflag.exit_flag:
|
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
|
return stoplossflag
|
||||||
|
|
||||||
# This one is noisy, commented out...
|
# This one is noisy, commented out...
|
||||||
|
@ -988,11 +988,11 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||||
if ((sl_higher_long or sl_lower_short) and
|
if ((sl_higher_long or sl_lower_short) and
|
||||||
(not self.order_types.get('stoploss_on_exchange') or self.config['dry_run'])):
|
(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 initial stoploss is not the same as current one then it is trailing.
|
||||||
if trade.initial_stop_loss != trade.stop_loss:
|
if trade.initial_stop_loss != trade.stop_loss:
|
||||||
sell_type = ExitType.TRAILING_STOP_LOSS
|
exit_type = ExitType.TRAILING_STOP_LOSS
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"{trade.pair} - HIT STOP: current price at "
|
f"{trade.pair} - HIT STOP: current price at "
|
||||||
f"{((high if trade.is_short else low) or current_rate):.6f}, "
|
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 "
|
logger.debug(f"{trade.pair} - Trailing stop saved "
|
||||||
f"{new_stoploss:.6f}")
|
f"{new_stoploss:.6f}")
|
||||||
|
|
||||||
return ExitCheckTuple(exit_type=sell_type)
|
return ExitCheckTuple(exit_type=exit_type)
|
||||||
|
|
||||||
return ExitCheckTuple(exit_type=ExitType.NONE)
|
return ExitCheckTuple(exit_type=ExitType.NONE)
|
||||||
|
|
||||||
|
|
|
@ -2268,7 +2268,7 @@ def test_handle_trade_roi(default_conf_usdt, ticker_usdt, limit_order_open, fee,
|
||||||
caplog.clear()
|
caplog.clear()
|
||||||
patch_get_signal(freqtrade)
|
patch_get_signal(freqtrade)
|
||||||
assert freqtrade.handle_trade(trade)
|
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)
|
caplog)
|
||||||
|
|
||||||
|
|
||||||
|
@ -2310,7 +2310,7 @@ def test_handle_trade_use_sell_signal(
|
||||||
else:
|
else:
|
||||||
patch_get_signal(freqtrade, enter_long=False, exit_long=True)
|
patch_get_signal(freqtrade, enter_long=False, exit_long=True)
|
||||||
assert freqtrade.handle_trade(trade)
|
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)
|
caplog)
|
||||||
|
|
||||||
|
|
||||||
|
@ -3628,7 +3628,7 @@ def test_execute_trade_exit_insufficient_funds_error(default_conf_usdt, ticker_u
|
||||||
assert mock_insuf.call_count == 1
|
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
|
# 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, False),
|
||||||
(True, 2.18, 2.2, False, True, ExitType.SELL_SIGNAL.value, True),
|
(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(
|
def test_sell_profit_only(
|
||||||
default_conf_usdt, limit_order, limit_order_open, is_short,
|
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_RPCManager(mocker)
|
||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
eside = enter_side(is_short)
|
eside = enter_side(is_short)
|
||||||
|
@ -3669,7 +3669,7 @@ def test_sell_profit_only(
|
||||||
})
|
})
|
||||||
freqtrade = FreqtradeBot(default_conf_usdt)
|
freqtrade = FreqtradeBot(default_conf_usdt)
|
||||||
patch_get_signal(freqtrade, enter_short=is_short, enter_long=not is_short)
|
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)
|
freqtrade.strategy.min_roi_reached = MagicMock(return_value=False)
|
||||||
else:
|
else:
|
||||||
freqtrade.strategy.stop_loss_reached = MagicMock(return_value=ExitCheckTuple(
|
freqtrade.strategy.stop_loss_reached = MagicMock(return_value=ExitCheckTuple(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user