summaryrefslogtreecommitdiff
path: root/app/trading/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/trading/models.py')
-rw-r--r--app/trading/models.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/app/trading/models.py b/app/trading/models.py
index be226e9..026c9cb 100644
--- a/app/trading/models.py
+++ b/app/trading/models.py
@@ -215,7 +215,7 @@ class LuxOptionsTrade(models.Model):
)
status = models.IntegerField(choices=STATUS, default=2)
notes = models.TextField(null=True, blank=True)
- pl = models.FloatField(null=True)
+ pl = models.FloatField(null=True, blank=True)
class Meta:
ordering = ('-open_date',)
@@ -263,7 +263,8 @@ class LuxOptionsTrade(models.Model):
if self.status == 1 and not self.close_date:
self.close_date = timezone.now()
if self.status == 1 and not self.pl:
- self.pl = round((self.contract_close_price*self.number_contracts)-(self.contract_price*self.number_contracts)*100, 2)
+ if self.call_put == 0:
+ self.pl = round(((self.contract_close_price*self.number_contracts)*100) - ((self.contract_price*self.number_contracts)*100), 2)
super(LuxOptionsTrade, self).save()