delete batchid na gui
This commit is contained in:
@ -343,7 +343,7 @@ def capsule(target: object, db: object, inter_batch_params: dict = None):
|
|||||||
print(f"Daily report ERROR - {val}")
|
print(f"Daily report ERROR - {val}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Nepodarilo se vytvorit report image", str(e)+format_exc())
|
print("Nepodarilo se vytvorit report image", str(e)+format_exc())
|
||||||
|
target.release()
|
||||||
print("Runner STOPPED")
|
print("Runner STOPPED")
|
||||||
|
|
||||||
#vrátí konkrétní sadu testlistu
|
#vrátí konkrétní sadu testlistu
|
||||||
@ -519,6 +519,8 @@ def batch_run_manager(id: UUID, runReq: RunRequest, rundays: list[RunDay]):
|
|||||||
#i.history += str(runner.__dict__)+"<BR>"
|
#i.history += str(runner.__dict__)+"<BR>"
|
||||||
db.save()
|
db.save()
|
||||||
|
|
||||||
|
inter_batch_params = None
|
||||||
|
runReq = None
|
||||||
#vytvoreni report image pro batch
|
#vytvoreni report image pro batch
|
||||||
try:
|
try:
|
||||||
res, val = generate_trading_report_image(batch_id=batch_id)
|
res, val = generate_trading_report_image(batch_id=batch_id)
|
||||||
@ -1077,6 +1079,23 @@ def delete_report_files(id):
|
|||||||
print(f"An error occurred while deleting the file: {e}")
|
print(f"An error occurred while deleting the file: {e}")
|
||||||
return (-1, str(e))
|
return (-1, str(e))
|
||||||
|
|
||||||
|
#delete runners by BatchID
|
||||||
|
#NOTE: Batch image is deleted on runners level - uvidime jak to bude moc overhead
|
||||||
|
def delete_archived_runners_byBatchID(batch_id: str):
|
||||||
|
res, runner_ids = get_archived_runnerslist_byBatchID(batch_id)
|
||||||
|
|
||||||
|
if res != 0:
|
||||||
|
print(f"no batch {batch_id} found")
|
||||||
|
return -1, f"no batch {batch_id} found"
|
||||||
|
|
||||||
|
res, val = delete_archived_runners_byIDs(runner_ids)
|
||||||
|
|
||||||
|
if res == 0:
|
||||||
|
return 0, batch_id
|
||||||
|
else:
|
||||||
|
print(f"error delete")
|
||||||
|
return res, f"ERROR deleting {batch_id} : {val}"
|
||||||
|
|
||||||
#delete runner in archive and archive detail and runner logs
|
#delete runner in archive and archive detail and runner logs
|
||||||
#predelano do JEDNE TRANSAKCE
|
#predelano do JEDNE TRANSAKCE
|
||||||
def delete_archived_runners_byIDs(ids: list[UUID]):
|
def delete_archived_runners_byIDs(ids: list[UUID]):
|
||||||
@ -1096,8 +1115,9 @@ def delete_archived_runners_byIDs(ids: list[UUID]):
|
|||||||
c.execute("SELECT COUNT(*) FROM runner_header WHERE batch_id = ?", (batch_id,))
|
c.execute("SELECT COUNT(*) FROM runner_header WHERE batch_id = ?", (batch_id,))
|
||||||
count = c.fetchone()[0]
|
count = c.fetchone()[0]
|
||||||
if count == 1:
|
if count == 1:
|
||||||
# If it's the last record, call delete_report_files
|
# If it's the last record, call delete_batch_report_files
|
||||||
delete_report_files(batch_id)
|
delete_report_files(batch_id)
|
||||||
|
print("Batch report file deleted")
|
||||||
|
|
||||||
resh = c.execute(f"DELETE from runner_header WHERE runner_id='{str(id)}';")
|
resh = c.execute(f"DELETE from runner_header WHERE runner_id='{str(id)}';")
|
||||||
print("header deleted",resh.rowcount)
|
print("header deleted",resh.rowcount)
|
||||||
|
|||||||
@ -440,6 +440,17 @@ def _delete_archived_runners_byIDs(runner_ids: list[UUID]):
|
|||||||
elif res < 0:
|
elif res < 0:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"Error: {res}:{id}")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"Error: {res}:{id}")
|
||||||
|
|
||||||
|
#delete archive runner from header and detail
|
||||||
|
@app.delete("/archived_runners/batch/{batch_id}", dependencies=[Depends(api_key_auth)], status_code=status.HTTP_200_OK)
|
||||||
|
def _delete_archived_runners_byBatchID(batch_id: str):
|
||||||
|
res, id = cs.delete_archived_runners_byBatchID(batch_id=batch_id)
|
||||||
|
if res == 0: return id
|
||||||
|
elif res == -1:
|
||||||
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"Error: {res}:{id}")
|
||||||
|
else:
|
||||||
|
raise HTTPException(status_code=status.HTTP_406_NOT_ACCEPTABLE, detail=f"Error not changed: {res}:{batch_id}:{id}")
|
||||||
|
|
||||||
|
|
||||||
#WIP - TOM indicator preview from frontend
|
#WIP - TOM indicator preview from frontend
|
||||||
#return indicator value for archived runner
|
#return indicator value for archived runner
|
||||||
@app.put("/archived_runners/{runner_id}/previewindicator", dependencies=[Depends(api_key_auth)], status_code=status.HTTP_200_OK)
|
@app.put("/archived_runners/{runner_id}/previewindicator", dependencies=[Depends(api_key_auth)], status_code=status.HTTP_200_OK)
|
||||||
|
|||||||
@ -302,6 +302,7 @@
|
|||||||
<div id="controls">
|
<div id="controls">
|
||||||
<button id="button_edit_arch" class="btn btn-outline-success btn-sm">Edit(a)</button>
|
<button id="button_edit_arch" class="btn btn-outline-success btn-sm">Edit(a)</button>
|
||||||
<button id="button_delete_arch" class="btn btn-outline-success btn-sm">Delete(d)</button>
|
<button id="button_delete_arch" class="btn btn-outline-success btn-sm">Delete(d)</button>
|
||||||
|
<button id="button_delete_batch" class="btn btn-outline-success btn-sm">Delete Batch(b)</button>
|
||||||
<button id="button_show_arch" class="btn btn-outline-success btn-sm">Show(w)</button>
|
<button id="button_show_arch" class="btn btn-outline-success btn-sm">Show(w)</button>
|
||||||
<button id="button_refresh" class="refresh btn btn-outline-success btn-sm">Refresh</button>
|
<button id="button_refresh" class="refresh btn btn-outline-success btn-sm">Refresh</button>
|
||||||
<button id="button_compare_arch" class="refresh btn btn-outline-success btn-sm">Compare</button>
|
<button id="button_compare_arch" class="refresh btn btn-outline-success btn-sm">Compare</button>
|
||||||
@ -366,6 +367,28 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="delModalBatch" class="modal fade">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<form method="post" id="delFormBatch">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title"><i class="fa fa-plus"></i> Delete Batch</h4>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="batch_id_del" class="form-label">Batch ID</label>
|
||||||
|
<input type="text" class="form-control" id="batch_id_del" name="delidarchive" placeholder="batch id" readonly>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<input type="submit" name="delete" id="deletebatch" class="btn btn-primary" value="Delete" />
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div id="logModal" class="modal fade" style="--bs-modal-width: 825px;">
|
<div id="logModal" class="modal fade" style="--bs-modal-width: 825px;">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
|||||||
@ -210,6 +210,7 @@ $(document).ready(function () {
|
|||||||
$('#button_runagain_arch').attr('disabled','disabled');
|
$('#button_runagain_arch').attr('disabled','disabled');
|
||||||
$('#button_show_arch').attr('disabled','disabled');
|
$('#button_show_arch').attr('disabled','disabled');
|
||||||
$('#button_delete_arch').attr('disabled','disabled');
|
$('#button_delete_arch').attr('disabled','disabled');
|
||||||
|
$('#button_delete_batch').attr('disabled','disabled');
|
||||||
$('#button_analyze').attr('disabled','disabled');
|
$('#button_analyze').attr('disabled','disabled');
|
||||||
$('#button_edit_arch').attr('disabled','disabled');
|
$('#button_edit_arch').attr('disabled','disabled');
|
||||||
$('#button_compare_arch').attr('disabled','disabled');
|
$('#button_compare_arch').attr('disabled','disabled');
|
||||||
@ -222,6 +223,7 @@ $(document).ready(function () {
|
|||||||
$('#button_analyze').attr('disabled','disabled');
|
$('#button_analyze').attr('disabled','disabled');
|
||||||
$('#button_runagain_arch').attr('disabled','disabled');
|
$('#button_runagain_arch').attr('disabled','disabled');
|
||||||
$('#button_delete_arch').attr('disabled','disabled');
|
$('#button_delete_arch').attr('disabled','disabled');
|
||||||
|
$('#button_delete_batch').attr('disabled','disabled');
|
||||||
$('#button_edit_arch').attr('disabled','disabled');
|
$('#button_edit_arch').attr('disabled','disabled');
|
||||||
$('#button_compare_arch').attr('disabled','disabled');
|
$('#button_compare_arch').attr('disabled','disabled');
|
||||||
} else {
|
} else {
|
||||||
@ -231,6 +233,7 @@ $(document).ready(function () {
|
|||||||
$('#button_show_arch').attr('disabled',false);
|
$('#button_show_arch').attr('disabled',false);
|
||||||
$('#button_runagain_arch').attr('disabled',false);
|
$('#button_runagain_arch').attr('disabled',false);
|
||||||
$('#button_delete_arch').attr('disabled',false);
|
$('#button_delete_arch').attr('disabled',false);
|
||||||
|
$('#button_delete_batch').attr('disabled',false);
|
||||||
$('#button_edit_arch').attr('disabled',false);
|
$('#button_edit_arch').attr('disabled',false);
|
||||||
$('#button_compare_arch').attr('disabled',false);
|
$('#button_compare_arch').attr('disabled',false);
|
||||||
}
|
}
|
||||||
@ -532,7 +535,56 @@ $(document).ready(function () {
|
|||||||
refresh_logfile()
|
refresh_logfile()
|
||||||
});
|
});
|
||||||
|
|
||||||
//delete button
|
//delete batch button
|
||||||
|
$('#button_delete_batch').click(function () {
|
||||||
|
row = archiveRecords.row('.selected').data();
|
||||||
|
if (row == undefined || row.batch_id == undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$('#batch_id_del').val(row.batch_id);
|
||||||
|
|
||||||
|
rows = archiveRecords.rows('.selected');
|
||||||
|
if (rows == undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$('#listofids').html("");
|
||||||
|
window.$('#delModalBatch').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
//delete batch modal
|
||||||
|
$("#delModalBatch").on('submit','#delFormBatch', function(event){
|
||||||
|
event.preventDefault();
|
||||||
|
row = archiveRecords.row('.selected').data();
|
||||||
|
if (row == undefined || row.batch_id == undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url:"/archived_runners/batch/"+row.batch_id,
|
||||||
|
beforeSend: function (xhr) {
|
||||||
|
xhr.setRequestHeader('X-API-Key',
|
||||||
|
API_KEY); },
|
||||||
|
method:"DELETE",
|
||||||
|
contentType: "application/json",
|
||||||
|
dataType: "json",
|
||||||
|
data: JSON.stringify(row.batch_id),
|
||||||
|
success:function(data){
|
||||||
|
$('#delFormBatch')[0].reset();
|
||||||
|
window.$('#delModalBatch').modal('hide');
|
||||||
|
$('#button_delete_batch').attr('disabled', false);
|
||||||
|
//console.log(data)
|
||||||
|
archiveRecords.ajax.reload();
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
var err = eval("(" + xhr.responseText + ")");
|
||||||
|
window.alert(JSON.stringify(xhr));
|
||||||
|
console.log(JSON.stringify(xhr));
|
||||||
|
$('#button_delete_batch').attr('disabled', false);
|
||||||
|
archiveRecords.ajax.reload();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
//delete arch button
|
||||||
$('#button_delete_arch').click(function () {
|
$('#button_delete_arch').click(function () {
|
||||||
rows = archiveRecords.rows('.selected');
|
rows = archiveRecords.rows('.selected');
|
||||||
if (rows == undefined) {
|
if (rows == undefined) {
|
||||||
|
|||||||
@ -902,6 +902,9 @@ Mousetrap.bind('e', function() {
|
|||||||
Mousetrap.bind('d', function() {
|
Mousetrap.bind('d', function() {
|
||||||
$( "#button_delete_arch" ).trigger( "click" );
|
$( "#button_delete_arch" ).trigger( "click" );
|
||||||
});
|
});
|
||||||
|
Mousetrap.bind('b', function() {
|
||||||
|
$( "#button_delete_batch" ).trigger( "click" );
|
||||||
|
});
|
||||||
Mousetrap.bind('c', function() {
|
Mousetrap.bind('c', function() {
|
||||||
$( "#button_copy" ).trigger( "click" );
|
$( "#button_copy" ).trigger( "click" );
|
||||||
});
|
});
|
||||||
|
|||||||
@ -509,6 +509,17 @@ class Strategy:
|
|||||||
# self.order_notifs.stop()
|
# self.order_notifs.stop()
|
||||||
# self.dataloader.stop()
|
# self.dataloader.stop()
|
||||||
|
|
||||||
|
def release(self):
|
||||||
|
#release large variables
|
||||||
|
self.bt = None
|
||||||
|
self.btdata= None
|
||||||
|
self.dataloader = None
|
||||||
|
self.state = None
|
||||||
|
self.rtqueue = None
|
||||||
|
self._streams = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#for order updates from LIVE or BACKTEST
|
#for order updates from LIVE or BACKTEST
|
||||||
#updates are sent only for SYMBOL of strategy
|
#updates are sent only for SYMBOL of strategy
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user