mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
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
|
||||
"""
|
||||
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
|
||||
)
|
||||
|
||||
|
|
|
@ -333,10 +333,11 @@ class Backtesting:
|
|||
|
||||
def _get_sell_trade_entry(self, trade: LocalTrade, sell_row: Tuple) -> Optional[LocalTrade]:
|
||||
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(
|
||||
trade, sell_row[OPEN_IDX], sell_candle_time, # type: ignore
|
||||
enter_long=sell_row[LONG_IDX], enter_short=sell_row[SHORT_IDX],
|
||||
exit_long=sell_row[ELONG_IDX], exit_short=sell_row[ESHORT_IDX],
|
||||
enter=enter, exit_=exit_,
|
||||
low=sell_row[LOW_IDX], high=sell_row[HIGH_IDX]
|
||||
)
|
||||
|
||||
|
|
|
@ -666,8 +666,7 @@ class IStrategy(ABC, HyperStrategyMixin):
|
|||
return False
|
||||
|
||||
def should_exit(self, trade: Trade, rate: float, date: datetime, *,
|
||||
enter_long: bool, enter_short: bool,
|
||||
exit_long: bool, exit_short: bool,
|
||||
enter: bool, exit_: bool,
|
||||
low: float = None, high: float = None,
|
||||
force_stoploss: float = 0) -> SellCheckTuple:
|
||||
"""
|
||||
|
@ -679,9 +678,6 @@ class IStrategy(ABC, HyperStrategyMixin):
|
|||
: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_profit = trade.calc_profit_ratio(current_rate)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user