From b6cfaf59b1736bf91ce7a9497607ffca4a738065 Mon Sep 17 00:00:00 2001 From: lxf Date: Thu, 6 Jan 2022 11:20:15 -0500 Subject: trad: updated admin --- app/trading/admin.py | 2 +- app/trading/models.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'app/trading') 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): -- cgit v1.2.3-70-g09d2