From 96232c02fe68f7f8c1213ce3e81c9c594ac4e9e5 Mon Sep 17 00:00:00 2001 From: lxf Date: Thu, 6 Jan 2022 11:09:04 -0500 Subject: trad: fixed a bug in pl when saving --- app/trading/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/trading/models.py') diff --git a/app/trading/models.py b/app/trading/models.py index 10aaaf4..faac7ba 100644 --- a/app/trading/models.py +++ b/app/trading/models.py @@ -391,6 +391,7 @@ class LuxOptionPurchase(models.Model): def get_contract_count(self): return self.luxoptioncontract_set.count() + @property def profit_loss(self): total = 0 for option in self.luxoptioncontract_set.all(): @@ -428,7 +429,8 @@ class LuxOptionPurchase(models.Model): def save(self, *args, **kwargs): if self.status == 1 and not self.close_date: self.close_date = timezone.now() - if self.status == 1 and not self.pl: + if self.status == 1: + print("updating pl") self.pl = self.profit_loss super(LuxOptionPurchase, self).save() -- cgit v1.2.3-70-g09d2