gui changes

This commit is contained in:
David Brazda
2023-05-07 21:37:29 +02:00
parent d9abc19c1f
commit 45c356c1df
10 changed files with 211 additions and 72 deletions

View File

@ -5,7 +5,7 @@ from appdirs import user_data_dir
LOG_RUNNER_EVENTS = False
#no print in console
QUIET_MODE = False
QUIET_MODE = True
#how many consecutive trades with the fill price are necessary for LIMIT fill to happen in backtesting
#0 - optimistic, every knot high will fill the order
#N - N consecutive trades required

View File

@ -484,7 +484,7 @@ def delete_archived_runners_byID(id: UUID):
resh = db_arch_h.remove(where('id') == id)
resd = db_arch_d.remove(where('id') == id)
reslogs = delete_logs(id)
if len(resh) == 0 or len(resd) == 0 or reslogs ==0:
if len(resh) == 0 or len(resd) == 0:
return -1, "not found "+str(resh) + " " + str(resd) + " " + str(reslogs)
return 0, str(resh) + " " + str(resd) + " " + str(reslogs)
except Exception as e:

View File

@ -92,7 +92,7 @@
<label data-bs-toggle="collapse" data-bs-target="#runner-table-inner">
<h4><span class="badge secondary-bg">Running Strategies</span></h4>
</label>
<div id="runner-table-inner" class="collapse show">
<div id="runner-table-inner" class="collapse show" style="width:70%">
<div id="controls">
<label>API-KEY: <input type="password" id="api-key" autocomplete="off"/></label>
<button onclick="store_api_key(event)" id="bt-store" class="btn btn-outline-success btn-sm">Store</button>
@ -101,7 +101,7 @@
<button id="button_stopall" class="btn btn-outline-success btn-sm">Stop All</button>
<button id="button_refresh" class="refresh btn btn-outline-success btn-sm">Refresh</button>
</div>
<table id="runnerTable" class="table-striped table-bordered dataTable" style="width:100%; border-color: #dce1dc;">
<table id="runnerTable" class="table-striped table dataTable" style="width:100%; border-color: #dce1dc;">
<thead>
<tr>
<th>Id</th>
@ -149,11 +149,11 @@
<label data-bs-toggle="collapse" data-bs-target="#archive-table-inner">
<h4><span class="badge secondary-bg">Past Runs</span></h4>
</label>
<div id="archive-table-inner" class="collapse show">
<div id="archive-chart">
<div id="archive-table-inner" class="collapse show" style="width:70%">
<!-- <div id="archive-chart">
<div id="chartArchive" style="position: relative;"></div>
<div class="legend" id="legendArchive"></div>
</div>
</div> -->
<div id="controls">
<button id="button_edit_arch" class="btn btn-outline-success btn-sm">Edit</button>
<button id="button_delete_arch" class="btn btn-outline-success btn-sm">Delete</button>
@ -162,7 +162,7 @@
<!-- <button id="button_stopall" class="btn btn-outline-success btn-sm">Stop All</button>
<button id="button_refresh" class="btn btn-outline-success btn-sm">Refresh</button> -->
</div>
<table id="archiveTable" class="table-striped table-bordered dataTable" style="width:100%; border-color: #dce1dc;">
<table id="archiveTable" class="table-striped table dataTable" style="width:100%; border-color: #dce1dc;">
<thead>
<tr>
<th>Id</th>
@ -210,43 +210,42 @@
</form>
</div>
</div>
</div>
<div id="editModalArchive" class="modal fade">
<div class="modal-dialog">
<form method="post" id="editFormArchive">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Edit Archive</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="editidarchive" class="form-label">Id</label>
<input type="text" class="form-control" id="editidarchive" name="id" placeholder="id" readonly>
<div id="editModalArchive" class="modal fade">
<div class="modal-dialog">
<form method="post" id="editFormArchive">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Edit Archive</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="form-group">
<label for="editnote" class="form-label">note</label>
<textarea class="form-control" rows="2" id="editnote" name="note"></textarea>
<div class="modal-body">
<div class="form-group">
<label for="editidarchive" class="form-label">Id</label>
<input type="text" class="form-control" id="editidarchive" name="id" placeholder="id" readonly>
</div>
<div class="form-group">
<label for="editnote" class="form-label">note</label>
<textarea class="form-control" rows="2" id="editnote" name="note"></textarea>
</div>
<div class="form-group">
<label for="stratvars" class="form-label">Stratvars</label>
<textarea class="form-control" rows="4" id="editstratvars" name="stratvars"></textarea>
</div>
</div>
<div class="modal-footer">
<input type="submit" name="delete" id="editarchive" class="btn btn-primary" value="Edit" />
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
<div class="form-group">
<label for="stratvars" class="form-label">Stratvars</label>
<textarea class="form-control" rows="4" id="editstratvars" name="stratvars"></textarea>
</div>
</div>
<div class="modal-footer">
<input type="submit" name="delete" id="editarchive" class="btn btn-primary" value="Edit" />
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</form>
</form>
</div>
</div>
</div>
</div>
<div id="stratin-table" class="flex-items">
<label data-bs-toggle="collapse" data-bs-target="#stratin-table-inner">
<h4><span class="badge secondary-bg">Strategies</span></h4>
</label>
<div id="stratin-table-inner" class="collapse show">
<div id="stratin-table-inner" class="collapse show" style="width:70%">
<button id="button_add" class="btn btn-outline-success btn-sm">Add</button>
<button id="button_add_json" class="btn btn-outline-success btn-sm">Add JSON</button>
<button id="button_edit" class="btn btn-outline-success btn-sm">Edit</button>
@ -255,7 +254,7 @@
<button id="button_delete" class="btn btn-outline-success btn-sm">Delete</button>
<button id="button_run" class="btn btn-outline-success btn-sm">Run Strategy</button>
<button id="button_refresh" class="refresh btn btn-outline-success btn-sm">Refresh</button>
<table id="stratinTable" class="table-striped table-bordered dataTable" style="width:100%; border-color: #dce1dc;">
<table id="stratinTable" class="table-striped table dataTable" style="width:100%; border-color: #dce1dc;">
<thead>
<tr>
<th>Id</th>
@ -428,12 +427,16 @@
<input type="number" class="form-control" id="cash" name="cash" placeholder="cash" value="100000">
</div>
<div class="form-group">
<label for="ilog_save" class="form-label">Enable logs</label>
<input type="checkbox" class="form-check" id="ilog_save" name="ilog_save" aria-label="Enable logs">
<div style="display:inline-flex">
<label for="ilog_save" class="form-label">Enable logs</label>
<input type="checkbox" class="form-check" id="ilog_save" name="ilog_save" aria-label="Enable logs">
</div>
</div>
<div class="form-group">
<label for="subscribe" class="form-label">Subscribe for RT</label>
<input type="checkbox" class="form-check" id="subscribe" name="subscribe" aria-label="Real time subscribe">
<div style="display:inline-flex">
<label for="subscribe" class="form-label">Show real time</label>
<input type="checkbox" class="form-check" id="subscribe" name="subscribe" aria-label="Real time subscribe">
</div>
</div>
<div class="form-group">
<label for="note" class="form-label">note</label>

