summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2021-07-24 14:53:25 -0400
committerluxagraf <sng@luxagraf.net>2021-07-24 14:53:25 -0400
commitc3672978183dbc0cb0bf728b3dfadf12dd831a60 (patch)
tree1ed5c8bdb2b921a7073461106b4872c4440b5ae3 /app
parent2a334a02495a2788f4d36f96436c8e2c130a1ea2 (diff)
trad: added profit calc to options
Diffstat (limited to 'app')
-rw-r--r--app/trading/templates/trading/base.html2
-rw-r--r--app/trading/templates/trading/create_form.html1
-rw-r--r--app/trading/templates/trading/list.html19
3 files changed, 18 insertions, 4 deletions
diff --git a/app/trading/templates/trading/base.html b/app/trading/templates/trading/base.html
index 230a661..a557706 100644
--- a/app/trading/templates/trading/base.html
+++ b/app/trading/templates/trading/base.html
@@ -1,6 +1,6 @@
<html>
<head>
- <title>{% block pagetitle %}Luxagraf - Topografical Writings{% endblock %}</title>
+ <title>{% block pagetitle %}Luxagraf - Trading{% endblock %}</title>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
diff --git a/app/trading/templates/trading/create_form.html b/app/trading/templates/trading/create_form.html
index 890c9e2..2814171 100644
--- a/app/trading/templates/trading/create_form.html
+++ b/app/trading/templates/trading/create_form.html
@@ -1,5 +1,6 @@
{% extends 'trading/base.html' %}
{% load typogrify_tags %}
+ {% block pagetitle %}Luxagraf - Test Trade{% endblock %}
{% block content %}
<form id="id_form" action="{% url 'luxtrade:testtrade' %}" method="post" class="big">{% csrf_token %}
{% for field in form %}
diff --git a/app/trading/templates/trading/list.html b/app/trading/templates/trading/list.html
index f689d9d..60ab941 100644
--- a/app/trading/templates/trading/list.html
+++ b/app/trading/templates/trading/list.html
@@ -117,7 +117,9 @@
<td>${{object.risk_total}}</td>
<td>${{object.profit_goal}}</td>
<td>{{object.risk_reward}}</td>
- <td><input class="close_price_calc"> <span id=profit"></span></td>
+ <td>
+ <input class="price_calc" data-delta="{{object.delta}}" data-cprice="{{object.contract_price}}" data-options=true data-eprice="{{object.entry_price}}" data-total="{{object.amount_invested}}" data-ncontracts="{{object.number_contracts}}"><span class="profit"></span>
+ </td>
<td class="notes">
{% if object.notes %}
<div class="wrapper">
@@ -201,11 +203,22 @@
<script>
var elements = document.getElementsByClassName("price_calc");
var getCurrentProfit = function() {
+ var options = this.getAttribute("data-options");
var eprice = this.getAttribute("data-eprice");
+ var sprice = this.getAttribute("data-sprice");
var shares = this.getAttribute("data-shares");
+ var contract_price = this.getAttribute("data-cprice");
+ var number_contracts = this.getAttribute("data-ncontracts");
+ var total = this.getAttribute("data-total");
+ var delta = this.getAttribute("data-delta");
var cprice = this.value;
- var profit = (cprice*shares)-(shares*eprice)
- this.nextSibling.innerHTML = "$"+profit.toFixed(2);
+ if (options) {
+ var profit = ((cprice*number_contracts)*100)-((contract_price*number_contracts)*100);
+ this.nextSibling.innerHTML = "$"+profit.toFixed(2);
+ } else {
+ var profit = (cprice*shares)-(shares*eprice)
+ this.nextSibling.innerHTML = "$"+profit.toFixed(2);
+ }
};
for (var i = 0; i < elements.length; i++) {