Skip to content

Commit 25077a1

Browse files
committed
feat: write empty "custom_roi" with advanced strategy template
1 parent b3b3bf6 commit 25077a1

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

freqtrade/templates/strategy_subtemplates/strategy_methods_advanced.j2

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,37 @@ def custom_stake_amount(
135135
"""
136136
return proposed_stake
137137

138+
use_custom_roi = True
139+
140+
def custom_roi(
141+
self,
142+
pair: str,
143+
trade: Trade,
144+
current_time: datetime,
145+
trade_duration: int,
146+
entry_tag: str | None,
147+
side: str,
148+
**kwargs,
149+
) -> float | None:
150+
"""
151+
Custom ROI logic, returns a new minimum ROI threshold (as a ratio, e.g., 0.05 for +5%).
152+
Only called when use_custom_roi is set to True.
153+
154+
If used at the same time as minimal_roi, an exit will be triggered when the lower
155+
threshold is reached. Example: If minimal_roi = {"0": 0.01} and custom_roi returns 0.05,
156+
an exit will be triggered if profit reaches 5%.
157+
158+
:param pair: Pair that's currently analyzed.
159+
:param trade: trade object.
160+
:param current_time: datetime object, containing the current datetime.
161+
:param trade_duration: Current trade duration in minutes.
162+
:param entry_tag: Optional entry_tag (buy_tag) if provided with the buy signal.
163+
:param side: 'long' or 'short' - indicating the direction of the current trade.
164+
:param **kwargs: Ensure to keep this here so updates to this won't break your strategy.
165+
:return float: New ROI value as a ratio, or None to fall back to minimal_roi logic.
166+
"""
167+
return None
168+
138169
use_custom_stoploss = True
139170

140171
def custom_stoploss(

0 commit comments

Comments
 (0)