From 45c356c1df22e687919ea9d8eb2826f3526a2087 Mon Sep 17 00:00:00 2001 From: David Brazda Date: Sun, 7 May 2023 21:37:29 +0200 Subject: [PATCH] gui changes --- v2realbot/__pycache__/config.cpython-310.pyc | Bin 2804 -> 2804 bytes v2realbot/config.py | 2 +- v2realbot/controller/services.py | 2 +- v2realbot/static/index.html | 81 ++++++++++--------- v2realbot/static/js/archivechart.js | 13 +-- v2realbot/static/js/archivetables.js | 46 ++++++++--- v2realbot/static/js/livewebsocket.js | 4 +- v2realbot/static/js/mytables.js | 28 +++++-- v2realbot/static/js/utils.js | 32 ++++++-- v2realbot/static/main.css | 75 ++++++++++++++++- 10 files changed, 211 insertions(+), 72 deletions(-) diff --git a/v2realbot/__pycache__/config.cpython-310.pyc b/v2realbot/__pycache__/config.cpython-310.pyc index d49f68a33dc8ef8e509c375f1ebf3063f40a414a..86d14e67cae83d570541f3e05cba9ccf81c03a78 100644 GIT binary patch delta 628 zcmYk1yKWOf6oz-!YkMzV-`95>auJdh89{0a7JD&Pzz&-=icYgqa+WAgkM3?rtQnVine~2J2ki!1%@A zmk+&#%okpWwOa}pZ-NOPO%C_p&ZeO5pM(d;+ys3byqlebAA(5;S071}5QAOHjYf)B zQBxo-km2|yQA^ks`z7x-McaG)O+}_IrO5JTWhx@?r1P@T;F-+47^=n zE9!L{)UNH>ez)&N|BUvdq5vdT7rk zWa3RP-n`nF{u!RU?0>+~q!$wpzM;l+CiBVneP8CycP{gnd2?i%hDNLRp^GO|v-6%q z6hmNO7-C*%5C?P41ae3oXc+mzAmv3+KV^`PYU>(C(Kyr4I1NCCsu;$pic^(E(+gt4 z<1aWSF?GfvhiS-T1`3#k1K^Yfd2^T9+A-hV?Ezj*6ScDa{;3m1Z zurU3zvo;G*-kC~W<9_UwH^jr?!QSi1*w^=tM*A;G`o_R}GdUWac*Bu@{*F}`OUloI zaydn}L|P%EkR^Q8L{aIY{2Az05+rZa8OI5R7H3yG6%eW;r_7SigBP)@8{`N}uJE-+ znPj`hMNV0Hg@S^b^l$oqWhqr6+@~|<1YJuoQ9A#~zcE&o8{yT5s_pBW-oz1NBx(_H zhYWF7xf~DokHwOzD+*PGWrgdRzK82Zoy=K?0P_TAP~XRGIe3`UQcFW*Lg-}8el gXBV<|qp{U%yY>FIy-kxJJ5KXjpm{V)elm9d0(@qSL;wH) diff --git a/v2realbot/config.py b/v2realbot/config.py index bdec1cb..6f1eacd 100644 --- a/v2realbot/config.py +++ b/v2realbot/config.py @@ -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 diff --git a/v2realbot/controller/services.py b/v2realbot/controller/services.py index 70a259d..ed6d025 100644 --- a/v2realbot/controller/services.py +++ b/v2realbot/controller/services.py @@ -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: diff --git a/v2realbot/static/index.html b/v2realbot/static/index.html index 53de61e..fb6a51a 100644 --- a/v2realbot/static/index.html +++ b/v2realbot/static/index.html @@ -92,7 +92,7 @@ -
+
@@ -101,7 +101,7 @@
- +
@@ -149,11 +149,11 @@ -
-
+
+
@@ -162,7 +162,7 @@
-
Id
+
@@ -210,43 +210,42 @@ - -
Id
+
@@ -428,12 +427,16 @@
- - +
+ + +
- - +
+ + +
diff --git a/v2realbot/static/js/archivechart.js b/v2realbot/static/js/archivechart.js index 640e72c..e5d2b5a 100644 --- a/v2realbot/static/js/archivechart.js +++ b/v2realbot/static/js/archivechart.js @@ -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)); } }) } diff --git a/v2realbot/static/js/archivetables.js b/v2realbot/static/js/archivetables.js index 5b70b9e..5ac88d4 100644 --- a/v2realbot/static/js/archivetables.js +++ b/v2realbot/static/js/archivetables.js @@ -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 '
'+data+'' + }, + }, + { + 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"); diff --git a/v2realbot/static/js/livewebsocket.js b/v2realbot/static/js/livewebsocket.js index 76505a6..4906e9c 100644 --- a/v2realbot/static/js/livewebsocket.js +++ b/v2realbot/static/js/livewebsocket.js @@ -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)); } }) } diff --git a/v2realbot/static/js/mytables.js b/v2realbot/static/js/mytables.js index ba27867..45f009d 100644 --- a/v2realbot/static/js/mytables.js +++ b/v2realbot/static/js/mytables.js @@ -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 ''+status+'' }, - }], + }, + { + targets: 0, + render: function ( data, type, row ) { + return '
'+data+'' + }, + }, + ], 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 '
'+data+'' + }, + }, + { + targets: [2], + render: function ( data, type, row ) { + return format_date(data) + }, + }, + ], // select: { // style: 'multi' // }, diff --git a/v2realbot/static/js/utils.js b/v2realbot/static/js/utils.js index 00ae9a2..90c5ae2 100644 --- a/v2realbot/static/js/utils.js +++ b/v2realbot/static/js/utils.js @@ -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("") diff --git a/v2realbot/static/main.css b/v2realbot/static/main.css index 29ce6a8..29e703a 100644 --- a/v2realbot/static/main.css +++ b/v2realbot/static/main.css @@ -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;
Id