Provide strategy with copied objects

avoids accidental modification of crucial elements in a trade object
part of #5828
This commit is contained in:
Matthias 2021-11-08 19:59:29 +01:00
parent e4cca63163
commit ae0e72a945
1 changed files with 4 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import logging
from copy import deepcopy
from freqtrade.exceptions import StrategyError
@ -14,6 +15,9 @@ def strategy_safe_wrapper(f, message: str = "", default_retval=None, supress_err
"""
def wrapper(*args, **kwargs):
try:
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(