gui onclick timestamp enhancements

This commit is contained in:
David Brazda
2023-04-24 21:38:20 +02:00
parent 0c2e441aac
commit a40b899b1d
6 changed files with 26 additions and 3 deletions

View File

@ -59,7 +59,11 @@ chart.subscribeCrosshairMove((param) => {
});
firstRow.innerText += ' vwap' + ' ' + vwap.toFixed(2) + " O" + bars.open + " H" + bars.high + " L" + bars.low + " C" + bars.close + " V" + volumes.value + "";
}
//display timestamp in trade-timestamp input field
$('#trade-timestamp').val(param.time)
}
else {
firstRow.innerText = '-';
}

View File

@ -9,6 +9,11 @@ function findCommonElements3(arr1, arr2) {
return arr1.some(item => arr2.includes(item))
}
function set_timestamp(timestamp) {
//console.log(timestamp);
$('#trade-timestamp').val(timestamp);
}
//KEY shortcuts
Mousetrap.bind('e', function() {
$( "#button_edit" ).trigger( "click" );
@ -222,6 +227,14 @@ $(document).ready(function () {
})
});
//on hover of each logline move timestamp to trade history input field
// $('.line').click(function () {
// timestamp = $(this).data("timestamp");
// console.log(timestamp);
// $('#trade-timestamp').val(timestamp);
// })
//button refresh
$('#button_refresh').click(function () {
runnerRecords.ajax.reload();

View File

@ -82,7 +82,7 @@ function connect(event) {
logcnt++;
row = '<div data-toggle="collapse" data-target="#rec'+logcnt+'">'+logLine.time + " " + logLine.event + ' - '+ (logLine.message == undefined ? "" : logLine.message) +'</div>'
row = '<div data-toggle="collapse" onclick="set_timestamp(' + logLine.time + ')" data-target="#rec'+logcnt+'">'+logLine.time + " " + logLine.event + ' - '+ (logLine.message == undefined ? "" : logLine.message) +'</div>'
str_row = JSON.stringify(logLine.details, null, 2)
//row_detail = '<div id="rec'+logcnt+'" data-toggle="collapse" data-target="#rec'+logcnt+'"class="collapse pidi"><pre>' + str_row + '</pre></div>'
@ -91,6 +91,7 @@ function connect(event) {
var lines = document.getElementById('lines')
var line = document.createElement('div')
line.classList.add("line")
line.dataset.timestamp = logLine.time
line.insertAdjacentHTML( 'beforeend', row );
line.insertAdjacentHTML( 'beforeend', row_detail );

View File

@ -106,7 +106,7 @@ class Strategy:
#propojujeme notifice s interfacem (pro callback)
self.order_notifs.connect_callback(self)
self.state = StrategyState(name=self.name, symbol = self.symbol, stratvars = self.stratvars, interface=self.interface, rectype=self.rectype)
elif mode == Mode.BT:
self.dataloader = Trade_Offline_Streamer(start, end, btdata=self.btdata)
self.bt = Backtester(symbol = self.symbol, order_fill_callback= self.order_updates, btdata=self.btdata, cash=cash, bp_from=start, bp_to=end)
@ -121,6 +121,7 @@ class Strategy:
return -1
self.mode = mode
self.state.mode = self.mode
"""SAVE record to respective STATE variables (bar or trades)
ukládáme i index pro případné indikátory - pro zobrazení v grafu
@ -517,8 +518,12 @@ class StrategyState:
self.iter_log_list = []
self.profit = 0
self.tradeList = []
self.mode = None
def ilog(self, e: str = None, msg: str = None, **kwargs):
if self.mode == Mode.LIVE or self.mode == Mode.PAPER:
self.time = datetime.now().timestamp()
if e is None:
if msg is None:
row = dict(time=self.time, details=kwargs)