diff options
Diffstat (limited to 'app/trading/templates')
-rw-r--r-- | app/trading/templates/trading/list.html | 64 |
1 files changed, 56 insertions, 8 deletions
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 %} |