summaryrefslogtreecommitdiff
path: root/app/trading/models.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2021-08-13 10:39:20 -0400
committerluxagraf <sng@luxagraf.net>2021-08-13 10:39:20 -0400
commit0c8e041f22fb9c29242fe8b279cd2c11de000979 (patch)
tree370044b60d735b31382b0b7a28c539a0699af97e /app/trading/models.py
parent198448fe8ece2bf40feb3bbd32f03f5dc59a434c (diff)
trad: added calc for puts to pl
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()