summaryrefslogtreecommitdiff
path: root/app/trading/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/trading/models.py')
-rw-r--r--app/trading/models.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/trading/models.py b/app/trading/models.py
index 678edd3..837300b 100644
--- a/app/trading/models.py
+++ b/app/trading/models.py
@@ -259,7 +259,8 @@ class LuxOptionsTrade(models.Model):
@property
def risk_reward(self):
- return round((self.target_price-self.entry_price)/(self.entry_price-self.stop_price), 2);
+ if self.call_put == 0:
+ return round((self.target_price-self.entry_price)/(self.entry_price-self.stop_price), 2);
@property
def amount_invested(self):
@@ -295,6 +296,9 @@ class LuxOptionsTrade(models.Model):
if self.status == 1 and not self.pl:
if self.call_put == 0:
self.pl = round(((self.contract_close_price*self.number_contracts)*100) - ((self.contract_price*self.number_contracts)*100), 2)
+ else:
+ self.pl = round(((self.contract_price*self.number_contracts)*100) - ((self.contract_close_price*self.number_contracts)*100), 2)
+
if self.notes:
self.notes_html = markdown_to_html(self.notes)
super(LuxOptionsTrade, self).save()