Run Mode also from the UI
This commit is contained in:
1 parent
d4c840cfcf
commit
9f129b6ba6
5 files changed
+82
-37
No files matched your search
+15
-15
@@ -55,7 +55,7 @@
|
||||
exchangeAPI = pExchangeAPI;
|
||||
thisObject.dataDependencies = pDataDependencies;
|
||||
|
||||
switch (bot.runMode) {
|
||||
switch (bot.startMode) {
|
||||
|
||||
case 'Live': {
|
||||
getMarketRateFromExchange();
|
||||
@@ -73,8 +73,8 @@
|
||||
}
|
||||
|
||||
default: {
|
||||
logger.write("[ERROR] initialize -> Unexpected bot.runMode.");
|
||||
logger.write("[ERROR] initialize -> bot.runMode = " + bot.runMode);
|
||||
logger.write("[ERROR] initialize -> Unexpected bot.startMode.");
|
||||
logger.write("[ERROR] initialize -> bot.startMode = " + bot.startMode);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
@@ -330,7 +330,7 @@
|
||||
|
||||
*/
|
||||
|
||||
switch (bot.runMode) {
|
||||
switch (bot.startMode) {
|
||||
|
||||
case "Live": {
|
||||
|
||||
@@ -355,8 +355,8 @@
|
||||
}
|
||||
|
||||
default: {
|
||||
logger.write("[ERROR] getPositionsAtExchange -> Unexpected bot.runMode.");
|
||||
logger.write("[ERROR] getPositionsAtExchange -> bot.runMode = " + bot.runMode);
|
||||
logger.write("[ERROR] getPositionsAtExchange -> Unexpected bot.startMode.");
|
||||
logger.write("[ERROR] getPositionsAtExchange -> bot.startMode = " + bot.startMode);
|
||||
callBack(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
@@ -511,7 +511,7 @@
|
||||
|
||||
*/
|
||||
|
||||
switch (bot.runMode) {
|
||||
switch (bot.startMode) {
|
||||
|
||||
case "Live": {
|
||||
|
||||
@@ -571,8 +571,8 @@
|
||||
}
|
||||
|
||||
default: {
|
||||
logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> Unexpected bot.runMode.");
|
||||
logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> bot.runMode = " + bot.runMode);
|
||||
logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> Unexpected bot.startMode.");
|
||||
logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> bot.startMode = " + bot.startMode);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
@@ -947,7 +947,7 @@
|
||||
|
||||
/* All validations passed, we proceed. */
|
||||
|
||||
switch (bot.runMode) {
|
||||
switch (bot.startMode) {
|
||||
|
||||
case "Live": {
|
||||
|
||||
@@ -976,8 +976,8 @@
|
||||
}
|
||||
|
||||
default: {
|
||||
logger.write("[ERROR] putPosition -> Unexpected bot.runMode.");
|
||||
logger.write("[ERROR] putPosition -> bot.runMode = " + bot.runMode);
|
||||
logger.write("[ERROR] putPosition -> Unexpected bot.startMode.");
|
||||
logger.write("[ERROR] putPosition -> bot.startMode = " + bot.startMode);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
@@ -1068,7 +1068,7 @@
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] movePosition -> pPosition = " + JSON.stringify(pPosition)); }
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] movePosition -> pNewRate = " + pNewRate); }
|
||||
|
||||
switch (bot.runMode) {
|
||||
switch (bot.startMode) {
|
||||
|
||||
case "Live": {
|
||||
|
||||
@@ -1091,8 +1091,8 @@
|
||||
}
|
||||
|
||||
default: {
|
||||
logger.write("[ERROR] movePosition -> Unexpected bot.runMode.");
|
||||
logger.write("[ERROR] movePosition -> bot.runMode = " + bot.runMode);
|
||||
logger.write("[ERROR] movePosition -> Unexpected bot.startMode.");
|
||||
logger.write("[ERROR] movePosition -> bot.startMode = " + bot.startMode);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
|
||||
+15
-15
@@ -86,7 +86,7 @@
|
||||
|
||||
let statusDependencies;
|
||||
|
||||
let runIndex; // This is the index for this run and depends on the runMode.
|
||||
let runIndex; // This is the index for this run and depends on the startMode.
|
||||
|
||||
return thisObject;
|
||||
|
||||
@@ -176,7 +176,7 @@
|
||||
|
||||
} else {
|
||||
|
||||
switch (bot.runMode) {
|
||||
switch (bot.startMode) {
|
||||
|
||||
case "Live": {
|
||||
|
||||
@@ -197,8 +197,8 @@
|
||||
}
|
||||
|
||||
default: {
|
||||
logger.write("[ERROR] initialize -> createConext -> Unexpected bot.runMode.");
|
||||
logger.write("[ERROR] initialize -> createConext -> bot.runMode = " + bot.runMode);
|
||||
logger.write("[ERROR] initialize -> createConext -> Unexpected bot.startMode.");
|
||||
logger.write("[ERROR] initialize -> createConext -> bot.startMode = " + bot.startMode);
|
||||
callBack(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
@@ -220,7 +220,7 @@
|
||||
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getExecutionHistory -> Entering function."); }
|
||||
|
||||
let fileName = "Execution.History." + bot.runMode + "." + runIndex + ".json";
|
||||
let fileName = "Execution.History." + bot.startMode + "." + runIndex + ".json";
|
||||
let filePath = bot.filePathRoot + "/Output/" + bot.process;
|
||||
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getExecutionHistory -> fileName = " + fileName); }
|
||||
@@ -280,7 +280,7 @@
|
||||
|
||||
let date;
|
||||
|
||||
switch (bot.runMode) {
|
||||
switch (bot.startMode) {
|
||||
|
||||
case "Live": {
|
||||
date = new Date(thisObject.statusReport.liveRuns[runIndex].lastExecution);
|
||||
@@ -302,14 +302,14 @@
|
||||
}
|
||||
|
||||
default: {
|
||||
logger.write("[ERROR] initialize -> getExecutionContext -> Unexpected bot.runMode.");
|
||||
logger.write("[ERROR] initialize -> getExecutionContext -> bot.runMode = " + bot.runMode);
|
||||
logger.write("[ERROR] initialize -> getExecutionContext -> Unexpected bot.startMode.");
|
||||
logger.write("[ERROR] initialize -> getExecutionContext -> bot.startMode = " + bot.startMode);
|
||||
callBack(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let fileName = "Execution.Context." + bot.runMode + "." + runIndex + ".json";
|
||||
let fileName = "Execution.Context." + bot.startMode + "." + runIndex + ".json";
|
||||
let dateForPath = date.getUTCFullYear() + '/' + utilities.pad(date.getUTCMonth() + 1, 2) + '/' + utilities.pad(date.getUTCDate(), 2) + '/' + utilities.pad(date.getUTCHours(), 2) + '/' + utilities.pad(date.getUTCMinutes(), 2);
|
||||
let filePath = bot.filePathRoot + "/Output/" + bot.process + '/' + dateForPath;
|
||||
|
||||
@@ -388,7 +388,7 @@
|
||||
};
|
||||
}
|
||||
|
||||
switch (bot.runMode) {
|
||||
switch (bot.startMode) {
|
||||
|
||||
case "Live": {
|
||||
|
||||
@@ -430,8 +430,8 @@
|
||||
}
|
||||
|
||||
default: {
|
||||
logger.write("[ERROR] initialize -> createConext -> Unexpected bot.runMode.");
|
||||
logger.write("[ERROR] initialize -> createConext -> bot.runMode = " + bot.runMode);
|
||||
logger.write("[ERROR] initialize -> createConext -> Unexpected bot.startMode.");
|
||||
logger.write("[ERROR] initialize -> createConext -> bot.startMode = " + bot.startMode);
|
||||
callBack(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
@@ -528,7 +528,7 @@
|
||||
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> Entering function."); }
|
||||
|
||||
let fileName = "Execution.Context." + bot.runMode + "." + runIndex +".json";
|
||||
let fileName = "Execution.Context." + bot.startMode + "." + runIndex +".json";
|
||||
let dateForPath = bot.processDatetime.getUTCFullYear() + '/' + utilities.pad(bot.processDatetime.getUTCMonth() + 1, 2) + '/' + utilities.pad(bot.processDatetime.getUTCDate(), 2) + '/' + utilities.pad(bot.processDatetime.getUTCHours(), 2) + '/' + utilities.pad(bot.processDatetime.getUTCMinutes(), 2);
|
||||
let filePath = bot.filePathRoot + "/Output/" + bot.process + '/' + dateForPath;
|
||||
|
||||
@@ -589,7 +589,7 @@
|
||||
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> Entering function."); }
|
||||
|
||||
let fileName = "Execution.History." + bot.runMode + "." + runIndex + ".json";
|
||||
let fileName = "Execution.History." + bot.startMode + "." + runIndex + ".json";
|
||||
let filePath = bot.filePathRoot + "/Output/" + bot.process;
|
||||
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> fileName = " + fileName); }
|
||||
@@ -656,7 +656,7 @@
|
||||
/* Here we will write the file containing the max sequence number. */
|
||||
|
||||
fileContent = runIndex;
|
||||
fileName = "Execution.History." + bot.runMode + "." + "Sequence" + ".json";
|
||||
fileName = "Execution.History." + bot.startMode + "." + "Sequence" + ".json";
|
||||
filePath = bot.filePathRoot + "/Output/" + bot.process;
|
||||
|
||||
cloudStorage.createTextFile(filePath, fileName, fileContent + '\n', onSequenceFileCreated);
|
||||
|
||||
@@ -343,6 +343,50 @@ exports.newRoot = function newRoot() {
|
||||
|
||||
try {
|
||||
|
||||
/*
|
||||
|
||||
When running at the browser, the endUser can override the configured setting for the bot. In this scenario we use the commands
|
||||
sent from the User Interface.
|
||||
|
||||
*/
|
||||
|
||||
if (UI_COMMANDS.startMode !== undefined) {
|
||||
|
||||
switch (UI_COMMANDS.startMode) {
|
||||
|
||||
case "Backtest": {
|
||||
|
||||
processConfig.startMode.backtest.run = "true";
|
||||
processConfig.startMode.live.run = "false";
|
||||
processConfig.startMode.competition.run = "false";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case "Live": {
|
||||
|
||||
processConfig.startMode.backtest.run = "false";
|
||||
processConfig.startMode.live.run = "true";
|
||||
processConfig.startMode.competition.run = "false";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case "Competition": {
|
||||
|
||||
processConfig.startMode.backtest.run = "false";
|
||||
processConfig.startMode.live.run = "false";
|
||||
processConfig.startMode.competition.run = "true";
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> Process found at the bot configuration file. -> Start Mode Overwritten. "); }
|
||||
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> Process found at the bot configuration file. -> processConfig.startMode = " + processConfig.startMode); }
|
||||
|
||||
}
|
||||
|
||||
/* We tesst each type of start Mode to get what to run and how. */
|
||||
|
||||
if (processConfig.startMode.allMonths !== undefined) {
|
||||
@@ -482,7 +526,7 @@ exports.newRoot = function newRoot() {
|
||||
|
||||
if (processConfig.startMode.live.run === "true") {
|
||||
|
||||
botConfig.runMode = "Live";
|
||||
botConfig.startMode = "Live";
|
||||
|
||||
let month = pad((new Date()).getUTCMonth() + 1, 2);
|
||||
let year = (new Date()).getUTCFullYear();
|
||||
@@ -509,7 +553,7 @@ exports.newRoot = function newRoot() {
|
||||
|
||||
if (processConfig.startMode.backtest.run === "true") {
|
||||
|
||||
botConfig.runMode = "Backtest";
|
||||
botConfig.startMode = "Backtest";
|
||||
botConfig.backtest = processConfig.startMode.backtest;
|
||||
|
||||
/* We override these waitTimes to the one specified at the backtest configuration. */
|
||||
@@ -537,7 +581,7 @@ exports.newRoot = function newRoot() {
|
||||
|
||||
if (processConfig.startMode.competition.run === "true") {
|
||||
|
||||
botConfig.runMode = "Competition";
|
||||
botConfig.startMode = "Competition";
|
||||
botConfig.competition = processConfig.startMode.competition;
|
||||
|
||||
if (processConfig.startMode.competition.resumeExecution === "true") {
|
||||
|
||||
@@ -83,6 +83,7 @@ function startRoot() {
|
||||
beginDatetime: undefined,
|
||||
endDatetime: undefined,
|
||||
timePeriod: undefined,
|
||||
startMode: undefined,
|
||||
eventHandler: undefined
|
||||
};
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
|
||||
/* We define the datetime for the process that we are running now. This will be the official processing time for both the infraestructure and the bot. */
|
||||
|
||||
switch (bot.runMode) {
|
||||
switch (bot.startMode) {
|
||||
case 'Live': {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] run -> loop -> Live Mode detected."); }
|
||||
@@ -198,7 +198,7 @@
|
||||
|
||||
if (UI_COMMANDS.eventHandler !== undefined) {
|
||||
|
||||
UI_COMMANDS.eventHandler.raiseEvent('Datetime Changed', bot.processDatetime);
|
||||
UI_COMMANDS.eventHandler.raiseEvent('Bot Execution Changed Datetime', bot.processDatetime);
|
||||
|
||||
}
|
||||
|
||||
@@ -265,8 +265,8 @@
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
logger.write("[ERROR] run -> loop -> Unexpected bot.runMode.");
|
||||
logger.write("[ERROR] run -> loop -> bot.runMode = " + bot.runMode);
|
||||
logger.write("[ERROR] run -> loop -> Unexpected bot.startMode.");
|
||||
logger.write("[ERROR] run -> loop -> bot.startMode = " + bot.startMode);
|
||||
bot.eventHandler.raiseEvent("Loop Finished");
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user