summaryrefslogtreecommitdiff
path: root/app/trading/models.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2021-08-17 20:25:33 -0400
committerluxagraf <sng@luxagraf.net>2021-08-17 20:25:33 -0400
commit9a4c84cdcfcc33308e1092ad2464a81c29b84eb2 (patch)
tree10b3940747945d3937c06a12fbc9d86b2a59717e /app/trading/models.py
parentc3907cd3e61161a264ab0daf6b26262a40876393 (diff)
trad: fixed all the profit loss calcs for puts
Diffstat (limited to 'app/trading/models.py')
-rw-r--r--app/trading/models.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/app/trading/models.py b/app/trading/models.py
index 2a71fb3..ad40c98 100644
--- a/app/trading/models.py
+++ b/app/trading/models.py
@@ -23,7 +23,6 @@ def get_upload_path(self, filename):
return "images/products/%s" % (filename)
-
class Ticker(models.Model):
symbol = models.CharField(max_length=9)
name = models.CharField(max_length=243, blank=True, null=True)
@@ -251,16 +250,18 @@ class LuxOptionsTrade(models.Model):
@property
def risk_per_contract(self):
- return round(((self.entry_price-self.stop_price)*self.delta/self.contract_price)*self.contract_price*100, 2)
-
+ if self.call_put == 0:
+ return round(((self.entry_price-self.stop_price)*self.delta/self.contract_price)*self.contract_price*100, 2)
+ else:
+ return round(((self.stop_price-self.entry_price)*self.delta/self.contract_price)*self.contract_price*100, 2)
+
@property
def risk_total(self):
return round(self.risk_per_contract*self.number_contracts, 2)
@property
def risk_reward(self):
- if self.call_put == 0:
- return round((self.target_price-self.entry_price)/(self.entry_price-self.stop_price), 2);
+ return round((self.target_price-self.entry_price)/(self.entry_price-self.stop_price), 2);
@property
def amount_invested(self):
@@ -269,7 +270,9 @@ class LuxOptionsTrade(models.Model):
@property
def profit_goal(self):
if self.call_put == 0:
- return round((((self.target_price-(self.strike_price+self.contract_price))*100)*self.number_contracts)-self.fees, 3)
+ return round((((self.target_price-(self.strike_price+self.contract_price))*100)*self.number_contracts)-self.fees, 2)
+ else:
+ return round((((self.strike_price-self.target_price)*self.number_contracts)*100)-self.fees, 2)
@property
def days_until_expiration(self):
@@ -278,7 +281,11 @@ class LuxOptionsTrade(models.Model):
@property
def realized_dollars(self):
- return round((((self.contract_close_price*self.number_contracts)*100) - ((self.contract_price*self.number_contracts)*100)-self.fees), 2)
+ if self.call_put == 0:
+ return round((((self.contract_close_price*self.number_contracts)*100) - ((self.contract_price*self.number_contracts)*100)-self.fees), 2)
+ else:
+ return round((((self.contract_price*self.number_contracts)*100)-((self.contract_close_price*self.number_contracts)*100)-self.fees), 2)
+
@property
def realized_percent(self):