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.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/app/trading/models.py b/app/trading/models.py
index c030e05..be226e9 100644
--- a/app/trading/models.py
+++ b/app/trading/models.py
@@ -202,6 +202,7 @@ class LuxOptionsTrade(models.Model):
)
call_put = models.IntegerField(choices=CALL_PUT, default=2)
contract_price = models.FloatField()
+ contract_close_price = models.FloatField(null=True, blank=True)
number_contracts = models.FloatField()
delta = models.FloatField()
expiration_date = models.DateField()
@@ -262,7 +263,7 @@ 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 = 0 #round((self.close_price*self.shares)-(self.entry_price*self.shares), 2)
+ self.pl = round((self.contract_close_price*self.number_contracts)-(self.contract_price*self.number_contracts)*100, 2)
super(LuxOptionsTrade, self).save()