diff options
Diffstat (limited to 'app/trading')
-rw-r--r-- | app/trading/models.py | 4 | ||||
-rw-r--r-- | app/trading/views.py | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/app/trading/models.py b/app/trading/models.py index 10aaaf4..faac7ba 100644 --- a/app/trading/models.py +++ b/app/trading/models.py @@ -391,6 +391,7 @@ class LuxOptionPurchase(models.Model): def get_contract_count(self): return self.luxoptioncontract_set.count() + @property def profit_loss(self): total = 0 for option in self.luxoptioncontract_set.all(): @@ -428,7 +429,8 @@ class LuxOptionPurchase(models.Model): def save(self, *args, **kwargs): if self.status == 1 and not self.close_date: self.close_date = timezone.now() - if self.status == 1 and not self.pl: + if self.status == 1: + print("updating pl") self.pl = self.profit_loss super(LuxOptionPurchase, self).save() diff --git a/app/trading/views.py b/app/trading/views.py index 982fb8f..3bb64cf 100644 --- a/app/trading/views.py +++ b/app/trading/views.py @@ -25,7 +25,7 @@ class LuxTradeListView(PaginatedListView): context['options_monthly_pl'] = LuxOptionPurchase.stats.get_month_pl() context['options_year_pl'] = LuxOptionPurchase.stats.get_year_pl() context['month'] = datetime.now().strftime('%h') - context['luxoptions_purchases'] = LuxOptionPurchase.objects.filter(status=0) + context['luxoptions_purchases'] = LuxOptionPurchase.objects.all() return context def get_queryset(self): |