Simplify should_exit interface
This commit is contained in:
parent
f3b6a0a797
commit
6524edbb4e
@ -858,7 +858,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
Check and execute trade exit
|
Check and execute trade exit
|
||||||
"""
|
"""
|
||||||
should_exit: SellCheckTuple = self.strategy.should_exit(
|
should_exit: SellCheckTuple = self.strategy.should_exit(
|
||||||
trade, sell_rate, datetime.now(timezone.utc), enter, exit_,
|
trade, sell_rate, datetime.now(timezone.utc), enter=enter, exit_=exit_,
|
||||||
force_stoploss=self.edge.stoploss(trade.pair) if self.edge else 0
|
force_stoploss=self.edge.stoploss(trade.pair) if self.edge else 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -333,10 +333,11 @@ class Backtesting:
|
|||||||
|
|
||||||
def _get_sell_trade_entry(self, trade: LocalTrade, sell_row: Tuple) -> Optional[LocalTrade]:
|
def _get_sell_trade_entry(self, trade: LocalTrade, sell_row: Tuple) -> Optional[LocalTrade]:
|
||||||
sell_candle_time = sell_row[DATE_IDX].to_pydatetime()
|
sell_candle_time = sell_row[DATE_IDX].to_pydatetime()
|
||||||
|
enter = sell_row[LONG_IDX] if trade.is_short else sell_row[SHORT_IDX]
|
||||||
|
exit_ = sell_row[ELONG_IDX] if trade.is_short else sell_row[ESHORT_IDX]
|
||||||
sell = self.strategy.should_exit(
|
sell = self.strategy.should_exit(
|
||||||
trade, sell_row[OPEN_IDX], sell_candle_time, # type: ignore
|
trade, sell_row[OPEN_IDX], sell_candle_time, # type: ignore
|
||||||
enter_long=sell_row[LONG_IDX], enter_short=sell_row[SHORT_IDX],
|
enter=enter, exit_=exit_,
|
||||||
exit_long=sell_row[ELONG_IDX], exit_short=sell_row[ESHORT_IDX],
|
|
||||||
low=sell_row[LOW_IDX], high=sell_row[HIGH_IDX]
|
low=sell_row[LOW_IDX], high=sell_row[HIGH_IDX]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -666,8 +666,7 @@ class IStrategy(ABC, HyperStrategyMixin):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def should_exit(self, trade: Trade, rate: float, date: datetime, *,
|
def should_exit(self, trade: Trade, rate: float, date: datetime, *,
|
||||||
enter_long: bool, enter_short: bool,
|
enter: bool, exit_: bool,
|
||||||
exit_long: bool, exit_short: bool,
|
|
||||||
low: float = None, high: float = None,
|
low: float = None, high: float = None,
|
||||||
force_stoploss: float = 0) -> SellCheckTuple:
|
force_stoploss: float = 0) -> SellCheckTuple:
|
||||||
"""
|
"""
|
||||||
@ -679,9 +678,6 @@ class IStrategy(ABC, HyperStrategyMixin):
|
|||||||
:return: True if trade should be exited, False otherwise
|
:return: True if trade should be exited, False otherwise
|
||||||
"""
|
"""
|
||||||
|
|
||||||
enter = enter_short if trade.is_short else enter_long
|
|
||||||
exit_ = exit_short if trade.is_short else exit_long
|
|
||||||
|
|
||||||
current_rate = rate
|
current_rate = rate
|
||||||
current_profit = trade.calc_profit_ratio(current_rate)
|
current_profit = trade.calc_profit_ratio(current_rate)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user