diff options
author | luxagraf <sng@luxagraf.net> | 2021-07-27 11:41:55 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2021-07-27 11:41:55 -0400 |
commit | e9542c3f64d547765ebe132a31d12633d963a8e3 (patch) | |
tree | a9de82e8866819a32dc8f11dea9323f6c3d4e1ab /app/trading/models.py | |
parent | f94cd466d98eae940e2e9449aedc041ba9f6f431 (diff) |
trad: added closing price to options trades
Diffstat (limited to 'app/trading/models.py')
-rw-r--r-- | app/trading/models.py | 3 |
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() |