summaryrefslogtreecommitdiff
path: root/app/trading/models.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2021-07-27 11:41:55 -0400
committerluxagraf <sng@luxagraf.net>2021-07-27 11:41:55 -0400
commite9542c3f64d547765ebe132a31d12633d963a8e3 (patch)
treea9de82e8866819a32dc8f11dea9323f6c3d4e1ab /app/trading/models.py
parentf94cd466d98eae940e2e9449aedc041ba9f6f431 (diff)
trad: added closing price to options trades
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()