diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/trading/migrations/0015_auto_20210727_1141.py | 22 | ||||
-rw-r--r-- | app/trading/models.py | 3 |
2 files changed, 24 insertions, 1 deletions
diff --git a/app/trading/migrations/0015_auto_20210727_1141.py b/app/trading/migrations/0015_auto_20210727_1141.py new file mode 100644 index 0000000..893922d --- /dev/null +++ b/app/trading/migrations/0015_auto_20210727_1141.py @@ -0,0 +1,22 @@ +# Generated by Django 3.2.5 on 2021-07-27 11:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('trading', '0014_luxtrade_notes_html'), + ] + + operations = [ + migrations.AlterModelOptions( + name='luxtrade', + options={'get_latest_by': 'open_date', 'ordering': ('status', '-open_date')}, + ), + migrations.AddField( + model_name='luxoptionstrade', + name='contract_close_price', + field=models.FloatField(blank=True, null=True), + ), + ] diff --git a/app/trading/models.py b/app/trading/models.py index c030e05..be226e9 100644 --- a/app/trading/models.py +++ b/app/trading/models.py @@ -202,6 +202,7 @@ class LuxOptionsTrade(models.Model): ) call_put = models.IntegerField(choices=CALL_PUT, default=2) contract_price = models.FloatField() + contract_close_price = models.FloatField(null=True, blank=True) number_contracts = models.FloatField() delta = models.FloatField() expiration_date = models.DateField() @@ -262,7 +263,7 @@ class LuxOptionsTrade(models.Model): if self.status == 1 and not self.close_date: self.close_date = timezone.now() if self.status == 1 and not self.pl: - self.pl = 0 #round((self.close_price*self.shares)-(self.entry_price*self.shares), 2) + self.pl = round((self.contract_close_price*self.number_contracts)-(self.contract_price*self.number_contracts)*100, 2) super(LuxOptionsTrade, self).save() |