diff --git a/v2realbot/controller/services.py b/v2realbot/controller/services.py index 42959b0..da1b6e2 100644 --- a/v2realbot/controller/services.py +++ b/v2realbot/controller/services.py @@ -809,7 +809,7 @@ def populate_metrics_output_directory(strat: StrategyInstance, inter_batch_param rp_string = "RP" + str(float(np.sum(strat.state.rel_profit_cum))) if len(strat.state.rel_profit_cum) >0 else "noRP" ##summary pro rychle zobrazeni P333L-222 PT9:30 PL10:30 - res["profit"]["sum"]="P"+str(int(sum_wins))+"L"+str(int(sum_losses))+" "+"MCP"+str(int(max_profit))+"MCL(DD)"+str(int(max_loss))+" "+ mpt_string+" " + mlt_string + rp_string + " "+str(strat.state.rel_profit_cum) + res["profit"]["sum"]="P"+str(int(sum_wins))+"L"+str(int(sum_losses))+" "+"MP"+str(int(max_profit))+"ML"+str(int(max_loss))+" "+ mpt_string+" " + mlt_string + rp_string + " "+str(strat.state.rel_profit_cum) #rel_profit zprumerovane res["profit"]["daily_rel_profit_sum"] = float(np.sum(strat.state.rel_profit_cum)) if len(strat.state.rel_profit_cum) > 0 else 0 diff --git a/v2realbot/static/js/archivetables.js b/v2realbot/static/js/archivetables.js index 2ecc6d6..8c615e0 100644 --- a/v2realbot/static/js/archivetables.js +++ b/v2realbot/static/js/archivetables.js @@ -2,6 +2,7 @@ let editor_diff_arch1 let editor_diff_arch2 var archData = null +var batchHeaders = [] function refresh_arch_and_callback(row, callback) { //console.log("entering refresh") @@ -954,7 +955,7 @@ var archiveRecords = {data: 'metrics', visible: true}, {data: 'batch_id', visible: true}, ], - paging: false, + paging: true, processing: true, serverSide: true, columnDefs: [{ @@ -1126,40 +1127,75 @@ var archiveRecords = // Add row grouping based on 'batch_id' rowGroup: { dataSrc: 'batch_id', + //toto je volano pri renderovani groupy startRender: function (rows, group) { var groupId = group ? group : 'no-batch-id'; // Initialize variables for the group var itemCount = 0; - var firstNote = ''; + var period = ''; var profit = ''; + var started = null; + + // // Process each item only once + // archiveRecords.rows({ search: 'applied' }).every(function (rowIdx, tableLoop, rowLoop) { + // var data = this.data(); - // Process each item only once - archiveRecords.rows({ search: 'applied' }).every(function (rowIdx, tableLoop, rowLoop) { - var data = this.data(); - - if ((group && data.batch_id === group)) { - itemCount++; - if (itemCount === 1) { - firstNote = data.note ? data.note.substring(0, 14) : ''; - try { - profit = data.metrics.profit.batch_sum_profit; - } catch (e) { - profit = 'N/A'; - } - } + // if ((group && data.batch_id == group)) { + // itemCount++; + // if (itemCount === 1 ) { + // firstNote = data.note ? data.note.substring(0, 14) : ''; + + // if (data.note) { + // better_counter = extractNumbersFromString(data.note); + // } + // try { + // profit = data.metrics.profit.batch_sum_profit; + // } catch (e) { + // profit = 'N/A'; + // } + // } + // } + // }); + + + //pokud mame batch_id podivame se zda jeho nastaveni uz nema a pokud ano pouzijeme to + //pokud nemame tak si ho loadneme + if (group) { + const existingBatch = batchHeaders.find(batch => batch.batch_id == group); + var firstRowData = rows.data()[0]; + //jeste neni v poli batchu - udelame hlavicku + if (!existingBatch) { + itemCount = extractNumbersFromString(firstRowData.note); + profit = firstRowData.metrics.profit.batch_sum_profit; + period = firstRowData.note ? firstRowData.note.substring(0, 14) : ''; + started = firstRowData.started + var newBatchHeader = {batch_id:group, profit:profit, itemCount:itemCount, period:period, started:started} + batchHeaders.push(newBatchHeader) } - }); - + //uz je v poli, ale mame novejsi (pribyl v ramci backtestu napr.) - updatujeme + else if (new Date(existingBatch.started) < new Date(firstRowData.started)) { + itemCount = extractNumbersFromString(firstRowData.note); + profit = firstRowData.metrics.profit.batch_sum_profit; + period = firstRowData.note ? firstRowData.note.substring(0, 14) : ''; + started = firstRowData.started + existingBatch.itemCount = itemCount; + existingBatch.profit = profit; + existingBatch.period = period; + existingBatch.started = started; + } + //uz je v poli batchu vytahneme + else { + profit = existingBatch.profit + itemCount = existingBatch.itemCount + period = existingBatch.period + started = existingBatch.started + } + } + // Construct the group header var groupHeaderContent = '' + (group ? 'Batch ID: ' + group : 'No Batch') + ''; - groupHeaderContent += (group ? ' (' + itemCount + ')' : ''); - if (firstNote) { - groupHeaderContent += ' ' + firstNote; - } - if (profit) { - groupHeaderContent += ' - Profit: ' + profit + ''; - } + groupHeaderContent += (group ? ' (' + itemCount + ')' + ' ' + period + ' Profit: ' + profit + '' : ''); return $('