diff options
author | luxagraf <sng@luxagraf.net> | 2021-07-30 10:53:09 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2021-07-30 10:53:09 -0400 |
commit | 2ef32504886681272a3a462aa0449cffa06bb02f (patch) | |
tree | eff9545d7bcd88c9b5e172480a0f56db189cd2af /app | |
parent | 7ef866d37fa35aadb7ead8928b904395b49d52f8 (diff) |
trad: fixed a bug in options closing
Diffstat (limited to 'app')
-rw-r--r-- | app/trading/models.py | 5 |
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() |