sell_flag -> exit_flag
This commit is contained in:
parent
69c0e028c2
commit
a07cf45968
@ -1039,7 +1039,7 @@ class FreqtradeBot(LoggingMixin):
|
||||
force_stoploss=self.edge.stoploss(trade.pair) if self.edge else 0
|
||||
)
|
||||
|
||||
if should_exit.sell_flag:
|
||||
if should_exit.exit_flag:
|
||||
logger.info(f'Exit for {trade.pair} detected. Reason: {should_exit.exit_type}'
|
||||
f'Tag: {exit_tag if exit_tag is not None else "None"}')
|
||||
self.execute_trade_exit(trade, exit_rate, should_exit, exit_tag=exit_tag)
|
||||
|
@ -388,7 +388,7 @@ class Backtesting:
|
||||
low=sell_row[LOW_IDX], high=sell_row[HIGH_IDX]
|
||||
)
|
||||
|
||||
if sell.sell_flag:
|
||||
if sell.exit_flag:
|
||||
trade.close_date = sell_candle_time
|
||||
|
||||
trade_dur = int((trade.close_date_utc - trade.open_date_utc).total_seconds() // 60)
|
||||
|
@ -42,7 +42,7 @@ class ExitCheckTuple:
|
||||
self.exit_reason = exit_reason or exit_type.value
|
||||
|
||||
@property
|
||||
def sell_flag(self):
|
||||
def exit_flag(self):
|
||||
return self.exit_type != ExitType.NONE
|
||||
|
||||
|
||||
@ -825,7 +825,7 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
logger.debug(f"{trade.pair} - Required profit reached. exit_type=ExitType.ROI")
|
||||
return ExitCheckTuple(exit_type=ExitType.ROI)
|
||||
|
||||
if stoplossflag.sell_flag:
|
||||
if stoplossflag.exit_flag:
|
||||
|
||||
logger.debug(f"{trade.pair} - Stoploss hit. exit_type={stoplossflag.exit_type}")
|
||||
return stoplossflag
|
||||
|
@ -442,9 +442,9 @@ def test_stop_loss_reached(default_conf, fee, profit, adjusted, expected, traili
|
||||
assert isinstance(sl_flag, ExitCheckTuple)
|
||||
assert sl_flag.exit_type == expected
|
||||
if expected == ExitType.NONE:
|
||||
assert sl_flag.sell_flag is False
|
||||
assert sl_flag.exit_flag is False
|
||||
else:
|
||||
assert sl_flag.sell_flag is True
|
||||
assert sl_flag.exit_flag is True
|
||||
assert round(trade.stop_loss, 2) == adjusted
|
||||
|
||||
sl_flag = strategy.stop_loss_reached(current_rate=trade.open_rate * (1 + profit2), trade=trade,
|
||||
@ -452,9 +452,9 @@ def test_stop_loss_reached(default_conf, fee, profit, adjusted, expected, traili
|
||||
force_stoploss=0, high=None)
|
||||
assert sl_flag.exit_type == expected2
|
||||
if expected2 == ExitType.NONE:
|
||||
assert sl_flag.sell_flag is False
|
||||
assert sl_flag.exit_flag is False
|
||||
else:
|
||||
assert sl_flag.sell_flag is True
|
||||
assert sl_flag.exit_flag is True
|
||||
assert round(trade.stop_loss, 2) == adjusted2
|
||||
|
||||
strategy.custom_stoploss = original_stopvalue
|
||||
@ -479,14 +479,14 @@ def test_custom_exit(default_conf, fee, caplog) -> None:
|
||||
enter=False, exit_=False,
|
||||
low=None, high=None)
|
||||
|
||||
assert res.sell_flag is False
|
||||
assert res.exit_flag is False
|
||||
assert res.exit_type == ExitType.NONE
|
||||
|
||||
strategy.custom_exit = MagicMock(return_value=True)
|
||||
res = strategy.should_exit(trade, 1, now,
|
||||
enter=False, exit_=False,
|
||||
low=None, high=None)
|
||||
assert res.sell_flag is True
|
||||
assert res.exit_flag is True
|
||||
assert res.exit_type == ExitType.CUSTOM_EXIT
|
||||
assert res.exit_reason == 'custom_exit'
|
||||
|
||||
@ -496,7 +496,7 @@ def test_custom_exit(default_conf, fee, caplog) -> None:
|
||||
enter=False, exit_=False,
|
||||
low=None, high=None)
|
||||
assert res.exit_type == ExitType.CUSTOM_EXIT
|
||||
assert res.sell_flag is True
|
||||
assert res.exit_flag is True
|
||||
assert res.exit_reason == 'hello world'
|
||||
|
||||
caplog.clear()
|
||||
@ -505,7 +505,7 @@ def test_custom_exit(default_conf, fee, caplog) -> None:
|
||||
enter=False, exit_=False,
|
||||
low=None, high=None)
|
||||
assert res.exit_type == ExitType.CUSTOM_EXIT
|
||||
assert res.sell_flag is True
|
||||
assert res.exit_flag is True
|
||||
assert res.exit_reason == 'h' * 64
|
||||
assert log_has_re('Custom sell reason returned from custom_exit is too long.*', caplog)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user