diff options
-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 8c622d6..75476fd 100644 --- a/app/trading/models.py +++ b/app/trading/models.py @@ -104,7 +104,6 @@ class LuxTradeStatsManager(models.Manager): last_day = calendar.monthrange(timezone.now().year, month)[1] start_date = datetime.date(timezone.now().year, month, 1) end_date = datetime.date(timezone.now().year, month, last_day) - print("date info: ", last_day, start_date, end_date) return self.filter(close_date__range=(start_date, end_date)).aggregate(Sum('pl')) @@ -174,6 +173,8 @@ class LuxTrade(models.Model): def save(self, *args, **kwargs): if self.status == 0 and not self.open_date: self.open_date = timezone.now() + 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.close_price*self.shares)-(self.entry_price*self.shares), 2) super(LuxTrade, self).save() |