From bd6f2cfc5d13468dc1cd8d6f707b6e86272016fe Mon Sep 17 00:00:00 2001 From: Santa Date: Tue, 28 Sep 2021 08:54:29 +0700 Subject: [PATCH] Add deep clone to order clone to make old order info not affect to clone order in the future --- backtrader/order.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backtrader/order.py b/backtrader/order.py index 458a35e9f..478719176 100644 --- a/backtrader/order.py +++ b/backtrader/order.py @@ -384,12 +384,14 @@ def __init__(self): else: self.dteos = 0.0 - def clone(self): + def clone(self, deep=True): # status, triggered and executed are the only moving parts in order # status and triggered are covered by copy # executed has to be replaced with an intelligent clone of itself obj = copy(self) obj.executed = self.executed.clone() + if deep: + obj.info = self.info.copy() return obj # status could change in next to completed def getstatusname(self, status=None):