summaryrefslogtreecommitdiff
path: root/app/trading/models.py
diff options
context:
space:
mode:
authorlxf <sng@luxagraf.net>2022-01-06 11:09:04 -0500
committerlxf <sng@luxagraf.net>2022-01-06 11:09:04 -0500
commit96232c02fe68f7f8c1213ce3e81c9c594ac4e9e5 (patch)
treedb8fd24fd10236c6c59ba20871e5774e755da434 /app/trading/models.py
parent1b74c74fb154385d861d8a74feca75826d1c8a4b (diff)
trad: fixed a bug in pl when saving
Diffstat (limited to 'app/trading/models.py')
-rw-r--r--app/trading/models.py4
1 files changed, 3 insertions, 1 deletions
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()