View File

@ -213,9 +213,10 @@ function chart_archived_run(archRecord, data, oneMinuteBars) {
toolTip = document.createElement('div');
//width: 90px; , height: 80px;
toolTip.style = `position: absolute; display: none; padding: 8px; box-sizing: border-box; font-size: 12px; text-align: left; z-index: 1000; top: 12px; left: 12px; pointer-events: none; border: 1px solid; border-radius: 2px;font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;`;
toolTip.style.background = 'white';
toolTip.style.color = 'black';
toolTip.style.borderColor = '#2962FF';
toolTip.style.backgroundColor = '#2d323e';
toolTip.style.color = '#babfcd';
toolTip.style.borderColor = "#a7a9b0";
//'#2962FF';
container1.appendChild(toolTip);
//initialize chart
document.getElementById("chart").style.display = "block"
@ -579,7 +580,7 @@ function chart_archived_run(archRecord, data, oneMinuteBars) {
chart.subscribeClick(param => {
$('#trade-timestamp').val(param.time)
if (archRecord.ilog_save == "true") {
if (archRecord.ilog_save == true) {
fetch_log_data(param.time, archRecord.id);
}
if (
@ -666,13 +667,13 @@ function fetch_log_data(timestamp, runner_id) {
contentType: "application/json",
data: req,
success:function(data){
console.log("archived logs", JSON.stringify(data))
//console.log("archived logs", JSON.stringify(data))
display_log(data, timestamp)
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
window.alert(JSON.stringify(xhr));
console.log(JSON.stringify(xhr));
//console.log(JSON.stringify(xhr));
}
})
}

View File

@ -166,22 +166,50 @@ var archiveRecords =
{data: 'bt_from', visible: true},
{data: 'bt_to', visible: true},
{data: 'ilog_save', visible: true},
{data: 'stratvars', visible: true},
{data: 'stratvars', visible: false},
{data: 'profit'},
{data: 'trade_count', visible: true},
{data: 'end_positions', visible: true},
{data: 'end_positions_avgp', visible: true},
{data: 'open_orders', visible: true}
],
// columnDefs: [{
// targets: [4,5,8,9],
// render: function ( data, type, row ) {
// return format_date(data)
// },
// }],
paging: false,
processing: false,
columnDefs: [ {
targets: [0,1],
render: function ( data, type, row ) {
return '<div class="tdnowrap" title="'+data+'">'+data+'</i>'
},
},
{
targets: [5,6],
render: function ( data, type, row ) {
now = new Date(data)
if (isToday(now)) {
//return local time only
return 'dnes ' + format_date(data,false,true)
}
else
{
//return local datetime
return format_date(data,false,false)
}
},
},
{
targets: [9,10],
render: function ( data, type, row ) {
//market datetime
return format_date(data, true)
},
},
],
order: [[6, 'desc']],
paging: true,
lengthChange: false,
// paging: true,
// lengthChange: false,
// select: true,
// createdRow: function( row, data, dataIndex){
// if (is_running(data.id) ){
// alert("runner");

View File

@ -20,7 +20,7 @@ function populate_rt_status_header(runnerId) {
method:"GET",
contentType: "application/json",
success:function(data){
console.log(JSON.stringify(data))
//console.log(JSON.stringify(data))
//add status on chart
$("#statusRegime").text("REALTIME")
$("#statusName").text(data.run_name)
@ -31,7 +31,7 @@ function populate_rt_status_header(runnerId) {
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
window.alert(JSON.stringify(xhr));
console.log(JSON.stringify(xhr));
//console.log(JSON.stringify(xhr));
}
})
}

View File

@ -41,8 +41,6 @@ function is_stratin_running(id) {
//STRATIN and RUNNERS TABELS
$(document).ready(function () {
//reaload hlavni tabulky
stratinRecords.ajax.reload();
runnerRecords.ajax.reload();
@ -411,8 +409,8 @@ var stratinRecords =
{data: 'id2'},
{data: 'name'},
{data: 'symbol'},
{data: 'class_name'},
{data: 'script'},
{data: 'class_name', visible: false},
{data: 'script', visible: false},
{data: 'open_rush', visible: false},
{data: 'close_rush', visible: false},
{data: 'stratvars_conf', visible: false},
@ -427,7 +425,14 @@ var stratinRecords =
var status = get_status(data)
return '<i class="fas fa-check-circle">'+status+'</i>'
},
}],
},
{
targets: 0,
render: function ( data, type, row ) {
return '<div class="tdnowrap" data-bs-toggle="tooltip" data-bs-placement="top" title="'+data+'">'+data+'</i>'
},
},
],
order: [[1, 'asc']],
paging: false,
// select: {
@ -480,6 +485,19 @@ var runnerRecords =
],
paging: false,
processing: false,
columnDefs: [ {
targets: [0,1],
render: function ( data, type, row ) {
return '<div class="tdnowrap" title="'+data+'">'+data+'</i>'
},
},
{
targets: [2],
render: function ( data, type, row ) {
return format_date(data)
},
},
],
// select: {
// style: 'multi'
// },

