diff options
Diffstat (limited to 'app/trading')
-rw-r--r-- | app/trading/admin.py | 2 | ||||
-rw-r--r-- | app/trading/models.py | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/app/trading/admin.py b/app/trading/admin.py index 96e60ee..46982b0 100644 --- a/app/trading/admin.py +++ b/app/trading/admin.py @@ -53,7 +53,7 @@ class LuxOptionContactInline(admin.StackedInline): @admin.register(LuxOptionPurchase) class LuxOptionPurchaseAdmin(admin.ModelAdmin): - list_display = ('symbol',) + list_display = ('symbol','status', 'profit_loss') inlines = [LuxOptionContactInline,] class Media: js = ('image-loader.js', 'next-prev-links.js') diff --git a/app/trading/models.py b/app/trading/models.py index faac7ba..17a1b85 100644 --- a/app/trading/models.py +++ b/app/trading/models.py @@ -376,7 +376,7 @@ class LuxOptionPurchase(models.Model): status = models.IntegerField(choices=STATUS, default=0) class Meta: - ordering = ('-open_date',) + ordering = ('-open_date', 'status') get_latest_by = 'open_date' objects = models.Manager() # The default manager. @@ -393,14 +393,14 @@ class LuxOptionPurchase(models.Model): @property def profit_loss(self): - total = 0 + total = float(0) for option in self.luxoptioncontract_set.all(): if option.contract_close_price: pl = option.contract_close_price - option.contract_open_price else: pl = 0 total = total + pl - return total*100 + return round((total*100),2) @property def stop_price(self): |