diff --git a/docs/strategy-callbacks.md b/docs/strategy-callbacks.md index 3f6dce5ce..a63aa9703 100644 --- a/docs/strategy-callbacks.md +++ b/docs/strategy-callbacks.md @@ -527,7 +527,7 @@ class AwesomeStrategy(IStrategy): # ... populate_* methods - def custom_roi(self, pair: str, trade: Trade, current_time: datetime, + def custom_roi(self, pair: str, trade: Trade, current_time: datetime, trade_duration: int, entry_tag: str | None, side: str, **kwargs) -> float | None: """ Custom ROI logic, returns a new minimum ROI threshold (as a ratio, e.g., 0.05 for +5%). @@ -540,6 +540,7 @@ class AwesomeStrategy(IStrategy): :param pair: Pair that's currently analyzed. :param trade: trade object. :param current_time: datetime object, containing the current datetime. + :param trade_duration: Current trade duration in minutes. :param entry_tag: Optional entry_tag (buy_tag) if provided with the buy signal. :param side: 'long' or 'short' - indicating the direction of the current trade. :param **kwargs: Ensure to keep this here so updates to this won't break your strategy. @@ -561,7 +562,7 @@ class AwesomeStrategy(IStrategy): # ... populate_* methods - def custom_roi(self, pair: str, trade: Trade, current_time: datetime, + def custom_roi(self, pair: str, trade: Trade, current_time: datetime, trade_duration: int, entry_tag: str | None, side: str, **kwargs) -> float | None: stake = trade.stake_currency @@ -587,7 +588,7 @@ class AwesomeStrategy(IStrategy): # ... populate_* methods - def custom_roi(self, pair: str, trade: Trade, current_time: datetime, + def custom_roi(self, pair: str, trade: Trade, current_time: datetime, trade_duration: int, entry_tag: str | None, side: str, **kwargs) -> float | None: roi_by_tag = { @@ -616,7 +617,7 @@ class AwesomeStrategy(IStrategy): # <...> dataframe["atr"] = ta.ATR(dataframe, timeperiod=10) - def custom_roi(self, pair: str, trade: Trade, current_time: datetime, + def custom_roi(self, pair: str, trade: Trade, current_time: datetime, trade_duration: int, entry_tag: str | None, side: str, **kwargs) -> float | None: dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 4bdaa9699..51a89cf8c 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -472,6 +472,7 @@ class IStrategy(ABC, HyperStrategyMixin): pair: str, trade: Trade, current_time: datetime, + trade_duration: int, entry_tag: str | None, side: str, **kwargs, @@ -487,6 +488,7 @@ class IStrategy(ABC, HyperStrategyMixin): :param pair: Pair that's currently analyzed. :param trade: trade object. :param current_time: datetime object, containing the current datetime. + :param trade_duration: Current trade duration in minutes. :param entry_tag: Optional entry_tag (buy_tag) if provided with the buy signal. :param side: 'long' or 'short' - indicating the direction of the current trade. :param **kwargs: Ensure to keep this here so updates to this won't break your strategy. @@ -1686,6 +1688,7 @@ class IStrategy(ABC, HyperStrategyMixin): pair=trade.pair, trade=trade, current_time=current_time, + trade_duration=trade_dur, entry_tag=trade.enter_tag, side=trade.trade_direction, )