ok
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -31,3 +31,4 @@ share/python-wheels/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
strat.log
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
INFO: Started server process [56033]
|
||||
INFO: Waiting for application startup.
|
||||
INFO: Application startup complete.
|
||||
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
|
||||
INFO: Shutting down
|
||||
INFO: Waiting for application shutdown.
|
||||
INFO: Application shutdown complete.
|
||||
INFO: Finished server process [56033]
|
||||
@ -7,37 +7,36 @@
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
|
||||
<link href="https://cdn.datatables.net/1.13.4/css/jquery.dataTables.min.css" rel="stylesheet">
|
||||
<script src="/static/js/jquery.dataTables.min.js"></script>
|
||||
<link rel="stylesheet" href="/static/main.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="mainConteiner">
|
||||
<div class="realtime">
|
||||
<h1>Realtime chart</h1>
|
||||
<h2>Your ID: <span id="ws-id"></span></h2>
|
||||
<h3>Status: <span id="status">Not connected</span></h3>
|
||||
<form action="" onsubmit="sendMessage(event)">
|
||||
<label>Runner ID: <input type="text" id="runnerId" autocomplete="off" value=""/></label>
|
||||
<button onclick="connect(event)" id="bt-conn">Connect</button>
|
||||
<button onclick="disconnect(event)" id="bt-disc" style="display: None">Disconnect</button>
|
||||
<hr>
|
||||
<label>Message: <input type="text" id="messageText" autocomplete="off"/></label>
|
||||
<button>Send</button>
|
||||
<div id="main" class="mainConteiner flex-container">
|
||||
<div id="chartContainer" class="flex-items">
|
||||
<h4>Status: <span id="status">Not connected</span></h4>
|
||||
<div id="formular">
|
||||
<form action="">
|
||||
<input type="text" id="runnerId" autocomplete="off" placeholder="StrategyID" value=""/>
|
||||
<button onclick="connect(event)" id="bt-conn" class="btn btn-success">Connect</button>
|
||||
<button onclick="disconnect(event)" id="bt-disc" style="display: None" class="btn btn-success">Disconnect</button>
|
||||
<!-- <label>Message: --> <input type="text" id="messageText" autocomplete="off" placeholder="WS out message"/>
|
||||
<button onclick="sendMessage(event)" id="bt.send" class="btn btn-success">Send</button>
|
||||
</form>
|
||||
</div>
|
||||
<ul id='messages'>
|
||||
</ul>
|
||||
<div id="chart"></div>
|
||||
<div id="conteiner"></div>
|
||||
<div class="legend" id="legend"></div>
|
||||
</div>
|
||||
|
||||
<div id="runner-table" class="flex-items">
|
||||
<div id="controls">
|
||||
<label>API-KEY: <input type="password" id="api-key" autocomplete="off"/></label>
|
||||
<button onclick="store_api_key(event)" id="bt-store">Store</button>
|
||||
</div>
|
||||
<div id="runner-table">
|
||||
<button onclick="store_api_key(event)" id="bt-store" class="btn btn-success">Store</button>
|
||||
<button id="button_pause" class="btn btn-success">Pause/Unpause</button>
|
||||
<button id="button_stop" class="btn btn-success">Stop</button>
|
||||
<button id="button_stopall" class="btn btn-success">Stop All</button>
|
||||
<button id="button_refresh" class="btn btn-success">Refresh</button>
|
||||
|
||||
</div>
|
||||
<div id="runner-table">
|
||||
<table id="runnerTable" class="display" style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -60,7 +59,7 @@
|
||||
<h4 class="modal-title"><i class="fa fa-plus"></i> Stop Strategy</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group"
|
||||
<div class="form-group">
|
||||
<label for="runnerid" class="control-label">Id</label>
|
||||
<input type="text" class="form-control" id="runnerid" name="runnerid" placeholder="id">
|
||||
</div>
|
||||
@ -73,9 +72,8 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div id="stratin-table" class="flex-items">
|
||||
<div id="stratin-table">
|
||||
<button id="button_add" class="btn btn-success">Add</button><button id="button_edit" class="btn btn-success">Edit</button><button id="button_delete" class="btn btn-success">Delete</button><button id="button_run" class="btn btn-success">Run Strategy</button>
|
||||
<table id="stratinTable" class="display" style="width:100%">
|
||||
@ -109,15 +107,15 @@
|
||||
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Record</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group"
|
||||
<div class="form-group">
|
||||
<label for="id" class="control-label">Id</label>
|
||||
<input type="text" class="form-control" id="id" name="id" placeholder="id" readonly>
|
||||
</div>
|
||||
<div class="form-group"
|
||||
<div class="form-group">
|
||||
<label for="id2" class="control-label">Id2</label>
|
||||
<input type="text" class="form-control" id="id2" name="id2" placeholder="id2" required>
|
||||
</div>
|
||||
<div class="form-group"
|
||||
<div class="form-group">
|
||||
<label for="name" class="control-label">Name</label>
|
||||
<input type="text" class="form-control" id="name" name="name" placeholder="Name" required>
|
||||
</div>
|
||||
@ -177,7 +175,7 @@
|
||||
<h4 class="modal-title"><i class="fa fa-plus"></i> Delete Record</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group"
|
||||
<div class="form-group">
|
||||
<label for="delid" class="control-label">Id</label>
|
||||
<input type="text" class="form-control" id="delid" name="delid" placeholder="id">
|
||||
</div>
|
||||
@ -190,7 +188,6 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="runModal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<form method="post" id="runForm">
|
||||
@ -200,15 +197,15 @@
|
||||
<h4 class="modal-title"><i class="fa fa-plus"></i> Run strategy</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group"
|
||||
<div class="form-group">
|
||||
<label for="runid" class="control-label">Id</label>
|
||||
<input type="text" class="form-control" id="runid" name="runid" placeholder="id" readonly>
|
||||
</div>
|
||||
<div class="form-group"
|
||||
<div class="form-group">
|
||||
<label for="mode" class="control-label">Mode</label>
|
||||
<select class="form-control" id="mode" name="mode"><option value="paper">paper</option><option value="live">live</option><option value="backtest">backtest</option></select>
|
||||
</div>
|
||||
<div class="form-group"
|
||||
<div class="form-group">
|
||||
<label for="account" class="control-label">Account</label>
|
||||
<select class="form-control" id="account" name="account"><option value="ACCOUNT1">ACCOUNT1</option><option value="ACCOUNT2">ACCOUNT2</option></select>
|
||||
</div>
|
||||
@ -240,10 +237,10 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script type="text/javascript" src="https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.production.js"
|
||||
></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.production.js"></script>
|
||||
<script src="/static/js/mywebsocket.js"></script>
|
||||
<script src="/static/js/mychart.js"></script>
|
||||
<script src="/static/js/mytables.js"></script>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//const chartOptions = { layout: { textColor: 'black', background: { type: 'solid', color: 'white' } } };
|
||||
const chartOptions = { width: 800, height: 600}
|
||||
const chart = LightweightCharts.createChart(document.getElementById('conteiner'), chartOptions);
|
||||
const chartOptions = { width: 1200, height: 600}
|
||||
const chart = LightweightCharts.createChart(document.getElementById('chart'), chartOptions);
|
||||
chart.applyOptions({ timeScale: { visible: true, timeVisible: true, secondsVisible: true }, crosshair: {
|
||||
mode: LightweightCharts.CrosshairMode.Normal, labelVisible: true
|
||||
}})
|
||||
@ -28,15 +28,12 @@ const vwapSeries = chart.addLineSeries({
|
||||
|
||||
|
||||
//TBD dynamicky zobrazovat vsechny indikatory
|
||||
document.getElementById('conteiner').style.display = 'inline-block';
|
||||
var cont = document.getElementById('conteiner');
|
||||
var legend = document.createElement('div');
|
||||
legend.classList.add('legend');
|
||||
cont.appendChild(legend);
|
||||
//document.getElementById('chart').style.display = 'inline-block';
|
||||
var legendlist = document.getElementById('legend');
|
||||
var firstRow = document.createElement('div');
|
||||
firstRow.innerText = '-';
|
||||
// firstRow.style.color = 'white';
|
||||
legend.appendChild(firstRow);
|
||||
legendlist.appendChild(firstRow);
|
||||
|
||||
function pad(n) {
|
||||
var s = ('0' + n);
|
||||
@ -49,7 +46,15 @@ chart.subscribeCrosshairMove((param) => {
|
||||
const vwap = data.value !== undefined ? data.value : data.close;
|
||||
const bars = param.seriesData.get(candlestickSeries);
|
||||
const volumes = param.seriesData.get(volumeSeries);
|
||||
firstRow.innerText = 'VWAP' + ' ' + vwap.toFixed(2) + " O" + bars.open + " H" + bars.high + " L" + bars.low + " C" + bars.close + " V" + volumes.value;
|
||||
firstRow.innerText = "";
|
||||
//iterate of custom indicators dictionary to get values of custom lines
|
||||
// var customIndicator = {name: key, series: null}
|
||||
indList.forEach(function (item) {
|
||||
const ind = param.seriesData.get(item.series)
|
||||
firstRow.innerText += item.name + " " + ind.value + " ";
|
||||
});
|
||||
|
||||
firstRow.innerText += 'vwap' + ' ' + vwap.toFixed(2) + " o" + bars.open + " h" + bars.high + " l" + bars.low + " c" + bars.close + " v" + volumes.value;
|
||||
}
|
||||
else {
|
||||
firstRow.innerText = '-';
|
||||
|
||||
@ -9,10 +9,6 @@ function store_api_key(event) {
|
||||
}
|
||||
|
||||
function get_status(id) {
|
||||
|
||||
// for (val of stratinRecords.rows().iterator()) {
|
||||
// window.alert(JSON.stringify(val))
|
||||
// }
|
||||
var status = "stopped"
|
||||
runnerRecords.rows().iterator('row', function ( context, index ) {
|
||||
var data = this.row(index).data();
|
||||
@ -32,6 +28,18 @@ function get_status(id) {
|
||||
return status
|
||||
}
|
||||
|
||||
function is_running(id) {
|
||||
var running = false
|
||||
runnerRecords.rows().iterator('row', function ( context, index ) {
|
||||
var data = this.row(index).data();
|
||||
//window.alert(JSON.stringify(data))
|
||||
if (data.id == id) {
|
||||
running = true
|
||||
}
|
||||
//window.alert("found") }
|
||||
});
|
||||
return running
|
||||
}
|
||||
// alert(JSON.stringify(stratinRecords.data()))
|
||||
// arr = stratinRecords.data()
|
||||
// foreach(row in arr.rows) {
|
||||
@ -263,7 +271,13 @@ var stratinRecords =
|
||||
return '<i class="fas fa-check-circle">'+status+'</i>'
|
||||
},
|
||||
}],
|
||||
paging: false
|
||||
paging: false,
|
||||
// createdRow: function( row, data, dataIndex){
|
||||
// if (is_running(data.id) ){
|
||||
// alert("runner");
|
||||
// $(row).addClass('highlight');
|
||||
// }
|
||||
//}
|
||||
} );
|
||||
|
||||
//runner table
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
var indList = []
|
||||
var ws = null;
|
||||
function connect(event) {
|
||||
var runnerId = document.getElementById("runnerId")
|
||||
var indList = []
|
||||
try {
|
||||
ws = new WebSocket("ws://localhost:8000/runners/" + runnerId.value + "/ws?api_key=" + API_KEY);
|
||||
}
|
||||
@ -10,7 +10,7 @@ function connect(event) {
|
||||
}
|
||||
ws.onopen = function(event) {
|
||||
document.getElementById("status").textContent = "Connected to" + runnerId.value
|
||||
document.getElementById("bt-disc").style.display = "block"
|
||||
document.getElementById("bt-disc").style.display = "initial"
|
||||
document.getElementById("bt-conn").style.display = "none"
|
||||
}
|
||||
ws.onmessage = function(event) {
|
||||
@ -89,7 +89,7 @@ function connect(event) {
|
||||
ws.onclose = function(event) {
|
||||
document.getElementById("status").textContent = "Disconnected from" + runnerId.value
|
||||
document.getElementById("bt-disc").style.display = "none"
|
||||
document.getElementById("bt-conn").style.display = "block"
|
||||
document.getElementById("bt-conn").style.display = "initial"
|
||||
}
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
33
v2realbot/static/main.css
Normal file
33
v2realbot/static/main.css
Normal file
@ -0,0 +1,33 @@
|
||||
.flex-container {
|
||||
display: inline-grid;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-start;
|
||||
align-items: stretch;
|
||||
align-content: normal;
|
||||
}
|
||||
|
||||
.flex-items{
|
||||
display: block;
|
||||
flex-grow: 0;
|
||||
flex-shrink: 1;
|
||||
flex-basis: auto;
|
||||
align-self: auto;
|
||||
order: 0;
|
||||
margin-inline-start: 50px;
|
||||
}
|
||||
|
||||
.chartContainer {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.legend {
|
||||
position: absolute;
|
||||
color: #050505;
|
||||
left: 60px;
|
||||
top: 99px;
|
||||
z-index: 1;
|
||||
font-size: 16px;
|
||||
line-height: 18px;
|
||||
font-weight: 300;
|
||||
}
|
||||
Reference in New Issue
Block a user