diff options
Diffstat (limited to 'app/trading/templates')
-rw-r--r-- | app/trading/templates/trading/base.html | 2 | ||||
-rw-r--r-- | app/trading/templates/trading/create_luxoptions_form.html | 2 | ||||
-rw-r--r-- | app/trading/templates/trading/list.html | 2 | ||||
-rw-r--r-- | app/trading/templates/trading/luxoptions_update_form.html | 70 |
4 files changed, 74 insertions, 2 deletions
diff --git a/app/trading/templates/trading/base.html b/app/trading/templates/trading/base.html index 2d6e5da..9b9e6b0 100644 --- a/app/trading/templates/trading/base.html +++ b/app/trading/templates/trading/base.html @@ -15,7 +15,7 @@ <nav> <span class="nav-item"><a href="{% url 'luxtrade:list' %}">Home</a></span> <span class="nav-item"><a href="{% url 'luxtrade:testtrade' %}">Test Trade</a></span> - <span class="nav-item"><a href="{% url 'luxtrade:testoptions' %}">Test Options</a></span> + <span class="nav-item"><a href="{% url 'luxtrade:option-create' %}">Test Options</a></span> <span class="nav-item"><a href="https://wandererfinancial.com/{% now 'n-j-y'%}-todays-market/" target="_blank">Wanderer</a></span> <span class="nav-item"><a href="https://www.tradingview.com/chart/1a1NjVtp/" target="_blank">Trading View</a></span> <span class="nav-item"><a href="https://trade.tastyworks.com/index.html#/portfolioPage" target="_blank">Tastyworks</a></span> diff --git a/app/trading/templates/trading/create_luxoptions_form.html b/app/trading/templates/trading/create_luxoptions_form.html index 5fff0ae..937f90b 100644 --- a/app/trading/templates/trading/create_luxoptions_form.html +++ b/app/trading/templates/trading/create_luxoptions_form.html @@ -1,7 +1,7 @@ {% extends 'trading/base.html' %} {% load typogrify_tags %} {% block content %} - <form id="id_form" action="{% url 'luxtrade:testoptions' %}" method="post" class="big">{% csrf_token %} + <form id="id_form" action="{% url 'luxtrade:option-create' %}" method="post" class="big">{% csrf_token %} {% for field in form %} <fieldset> {{ field.errors }} diff --git a/app/trading/templates/trading/list.html b/app/trading/templates/trading/list.html index 3f6c3c0..be9b527 100644 --- a/app/trading/templates/trading/list.html +++ b/app/trading/templates/trading/list.html @@ -13,6 +13,7 @@ <th>% Portfolio Risk</th> <th>25% profit at</th> <th>Stop</th> + <th>Profit</th> <th>Notes</th> </tr> </thead> @@ -36,6 +37,7 @@ <td>{{object.portfolio_risk|floatformat:2}}%</td> <td>${{object.sell_half_at|floatformat:2}}</td> <td>${{object.stop_price|floatformat:2}}</td> + <td>${{object.profit_loss|floatformat:2}}</td> <td class="notes"> {% if object.notes %} <div class="wrapper"> diff --git a/app/trading/templates/trading/luxoptions_update_form.html b/app/trading/templates/trading/luxoptions_update_form.html new file mode 100644 index 0000000..14c80c3 --- /dev/null +++ b/app/trading/templates/trading/luxoptions_update_form.html @@ -0,0 +1,70 @@ +{% extends 'trading/base.html' %} +{% load typogrify_tags %} + {% block content %} + <form id="id_form" action="" method="post" class="big">{% csrf_token %} + {% for field in form %} + <fieldset> + {{ field.errors }} + {% if field.name == 'status' or field.name == 'call_put' %} + <label class="hide" for="id_status">Status:</label>{{ field }} + {% else %} + {% if field.name == 'strike_price' or field.name == 'expiration_date' %}<div class="hide">{%endif%} + {{ field.label_tag }} {{ field }} + {% if field.name == 'strike_price' or field.name == 'expiration_date' %}</div>{%endif%} + {% endif %} + {% if field.help_text %} + <p class="help">{{ field.help_text|safe }}</p> + {% endif %} + </fieldset> +{% endfor %} + <dl> + <dt>R/R: </dt><dd id="id_rr"></dd> + <dt>% Portfolio: </dt><dd id="id_p_portfolio"></dd> + <dt>Risk per contract: </dt><dd id="id_risk_contract"></dd> + <dt>Total Risk: </dt><dd id="id_risk_total"></dd> + <dt>Total Invested: </dt><dd id="id_total"></dd> + </dl> + <div class="flex"> + <input type="submit" name="post" class="btn" value="record purchase"/> + </div> + </form> + {% endblock %} + + {% block js %} +<script> +function calcPercentPortfolio() { + var entry_price = document.getElementById("id_entry_price").value; + var stop_price = document.getElementById("id_stop_price").value; + var target_price = document.getElementById("id_target_price").value; + var contract_price = document.getElementById("id_contract_price").value; + var number_contracts = document.getElementById("id_number_contracts").value; + var delta = document.getElementById("id_delta").value; + var pp = (contract_price*number_contracts)*100/10000; + var total = (contract_price*number_contracts)*100; + var rr = (target_price-entry_price)/(entry_price-stop_price); + var risk_per = ((entry_price-stop_price)*delta/contract_price)*contract_price*100 + var total_risk = (risk_per*number_contracts); + document.getElementById("id_p_portfolio").innerText = (pp*100).toFixed(2); + document.getElementById("id_risk_contract").innerText = "$"+risk_per.toFixed(2); + document.getElementById("id_risk_total").innerText = "$"+total_risk.toFixed(2); + document.getElementById("id_rr").innerText = rr.toFixed(2); + document.getElementById("id_total").innerText = "$"+total.toFixed(2); +} +id_form.addEventListener("input", function (e) { + calcPercentPortfolio(); +}); +var form = document.getElementById('id_form'); +function processForm(e) { + if (e.preventDefault) e.preventDefault(); + if(!confirm("Do you really want to do this?")) { + return false; + } + form.submit(); +} +if (form.attachEvent) { + form.attachEvent("submit", processForm); +} else { + form.addEventListener("submit", processForm); +} +</script> + {% endblock %} |