View File

@ -81,17 +81,17 @@ function initialize_chart() {
layout: {
background: {
type: 'solid',
color: '#000000',
color: '#2a2e39',
},
textColor: '#d1d4dc',
},
grid: {
vertLines: {
visible: true,
color: "#434d46"
color: "#434651"
},
horzLines: {
color: "#667069",
color: "#434651",
visible:true
},
},
@ -191,15 +191,35 @@ JSON.safeStringify = (obj, indent = 2) => {
return retVal;
};
function isToday(someDate) {
const today = new Date()
return someDate.getDate() == today.getDate() &&
someDate.getMonth() == today.getMonth() &&
someDate.getFullYear() == today.getFullYear()
}
//https://www.w3schools.com/jsref/jsref_tolocalestring.asp
function format_date(datum) {
function format_date(datum, markettime = false, timeonly = false) {
//const options = { weekday: 'long', year: 'numeric', month: 'numeric', day: 'numeric', };
const options = {dateStyle: "short", timeStyle: "short"}
// date.toLocaleString('en-US', {
// timeZone: 'America/New_York',
// })
//'Europe/Berlin'
var options = {}
if (timeonly) {
options = {hour: '2-digit', hour12: false, minute: '2-digit'}
}
else {
options = {dateStyle: "short", timeStyle: "short"}
}
if (markettime) {
options["timeZone"] = 'America/New_York'
}
const date = new Date(datum);
return date.toLocaleString('cs-CZ', options);
}
function clear_status_header() {
$("#statusRegime").text("")
$("#statusName").text("")

View File

@ -2,7 +2,60 @@
--dt-row-selected: 18, 143, 175;
} */
:root {
--dt-row-selected: 37, 120, 114;
--dt-row-selected: 140,142,141;
}
[data-bs-theme=dark] {
color-scheme: dark;
--bs-body-color: #adb5bd;
--bs-body-color-rgb: 173,181,189;
--bs-body-bg: #2a2e39;
--bs-body-bg-rgb: 33,37,41;
--bs-emphasis-color: #fff;
--bs-emphasis-color-rgb: 255,255,255;
--bs-secondary-color: rgba(173, 181, 189, 0.75);
--bs-secondary-color-rgb: 173,181,189;
--bs-secondary-bg: #343a40;
--bs-secondary-bg-rgb: 52,58,64;
--bs-tertiary-color: rgba(173, 181, 189, 0.5);
--bs-tertiary-color-rgb: 173,181,189;
--bs-tertiary-bg: #2b3035;
--bs-tertiary-bg-rgb: 43,48,53;
--bs-primary-text-emphasis: #6ea8fe;
--bs-secondary-text-emphasis: #a7acb1;
--bs-success-text-emphasis: #75b798;
--bs-info-text-emphasis: #6edff6;
--bs-warning-text-emphasis: #ffda6a;
--bs-danger-text-emphasis: #ea868f;
--bs-light-text-emphasis: #f8f9fa;
--bs-dark-text-emphasis: #dee2e6;
--bs-primary-bg-subtle: #031633;
--bs-secondary-bg-subtle: #161719;
--bs-success-bg-subtle: #051b11;
--bs-info-bg-subtle: #032830;
--bs-warning-bg-subtle: #332701;
--bs-danger-bg-subtle: #2c0b0e;
--bs-light-bg-subtle: #343a40;
--bs-dark-bg-subtle: #1a1d20;
--bs-primary-border-subtle: #084298;
--bs-secondary-border-subtle: #41464b;
--bs-success-border-subtle: #0f5132;
--bs-info-border-subtle: #087990;
--bs-warning-border-subtle: #997404;
--bs-danger-border-subtle: #842029;
--bs-light-border-subtle: #495057;
--bs-dark-border-subtle: #343a40;
--bs-link-color: #6ea8fe;
--bs-link-hover-color: #8bb9fe;
--bs-link-color-rgb: 110,168,254;
--bs-link-hover-color-rgb: 139,185,254;
--bs-code-color: #e685b5;
--bs-border-color: #495057;
--bs-border-color-translucent: rgba(255, 255, 255, 0.15);
--bs-form-valid-color: #75b798;
--bs-form-valid-border-color: #75b798;
--bs-form-invalid-color: #ea868f;
--bs-form-invalid-border-color: #ea868f;
}
tbody, td, tfoot, th, thead, tr {
@ -12,6 +65,18 @@ tbody, td, tfoot, th, thead, tr {
padding: 4px;
}
.tdnowrap {
overflow: hidden;
text-overflow: ellipsis;
width: 68px;
white-space: nowrap;
}
table.dataTable thead th, table.dataTable thead td, table.dataTable tfoot th, table.dataTable tfoot td {
text-align: left;
color: #787b86;
}
.secondary-bg {
--bs-bg-opacity: 1;
background-color: #414749;
@ -73,7 +138,11 @@ tbody, td, tfoot, th, thead, tr {
}
html {
font-size: 14px;
font-size: 12px;
}
.table>:not(caption)>*>* {
padding: 0.32rem 0.32rem;
}
.flex-container {
@ -179,7 +248,7 @@ pre {
font-size: normal;
/* font-weight: bold; */
display: flex;
background-color: #dfe4e6;
/* background-color: #dfe4e6; */
/* color: white; */
padding: 1px;
padding-left: 5px;