summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/trading/migrations/0014_luxtrade_notes_html.py18
-rw-r--r--app/trading/models.py2
-rw-r--r--app/trading/templates/trading/list.html64
3 files changed, 76 insertions, 8 deletions
diff --git a/app/trading/migrations/0014_luxtrade_notes_html.py b/app/trading/migrations/0014_luxtrade_notes_html.py
new file mode 100644
index 0000000..d73f404
--- /dev/null
+++ b/app/trading/migrations/0014_luxtrade_notes_html.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.2.5 on 2021-07-21 15:06
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('trading', '0013_alter_luxoptionstrade_fees'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='luxtrade',
+ name='notes_html',
+ field=models.TextField(blank=True, null=True),
+ ),
+ ]
diff --git a/app/trading/models.py b/app/trading/models.py
index 551a4de..40762db 100644
--- a/app/trading/models.py
+++ b/app/trading/models.py
@@ -124,6 +124,7 @@ class LuxTrade(models.Model):
)
status = models.IntegerField(choices=STATUS, default=2)
notes = models.TextField(null=True, blank=True)
+ notes_html = models.TextField(null=True, blank=True)
is_wanderer = models.BooleanField(default=True)
pl = models.FloatField(null=True)
@@ -181,6 +182,7 @@ class LuxTrade(models.Model):
self.close_date = timezone.now()
if self.status == 1 and not self.pl:
self.pl = round((self.close_price*self.shares)-(self.entry_price*self.shares), 2)
+ self.notes_html = markdown_to_html(self.notes)
super(LuxTrade, self).save()
diff --git a/app/trading/templates/trading/list.html b/app/trading/templates/trading/list.html
index ac735e3..539ba49 100644
--- a/app/trading/templates/trading/list.html
+++ b/app/trading/templates/trading/list.html
@@ -32,8 +32,16 @@
<td>${{object.goal_dollars}}</td>
<td>{{object.goal_percent}}</td>
<td>{{object.risk_reward}}</td>
- <td><input class="close_price_calc" id="id_close_price_{{forloop.counter}}"> <span id=profit"></span></td>
- <td class="notes">{{object.notes}}</td>
+ <td>
+ <input class="price_calc" data-eprice="{{object.entry_price}}" data-shares="{{object.shares}}"><span class="profit"></span>
+ </td>
+ <td class="notes">
+ {% if object.notes %}
+ <div class="wrapper">
+ {{object.notes_html|safe}}
+ </div>
+ {% endif %}
+ </td>
</tr>
{% endfor %}
</table>
@@ -53,12 +61,13 @@
<th>$ Goal</th>
<th>% Goal</th>
<th>Risk/Reward</th>
+ <th>Price Calc</th>
<th>Notes</th>
</tr>
</thead>
{% for object in watch_trades %}
<tr {%if object.is_wanderer %}class="wanderer-trade"{% endif %}>
- <td>{{object.symbol}}</td>
+ <td><a href="https://www.tradingview.com/chart/?symbol={{object.symbol}}" target="_blank">{{object.symbol}}</a></td>
<td><a href="{{object.get_absolute_url}}">{{object.date|date:"m-d-Y"}}</a></td>
<td>${{object.entry_price}}</td>
<td>${{object.stop_price}}</td>
@@ -69,8 +78,16 @@
<td>${{object.goal_dollars}}</td>
<td>{{object.goal_percent}}</td>
<td>{{object.risk_reward}}</td>
- <td><input id="id_close_price"> <span id=profit"></span></td>
- <td class="notes">{{object.notes}}</td>
+ <td>
+ <input class="price_calc" data-eprice="{{object.entry_price}}" data-shares="{{object.shares}}"><span class="profit"></span>
+ </td>
+ <td class="notes">
+ {% if object.notes %}
+ <div class="wrapper">
+ {{object.notes_html|safe}}
+ </div>
+ {% endif %}
+ </td>
</tr>
{% endfor %}
</table>
@@ -119,8 +136,14 @@
<td>${{object.risk_total}}</td>
<td>${{object.profit_goal}}</td>
<td>{{object.risk_reward}}</td>
- <td><input class="close_price_calc" id="id_close_price_{{forloop.counter}}"> <span id=profit"></span></td>
- <td class="notes">{{object.notes}}</td>
+ <td><input class="close_price_calc"> <span id=profit"></span></td>
+ <td class="notes">
+ {% if object.notes %}
+ <div class="wrapper">
+ {{object.notes_html|safe}}
+ </div>
+ {% endif %}
+ </td>
</tr>
{% endfor %}
</table>
@@ -161,7 +184,13 @@
<td>${{object.goal_dollars}}</td>
<td>${{object.realized_dollars}}</td>
<td>{{object.realized_percent}}</td>
- <td class="notes">{{object.notes}}</td>
+ <td class="notes">
+ {% if object.notes %}
+ <div class="wrapper">
+ {{object.notes_html|safe}}
+ </div>
+ {% endif %}
+ </td>
</tr>
{% endfor %}
<tr>
@@ -182,3 +211,22 @@
</tr>
</table>
{% endblock %}
+
+
+ {% block js %}
+<script>
+ var elements = document.getElementsByClassName("price_calc");
+ var getCurrentProfit = function() {
+ var eprice = this.getAttribute("data-eprice");
+ var shares = this.getAttribute("data-shares");
+ var cprice = this.value;
+ var profit = (cprice*shares)-(shares*eprice)
+ this.nextSibling.innerHTML = "$"+profit.toFixed(2);
+ };
+
+ for (var i = 0; i < elements.length; i++) {
+ elements[i].addEventListener('input', getCurrentProfit, false);
+ }
+</script>
+
+ {% endblock %}