Skip to content

Commit 90b1e15

Browse files
committed
feat: Skip trade deepcopy if the callback isn't implemented
closes freqtrade#10946
1 parent 9c825fb commit 90b1e15

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

freqtrade/strategy/strategy_wrapper.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ def strategy_safe_wrapper(f: F, message: str = "", default_retval=None, supress_
2323
@wraps(f)
2424
def wrapper(*args, **kwargs):
2525
try:
26-
if "trade" in kwargs:
27-
# Protect accidental modifications from within the strategy
28-
kwargs["trade"] = deepcopy(kwargs["trade"])
26+
if not (getattr(f, "__qualname__", "")).startswith("IStrategy."):
27+
# Don't deep-copy if the function is not implemented in the user strategy.``
28+
if "trade" in kwargs:
29+
# Protect accidental modifications from within the strategy
30+
kwargs["trade"] = deepcopy(kwargs["trade"])
2931
return f(*args, **kwargs)
3032
except ValueError as error:
3133
logger.warning(f"{message}Strategy caused the following exception: {error}{f}")

0 commit comments

Comments
 (0)