feat: Skip trade deepcopy if the callback isn't implemented

closes #10946
This commit is contained in:
Matthias
2025-01-03 15:07:35 +01:00
parent 9c825fb156
commit 90b1e15eb2

View File

@@ -23,9 +23,11 @@ def strategy_safe_wrapper(f: F, message: str = "", default_retval=None, supress_
@wraps(f)
def wrapper(*args, **kwargs):
try:
if "trade" in kwargs:
# Protect accidental modifications from within the strategy
kwargs["trade"] = deepcopy(kwargs["trade"])
if not (getattr(f, "__qualname__", "")).startswith("IStrategy."):
# Don't deep-copy if the function is not implemented in the user strategy.``
if "trade" in kwargs:
# Protect accidental modifications from within the strategy
kwargs["trade"] = deepcopy(kwargs["trade"])
return f(*args, **kwargs)
except ValueError as error:
logger.warning(f"{message}Strategy caused the following exception: {error}{f}")