Server now returns HTML and can pass back/forth data
This commit is contained in:
1 parent
6b56699280
commit
04279d77f0
5 files changed
+223
-1
No files matched your search
@@ -0,0 +1,4 @@
|
||||
/*! jQuery v3.2.1 | (c) JS Foundation and other contributors | jquery.org/license */
|
||||
!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("scLine truncated
|
||||
a.removeEventListener("load",S),r.ready()}"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(r.ready):(d.addEventListener("DOMContentLoaded",S),a.addEventListener("load",S));var T=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===r.type(c)){e=!0;for(h in c)T(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,r.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(r(a),c)})),b))for(;h<i;h++)b(a[h],c,g?d:d.call(Line truncated
|
||||
null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"===b&&B(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d=0,e=b&&b.match(L);if(e&&1===a.nodeType)while(c=e[d++])a.removeAttribute(c)}}),lb={set:function(a,b,c){return b===!1?r.removeAttr(a,c):a.setAttribute(c,c),c}},r.each(r.expr.match.bool.source.match(/\w+/g),function(a,b){var c=mb[b]||r.find.attr;mb[b]=function(a,b,d){var e,f,g=b.toLowerCase();return dLine truncated
|
||||
@@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
|
||||
var optionResults;
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#option-terms").on("submit", function(e) {
|
||||
//
|
||||
e.preventDefault();
|
||||
sendRequest();
|
||||
})
|
||||
});
|
||||
|
||||
function serializeForm(id) {
|
||||
//
|
||||
return $(id).serializeArray()
|
||||
.reduce(function(a, x) { a[x.name] = x.value; return a; }, {});
|
||||
}
|
||||
|
||||
function sendRequest() {
|
||||
//
|
||||
var inputData = serializeForm("#option-terms");
|
||||
// Get the right data-types
|
||||
inputData.ExpiryDate = new Date(inputData.ExpiryDate).toJSON();
|
||||
inputData.OptType = parseInt(inputData.OptType);
|
||||
inputData.Rfr = parseFloat(inputData.Rfr);
|
||||
inputData.Sims = parseInt(inputData.Sims);
|
||||
inputData.Spot = parseFloat(inputData.Spot);
|
||||
inputData.Strike = parseFloat(inputData.Strike);
|
||||
inputData.ValueDate = new Date(inputData.ValueDate).toJSON();
|
||||
inputData.Vol = parseFloat(inputData.impliedVol);
|
||||
|
||||
// Send request
|
||||
var startTime;
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "http://localhost:8080",
|
||||
data: JSON.stringify(inputData),
|
||||
beforeSend: function(request, settings) {
|
||||
startTime = new Date().getTime();
|
||||
},
|
||||
success: function(e) {
|
||||
optionResults = e;
|
||||
updateTable();
|
||||
let requestTime = new Date().getTime() - startTime;
|
||||
console.log("Request time: ", requestTime);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function updateTable() {
|
||||
$("#results-table > tbody > tr").each(function(idx, el) {
|
||||
$($(el).children()[1])[0].innerText =
|
||||
optionResults["ClosedForm"][$($(el).children()[0]).text()].toFixed(4);
|
||||
$($(el).children()[2])[0].innerText =
|
||||
optionResults["MonteCarlo"][$($(el).children()[0]).text()].toFixed(4);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
body {
|
||||
font-family: 'Poppins', sans-serif;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
form > p {
|
||||
text-align: left;
|
||||
margin-left: 10%;
|
||||
}
|
||||
|
||||
p > select, button {
|
||||
float: right;
|
||||
margin-right: 20%;
|
||||
}
|
||||
|
||||
p > input {
|
||||
float: right;
|
||||
margin-right: 20%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
table {
|
||||
border: none;
|
||||
border collapse: collapse;
|
||||
}
|
||||
|
||||
table td {
|
||||
border-left: 1px solid #000;
|
||||
padding: 0 40px 0 40px;
|
||||
}
|
||||
|
||||
table td:first-child {
|
||||
border-left: none;
|
||||
}
|
||||
|
||||
table > tbody > tr > th {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
table > tbody > tr > td {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-left: 5%;
|
||||
}
|
||||
|
||||
#option-terms {
|
||||
/* float: right; */
|
||||
|
||||
}
|
||||
|
||||
#left-side {
|
||||
float: left;
|
||||
width: 33%;
|
||||
}
|
||||
|
||||
#right-side {
|
||||
float: left;
|
||||
width: 66%;
|
||||
}
|
||||
Reference in new issue
Block a user