diff --git a/v2realbot/ENTRY_ClassicSL_v01.py b/v2realbot/ENTRY_ClassicSL_v01.py
index 4ce1728..53361dc 100644
--- a/v2realbot/ENTRY_ClassicSL_v01.py
+++ b/v2realbot/ENTRY_ClassicSL_v01.py
@@ -1244,7 +1244,11 @@ def next(data, state: StrategyState):
#POKUD je nastaven MIN PROFIT, zkontrolujeme ho a az pripadne pustime CONDITIONY
directive_name = "exit_cond_min_profit"
- exit_cond_min_profit = get_override_for_active_trade(directive_name=directive_name, default_value=safe_get(state.vars, directive_name, None))
+ exit_cond_min_profit_nodir = get_override_for_active_trade(directive_name=directive_name, default_value=safe_get(state.vars, directive_name, None))
+
+ directive_name = "exit_cond_min_profit_" + str(smer)
+ exit_cond_min_profit = get_override_for_active_trade(directive_name=directive_name, default_value=exit_cond_min_profit_nodir)
+
#máme nastavený exit_cond_min_profit
# zjistíme, zda jsme v daném profit a případně nepustíme dál
diff --git a/v2realbot/controller/services.py b/v2realbot/controller/services.py
index c0c9058..af0e68d 100644
--- a/v2realbot/controller/services.py
+++ b/v2realbot/controller/services.py
@@ -823,8 +823,8 @@ def delete_archived_runners_byID(id: UUID):
print("log deleted",resl.rowcount)
conn.commit()
print("commit")
- if resh.rowcount == 0 or resd.rowcount == 0:
- return -1, "not found "+str(resh.rowcount) + " " + str(resd.rowcount) + " " + str(resl.rowcount)
+ # if resh.rowcount == 0 or resd.rowcount == 0:
+ # return -1, "not found "+str(resh.rowcount) + " " + str(resd.rowcount) + " " + str(resl.rowcount)
return 0, str(resh.rowcount) + " " + str(resd.rowcount) + " " + str(resl.rowcount)
except Exception as e:
diff --git a/v2realbot/static/index.html b/v2realbot/static/index.html
index 3515627..c7b1fa7 100644
--- a/v2realbot/static/index.html
+++ b/v2realbot/static/index.html
@@ -17,12 +17,12 @@
+
+
-
-
@@ -45,7 +45,25 @@
-
+
+
+
+
+
+
@@ -176,12 +194,12 @@
+
@@ -411,6 +430,33 @@
+
-
diff --git a/v2realbot/static/js/archivetables.js b/v2realbot/static/js/archivetables.js
index c381746..274942d 100644
--- a/v2realbot/static/js/archivetables.js
+++ b/v2realbot/static/js/archivetables.js
@@ -119,6 +119,9 @@ $(document).ready(function () {
//delete button
$('#button_delete_arch').click(function () {
rows = archiveRecords.rows('.selected');
+ if (rows == undefined) {
+ return
+ }
$('#listofids').html("");
if(rows.data().length > 0 ) {
@@ -138,6 +141,9 @@ $(document).ready(function () {
//edit button
$('#button_edit_arch').click(function () {
row = archiveRecords.row('.selected').data();
+ if (rows == undefined) {
+ return
+ }
window.$('#editModalArchive').modal('show');
$('#editidarchive').val(row.id);
$('#editnote').val(row.note);
diff --git a/v2realbot/static/js/jquery.serializejson.js b/v2realbot/static/js/jquery.serializejson.js
index ed699eb..877ab63 100644
--- a/v2realbot/static/js/jquery.serializejson.js
+++ b/v2realbot/static/js/jquery.serializejson.js
@@ -7,18 +7,7 @@
Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*/
-(function (factory) {
- /* global define, require, module */
- if (typeof define === "function" && define.amd) { // AMD. Register as an anonymous module.
- define(["jquery"], factory);
- } else if (typeof exports === "object") { // Node/CommonJS
- var jQuery = require("jquery");
- module.exports = factory(jQuery);
- } else { // Browser globals (zepto supported)
- factory(window.jQuery || window.Zepto || window.$); // Zepto supported on browsers as well
- }
-
-}(function ($) {
+(function ($) {
"use strict";
var rCRLF = /\r?\n/g;
@@ -335,4 +324,4 @@
var isUndefined = function(obj) { return obj === void 0; }; // safe check for undefined values
var isValidArrayIndex = function(val) { return /^[0-9]+$/.test(String(val)); }; // 1,2,3,4 ... are valid array indexes
var isArray = Array.isArray || function(obj) { return Object.prototype.toString.call(obj) === "[object Array]"; };
-}));
+})(jQuery);
\ No newline at end of file
diff --git a/v2realbot/static/js/mytables.js b/v2realbot/static/js/mytables.js
index d67f098..c8a5a74 100644
--- a/v2realbot/static/js/mytables.js
+++ b/v2realbot/static/js/mytables.js
@@ -38,9 +38,65 @@ function is_stratin_running(id) {
return running
}
+let editor;
//STRATIN and RUNNERS TABELS
$(document).ready(function () {
+
+ //incialize TOML LANGUAGE IN MONACO
+ require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.43.0/min/vs' }});
+
+ require(["vs/editor/editor.main"], () => {
+
+ // Register the TOML language
+ monaco.languages.register({ id: 'toml' });
+
+ // Define the TOML language configuration
+ monaco.languages.setLanguageConfiguration('toml', {
+ comments: {
+ lineComment: '#',
+ },
+ brackets: [['[', ']']], // Define brackets used in TOML arrays
+ autoClosingPairs: [
+ // Define auto-closing pairs for quotes
+ { open: '"', close: '"', notIn: ['string', 'comment'] },
+ { open: "'", close: "'", notIn: ['string', 'comment'] },
+ ],
+ });
+
+ // Define the TOML tokenizer
+ monaco.languages.setMonarchTokensProvider('toml', {
+ tokenizer: {
+ root: [
+ [/#.*/, 'comment'], // Comments
+ [/".*"/, 'string'], // Double-quoted strings
+ [/'[^']*'/, 'string'], // Single-quoted strings
+ [/-?\d+\.\d+/, 'number'], // Floating-point numbers (including negative)
+ [/-?\d+/, 'number'], // Integer numbers (including negative)
+ [/\btrue\b/, 'boolean-true'], // True values
+ [/\bfalse\b/, 'boolean-false'], // False values
+ [/=\s*/, 'delimiter'], // Key-Value separator
+ [/\[.*\]/, 'array'], // Array brackets
+ [/\.\s*(and|or)\s*\./, 'logical-operator'],
+ [/[^#=\[\]]+/, 'keyword'], // Keywords (anything not covered above)
+ [/[ \t\r\n]+/, 'white'], // Whitespace
+ ],
+ },
+ });
+
+ // Define the theme for highlighting true and false values
+ monaco.editor.defineTheme('tomlTheme-dark', {
+ colors: {},
+ base: 'vs-dark', // Use the VS Code Dark Theme as a base
+ inherit: true,
+ rules: [
+ { token: 'boolean-true', foreground: '009485', fontStyle:"" }, // Use the same color as VS Code for true
+ { token: 'boolean-false', foreground: 'e45649', fontStyle:"" }, // Use the same color as VS Code for false
+ ],
+ });
+
+ });
+
stratinRecords.ajax.reload();
runnerRecords.ajax.reload();
@@ -56,6 +112,7 @@ $(document).ready(function () {
$('#button_stop').attr('disabled','disabled');
$('#button_connect').attr('disabled','disabled');
$('#button_edit').attr('disabled','disabled');
+ $('#button_edit_stratvars').attr('disabled','disabled');
$('#button_dup').attr('disabled','disabled');
$('#button_copy').attr('disabled','disabled');
$('#button_delete').attr('disabled','disabled');
@@ -68,6 +125,7 @@ $(document).ready(function () {
$('#button_dup').attr('disabled','disabled');
$('#button_copy').attr('disabled','disabled');
$('#button_edit').attr('disabled','disabled');
+ $('#button_edit_stratvars').attr('disabled','disabled');
$('#button_delete').attr('disabled','disabled');
$('#button_run').attr('disabled','disabled');
} else {
@@ -76,6 +134,7 @@ $(document).ready(function () {
$('#button_dup').attr('disabled',false);
$('#button_copy').attr('disabled',false);
$('#button_edit').attr('disabled',false);
+ $('#button_edit_stratvars').attr('disabled',false);
$('#button_delete').attr('disabled',false);
$('#button_run').attr('disabled',false);
}
@@ -446,6 +505,9 @@ $(document).ready(function () {
//edit button
$('#button_edit').click(function () {
row = stratinRecords.row('.selected').data();
+ if (row== undefined) {
+ return
+ }
window.$('#recordModal').modal('show');
$('#id').val(row.id);
$('#id2').val(row.id2);
@@ -462,22 +524,6 @@ $(document).ready(function () {
$('.modal-title').html(" Edit Records");
$('#action').val('updateRecord');
$('#save').val('Save');
- //code for toml editor
- // Initialize Monaco Editor
-
- // require.config({ paths: { vs: 'monaco-editor/min/vs' } });
- // require(['vs/editor/editor.main'], function () {
- // var editor = $("#editor").monacoEditor({
- // language: "toml",
- // value: row.stratvars_conf
- // });
- // // Get content from Monaco Editor and set it to the textarea using jQuery
- // editor.getModels()[0].onDidChangeContent(function() {
- // var tomlContent = monaco.editor.getModels()[0].getValue();
- // $('#stratvars_conf').val(tomlContent);
- // });
- // });
-
});
//delete button
@@ -493,9 +539,28 @@ $(document).ready(function () {
$('#button_add_json').click(function () {
window.$('#jsonModal').modal('show');
});
+
+ $('#button_edit_stratvars').click(function () {
+ row = stratinRecords.row('.selected').data();
+ if (row== undefined) {
+ return
+ }
+ $('#stratvar_id').val(row.id);
+ require(["vs/editor/editor.main"], () => {
+ editor = monaco.editor.create(document.getElementById('stratvars_editor'), {
+ value: row.stratvars_conf,
+ language: 'toml',
+ theme: 'tomlTheme-dark',
+ automaticLayout: true
+ });
+ });
+ window.$('#stratvarsModal').modal('show');
+ //$('#stratvars_editor_val').val(row.stratvars_conf);
+ });
} );
+
//stratin table
var stratinRecords =
$('#stratinTable').DataTable( {
@@ -696,6 +761,81 @@ $("#runModal").on('submit','#runForm', function(event){
})
});
+$('#stratvars_close').click(function () {
+ console.log("disposed?")
+ editor.dispose();
+ window.$('#stratvarsModal').modal('hide');
+});
+
+$('#stratvars_close_x').click(function () {
+ editor.dispose();
+ window.$('#stratvarsModal').modal('hide');
+});
+
+//EDIT STRATVARS MONACO
+$('#stratvars_save').click(function () {
+ save_stratvars(exit=false);
+});
+
+$('#stratvars_save_exit').click(function () {
+ save_stratvars(exit=true)
+});
+
+function save_stratvars(exit) {
+ row = stratinRecords.row('.selected').data();
+ const rec = new Object()
+ rec.id = $('#stratvar_id').val()
+ if (row.id ==! rec.id) {
+ window.alert("Overwrite check,. Pozor neco spatne, IDcka se nerovnaji")
+ return
+ }
+ rec.id2 = row.id2
+ rec.name =row.name
+ rec.symbol =row.symbol
+ rec.class_name =row.class_name
+ rec.script =row.script
+ rec.open_rush =row.open_rush
+ rec.close_rush = row.close_rush
+ rec.add_data_conf = row.add_data_conf
+ rec.stratvars_conf = editor.getValue()
+ rec.note = row.note
+ rec.history = row.history
+
+ jsonString = JSON.stringify(rec, null, 2);
+ console.log("pred odeslanim editu", jsonString)
+ $('#stratvars_save').attr('disabled','disabled');
+ $('#stratvars_save_exit').attr('disabled','disabled');
+
+ $.ajax({
+ url:"/stratins/"+rec.id,
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader('X-API-Key',
+ API_KEY); },
+ method:"PATCH",
+ contentType: "application/json",
+ dataType: "json",
+ data: jsonString,
+ success:function(data){
+ $('#stratvars_save').attr('disabled',false);
+ $('#stratvars_save_exit').attr('disabled',false);
+ if (exit) {
+ window.$('#stratvarsModal').modal('hide');
+ editor.dispose();
+ $('#stratvar_id').val("");
+ stratinRecords.ajax.reload();
+ }
+ },
+ error: function(xhr, status, error) {
+ var err = eval("(" + xhr.responseText + ")");
+ window.alert(JSON.stringify(xhr));
+ console.log(JSON.stringify(xhr));
+ $('#stratvars_save').attr('disabled',false);
+ $('#stratvars_save_exit').attr('disabled',false);
+ }
+
+ })
+};
+
//modal na add/edit
$("#recordModal").on('submit','#recordForm', function(event){
diff --git a/v2realbot/static/js/utils.js b/v2realbot/static/js/utils.js
index baac0e2..5eb1d78 100644
--- a/v2realbot/static/js/utils.js
+++ b/v2realbot/static/js/utils.js
@@ -488,23 +488,26 @@ function set_timestamp(timestamp) {
Mousetrap.bind('e', function() {
$( "#button_edit" ).trigger( "click" );
});
-Mousetrap.bind('a', function() {
- $( "#button_add" ).trigger( "click" );
-});
+// Mousetrap.bind('a', function() {
+// $( "#button_add" ).trigger( "click" );
+// });
Mousetrap.bind('d', function() {
- $( "#button_dup" ).trigger( "click" );
+ $( "#button_delete_arch" ).trigger( "click" );
});
Mousetrap.bind('c', function() {
$( "#button_copy" ).trigger( "click" );
});
Mousetrap.bind('r', function() {
- $( "#button_run" ).trigger( "click" );
+ $( "#button_runagain_arch" ).trigger( "click" );
});
Mousetrap.bind('p', function() {
$( "#button_pause" ).trigger( "click" );
});
Mousetrap.bind('s', function() {
- $( "#button_stop" ).trigger( "click" );
+ $( "#button_edit_stratvars" ).trigger( "click" );
+});
+Mousetrap.bind('a', function() {
+ $( "#button_edit_arch" ).trigger( "click" );
});
Mousetrap.bind('j', function() {
$( "#button_add_json" ).trigger( "click" );