From 894cd0b50eb4ef0a9c0aa3779f10215720a5c7b8 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Thu, 19 Aug 2021 11:46:53 -0400 Subject: trad: fixed a little bug in realized percent --- app/trading/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app/trading') diff --git a/app/trading/models.py b/app/trading/models.py index ad40c98..cbd58ed 100644 --- a/app/trading/models.py +++ b/app/trading/models.py @@ -289,7 +289,10 @@ class LuxOptionsTrade(models.Model): @property def realized_percent(self): - return round((self.realized_dollars/self.amount_invested)*100, 2) + if self.call_put == 0: + return round((self.realized_dollars/self.amount_invested)*100, 2) + else: + return round((self.pl/self.amount_invested)*100, 2) def save(self, *args, **kwargs): if self.status == 0 and not self.open_date: -- cgit v1.2.3-70-g09d2