This commit is contained in:
@ -98,7 +98,7 @@ def row_to_runmanager(row: dict) -> RunManagerRecord:
|
|||||||
|
|
||||||
#prevede dict radku zpatky na objekt vcetme retypizace
|
#prevede dict radku zpatky na objekt vcetme retypizace
|
||||||
def row_to_runarchiveview(row: dict) -> RunArchiveView:
|
def row_to_runarchiveview(row: dict) -> RunArchiveView:
|
||||||
return RunArchive(
|
a = RunArchiveView(
|
||||||
id=row['runner_id'],
|
id=row['runner_id'],
|
||||||
strat_id=row['strat_id'],
|
strat_id=row['strat_id'],
|
||||||
batch_id=row['batch_id'],
|
batch_id=row['batch_id'],
|
||||||
@ -116,8 +116,11 @@ def row_to_runarchiveview(row: dict) -> RunArchiveView:
|
|||||||
trade_count=int(row['trade_count']),
|
trade_count=int(row['trade_count']),
|
||||||
end_positions=int(row['end_positions']),
|
end_positions=int(row['end_positions']),
|
||||||
end_positions_avgp=float(row['end_positions_avgp']),
|
end_positions_avgp=float(row['end_positions_avgp']),
|
||||||
metrics=orjson.loads(row['metrics']) if row['metrics'] else None
|
metrics=orjson.loads(row['metrics']) if row['metrics'] else None,
|
||||||
|
batch_profit=int(row['batch_profit']) if row['batch_profit'] else 0,
|
||||||
|
batch_count=int(row['batch_count']) if row['batch_count'] else 0,
|
||||||
)
|
)
|
||||||
|
return a
|
||||||
|
|
||||||
#prevede dict radku zpatky na objekt vcetme retypizace
|
#prevede dict radku zpatky na objekt vcetme retypizace
|
||||||
def row_to_runarchive(row: dict) -> RunArchive:
|
def row_to_runarchive(row: dict) -> RunArchive:
|
||||||
|
|||||||
@ -320,6 +320,8 @@ class RunArchiveView(BaseModel):
|
|||||||
end_positions: int = 0
|
end_positions: int = 0
|
||||||
end_positions_avgp: float = 0
|
end_positions_avgp: float = 0
|
||||||
metrics: Union[dict, str] = None
|
metrics: Union[dict, str] = None
|
||||||
|
batch_profit: float = 0 # Total profit for the batch - now calculated during query
|
||||||
|
batch_count: int = 0 # Count of runs in the batch - now calculated during query
|
||||||
|
|
||||||
#same but with pagination
|
#same but with pagination
|
||||||
class RunArchiveViewPagination(BaseModel):
|
class RunArchiveViewPagination(BaseModel):
|
||||||
|
|||||||
@ -1126,7 +1126,9 @@ def get_all_archived_runners_p(request: DataTablesRequest) -> Tuple[int, RunArch
|
|||||||
SELECT runner_id, strat_id, batch_id, symbol, name, note, started,
|
SELECT runner_id, strat_id, batch_id, symbol, name, note, started,
|
||||||
stopped, mode, account, bt_from, bt_to, ilog_save, profit,
|
stopped, mode, account, bt_from, bt_to, ilog_save, profit,
|
||||||
trade_count, end_positions, end_positions_avgp, metrics,
|
trade_count, end_positions, end_positions_avgp, metrics,
|
||||||
MAX(stopped) OVER (PARTITION BY batch_id) AS max_stopped
|
MAX(stopped) OVER (PARTITION BY batch_id) AS max_stopped,
|
||||||
|
SUM(profit) OVER (PARTITION BY batch_id) AS batch_profit,
|
||||||
|
COUNT(*) OVER (PARTITION BY batch_id) AS batch_count
|
||||||
FROM runner_header
|
FROM runner_header
|
||||||
WHERE (:search_value = '' OR strat_id LIKE :search_value OR batch_id LIKE :search_value)
|
WHERE (:search_value = '' OR strat_id LIKE :search_value OR batch_id LIKE :search_value)
|
||||||
),
|
),
|
||||||
@ -1140,7 +1142,8 @@ def get_all_archived_runners_p(request: DataTablesRequest) -> Tuple[int, RunArch
|
|||||||
)
|
)
|
||||||
SELECT runner_id, strat_id, batch_id, symbol, name, note, started,
|
SELECT runner_id, strat_id, batch_id, symbol, name, note, started,
|
||||||
stopped, mode, account, bt_from, bt_to, ilog_save, profit,
|
stopped, mode, account, bt_from, bt_to, ilog_save, profit,
|
||||||
trade_count, end_positions, end_positions_avgp, metrics
|
trade_count, end_positions, end_positions_avgp, metrics,
|
||||||
|
batch_profit, batch_count
|
||||||
FROM InterleavedGroups
|
FROM InterleavedGroups
|
||||||
ORDER BY
|
ORDER BY
|
||||||
sort_key DESC,
|
sort_key DESC,
|
||||||
|
|||||||
@ -595,7 +595,9 @@
|
|||||||
<th>pos</th>
|
<th>pos</th>
|
||||||
<th>avgp</th>
|
<th>avgp</th>
|
||||||
<th>metrics</th>
|
<th>metrics</th>
|
||||||
<th>batchid</th>
|
<th>batchid</th>
|
||||||
|
<th>batchprofit</th>
|
||||||
|
<th>batchcount</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody></tbody>
|
<tbody></tbody>
|
||||||
@ -1158,7 +1160,7 @@
|
|||||||
|
|
||||||
<!-- <script src="/static/js/archivetables.js?v=1.05"></script> -->
|
<!-- <script src="/static/js/archivetables.js?v=1.05"></script> -->
|
||||||
<!-- archiveTables split into separate files -->
|
<!-- archiveTables split into separate files -->
|
||||||
<script src="/static/js/tables/archivetable/init.js?v=1.09"></script>
|
<script src="/static/js/tables/archivetable/init.js?v=1.10"></script>
|
||||||
<script src="/static/js/tables/archivetable/functions.js?v=1.09"></script>
|
<script src="/static/js/tables/archivetable/functions.js?v=1.09"></script>
|
||||||
<script src="/static/js/tables/archivetable/modals.js?v=1.07"></script>
|
<script src="/static/js/tables/archivetable/modals.js?v=1.07"></script>
|
||||||
<script src="/static/js/tables/archivetable/handlers.js?v=1.07"></script>
|
<script src="/static/js/tables/archivetable/handlers.js?v=1.07"></script>
|
||||||
|
|||||||
@ -42,6 +42,8 @@ function initialize_archiveRecords() {
|
|||||||
{data: 'end_positions_avgp', visible: true},
|
{data: 'end_positions_avgp', visible: true},
|
||||||
{data: 'metrics', visible: true},
|
{data: 'metrics', visible: true},
|
||||||
{data: 'batch_id', visible: true},
|
{data: 'batch_id', visible: true},
|
||||||
|
{data: 'batch_profit', visible: true},
|
||||||
|
{data: 'batch_count', visible: true},
|
||||||
],
|
],
|
||||||
paging: true,
|
paging: true,
|
||||||
processing: true,
|
processing: true,
|
||||||
@ -237,6 +239,8 @@ function initialize_archiveRecords() {
|
|||||||
var groupId = group ? group : 'no-batch-id-' + firstRowData.id;
|
var groupId = group ? group : 'no-batch-id-' + firstRowData.id;
|
||||||
var stateKey = 'dt-group-state-' + groupId;
|
var stateKey = 'dt-group-state-' + groupId;
|
||||||
var state = localStorage.getItem(stateKey);
|
var state = localStorage.getItem(stateKey);
|
||||||
|
var profit = firstRowData.batch_profit
|
||||||
|
var itemCount = firstRowData.batch_count
|
||||||
|
|
||||||
// Iterate over each row in the group to set the data attribute
|
// Iterate over each row in the group to set the data attribute
|
||||||
// zaroven pro kazdy node nastavime viditelnost podle nastaveni
|
// zaroven pro kazdy node nastavime viditelnost podle nastaveni
|
||||||
@ -252,10 +256,10 @@ function initialize_archiveRecords() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Initialize variables for the group
|
// Initialize variables for the group
|
||||||
var itemCount = 0;
|
//var itemCount = 0;
|
||||||
var period = '';
|
var period = '';
|
||||||
var batch_note = '';
|
var batch_note = '';
|
||||||
var profit = '';
|
//var profit = '';
|
||||||
var started = null;
|
var started = null;
|
||||||
var stratinId = null;
|
var stratinId = null;
|
||||||
var symbol = null;
|
var symbol = null;
|
||||||
@ -292,15 +296,15 @@ function initialize_archiveRecords() {
|
|||||||
const existingBatch = batchHeaders.find(batch => batch.batch_id == group);
|
const existingBatch = batchHeaders.find(batch => batch.batch_id == group);
|
||||||
//jeste neni v poli batchu - udelame hlavicku
|
//jeste neni v poli batchu - udelame hlavicku
|
||||||
if (!existingBatch) {
|
if (!existingBatch) {
|
||||||
itemCount = extractNumbersFromString(firstRowData.note);
|
// itemCount = extractNumbersFromString(firstRowData.note);
|
||||||
if (!itemCount) {
|
// if (!itemCount) {
|
||||||
itemCount="NA"
|
// itemCount="NA"
|
||||||
}
|
// }
|
||||||
|
|
||||||
try { profit = firstRowData.metrics.profit.batch_sum_profit;}
|
// try { profit = firstRowData.metrics.profit.batch_sum_profit;}
|
||||||
catch (e) {profit = 'NA'}
|
// catch (e) {profit = 'NA'}
|
||||||
|
|
||||||
if (!profit) {profit = 'NA'}
|
// if (!profit) {profit = 'NA'}
|
||||||
period = firstRowData.note ? firstRowData.note.substring(0, 14) : '';
|
period = firstRowData.note ? firstRowData.note.substring(0, 14) : '';
|
||||||
try {
|
try {
|
||||||
batch_note = firstRowData.note ? firstRowData.note.split("N:")[1].trim() : ''
|
batch_note = firstRowData.note ? firstRowData.note.split("N:")[1].trim() : ''
|
||||||
@ -316,10 +320,10 @@ function initialize_archiveRecords() {
|
|||||||
}
|
}
|
||||||
//uz je v poli, ale mame novejsi (pribyl v ramci backtestu napr.) - updatujeme
|
//uz je v poli, ale mame novejsi (pribyl v ramci backtestu napr.) - updatujeme
|
||||||
else if (new Date(existingBatch.started) < new Date(firstRowData.started)) {
|
else if (new Date(existingBatch.started) < new Date(firstRowData.started)) {
|
||||||
try {itemCount = extractNumbersFromString(firstRowData.note);}
|
// try {itemCount = extractNumbersFromString(firstRowData.note);}
|
||||||
catch (e) {itemCount = 'NA'}
|
// catch (e) {itemCount = 'NA'}
|
||||||
try {profit = firstRowData.metrics.profit.batch_sum_profit;}
|
// try {profit = firstRowData.metrics.profit.batch_sum_profit;}
|
||||||
catch (e) {profit = 'NA'}
|
// catch (e) {profit = 'NA'}
|
||||||
period = firstRowData.note ? firstRowData.note.substring(0, 14) : '';
|
period = firstRowData.note ? firstRowData.note.substring(0, 14) : '';
|
||||||
if (period.startsWith("SCHED")) {
|
if (period.startsWith("SCHED")) {
|
||||||
period = "SCHEDULER";
|
period = "SCHEDULER";
|
||||||
|
|||||||
Reference in New Issue
Block a user