Support to EXECUTION AT, reading bots from members or devTeams

This commit is contained in:
Luis Fernando Molina committed 2018-05-30 11:26:01 +02:00
1 parent b69a638fee
commit 031add278f
11 files changed
+131 -55

No files matched your search

+18 -9
View File
@@ -57,11 +57,20 @@
switch (bot.runMode) {
case 'Live': { getMarketRateFromExchange();}
case 'Live': {
getMarketRateFromExchange();
break;
}
case 'Backtest': { getMarketRateFromIndicator();}
case 'Backtest': {
getMarketRateFromIndicator();
break;
}
case 'Competition': { getMarketRateFromExchange(); }
case 'Competition': {
getMarketRateFromExchange();
break;
}
default: {
logger.write("[ERROR] initialize -> Unexpected bot.runMode.");
@@ -221,7 +230,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] initialize -> validateExchangeSyncronicity -> onDone -> Execution finished well. :-)");
logger.write("[INFO] initialize -> validateExchangeSyncronicity -> onDone -> Execution finished well.");
calculateProfits();
return;
}
@@ -360,7 +369,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: { // Everything went well, we have the information requested.
logger.write("[INFO] getPositionsAtExchange -> onResponse -> Execution finished well. :-)");
logger.write("[INFO] getPositionsAtExchange -> onResponse -> Execution finished well.");
exchangePositions = pExchangePositions;
ordersExecutionCheck(callBack);
return;
@@ -576,7 +585,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: { // Everything went well, we have the information requested.
logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> Execution finished well. :-)");
logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> Execution finished well.");
innerCallBack(pTrades);
}
break;
@@ -609,7 +618,7 @@
try {
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> Entering function."); }
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> pTrades = " + JSON.stringify(pTrades)); }
if (global.LOG_CONTROL[MODULE_NAME].logContent === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> pTrades = " + JSON.stringify(pTrades)); }
/*
@@ -982,7 +991,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: { // Everything went well, we have the information requested.
logger.write("[INFO] putPosition -> onResponse -> Execution finished well. :-)");
logger.write("[INFO] putPosition -> onResponse -> Execution finished well.");
let position = {
id: pPositionId,
@@ -1097,7 +1106,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: { // Everything went well, we have the information requested.
logger.write("[INFO] movePosition -> onResponse -> Execution finished well. :-)");
logger.write("[INFO] movePosition -> onResponse -> Execution finished well.");
let newPosition = {
id: pPositionId,
+8 -2
View File
@@ -247,7 +247,10 @@ exports.newBlobStorage = function newBlobStorage(BOT) {
message: "File does not exist."
};
logger.write("[ERROR] getTextFile -> onFileReceived -> Custom Response -> message = " + customErr.message);
logger.write("[WARN] getTextFile -> onFileReceived -> Custom Response -> message = " + customErr.message);
logger.write("[WARN] getTextFile -> containerName = " + containerName);
logger.write("[WARN] getTextFile -> pFolderPath = " + pFolderPath);
logger.write("[WARN] getTextFile -> pFileName = " + pFileName);
callBackFunction(customErr);
return;
@@ -263,7 +266,10 @@ exports.newBlobStorage = function newBlobStorage(BOT) {
message: "Folder does not exist."
};
logger.write("[ERROR] getTextFile -> onFileReceived -> Custom Response -> message = " + customErr.message);
logger.write("[WARN] getTextFile -> onFileReceived -> Custom Response -> message = " + customErr.message);
logger.write("[WARN] getTextFile -> containerName = " + containerName);
logger.write("[WARN] getTextFile -> pFolderPath = " + pFolderPath);
logger.write("[WARN] getTextFile -> pFileName = " + pFileName);
callBackFunction(customErr);
return;
+32 -2
View File
@@ -25,7 +25,22 @@
if (FULL_LOG === true) { logger.write("[INFO] downloadBot -> Entering function."); }
let filePath = global.USER_DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + bot.repo + "/" + pProcessConfig.name;
let filePath;
switch (global.CURRENT_EXECUTION_AT) {
case "Cloud": {
filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud.
break;
}
case "Browser": {
filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser.
break;
}
default: {
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser' ");
}
}
let fileName = "User.Bot.js";
pCloudStorage.getTextFile(filePath, fileName, onFileReceived);
@@ -65,7 +80,22 @@
if (FULL_LOG === true) { logger.write("[INFO] downloadCommons -> Entering function."); }
let filePath = bot.devTeam + "/" + bot.repo;
let filePath;
switch (global.CURRENT_EXECUTION_AT) {
case "Cloud": {
filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo; // DevTeams bots only are run at the cloud.
break;
}
case "Browser": {
filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + bot.repo; // DevTeam Members bots only are run at the browser.
break;
}
default: {
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser' ");
}
}
let fileName = "Commons.js";
pCloudStorage.getTextFile(filePath, fileName, onFileReceived);
+4 -4
View File
@@ -130,7 +130,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] initialize -> onDone -> Execution finished well. :-)");
logger.write("[INFO] initialize -> onDone -> Execution finished well.");
bot.hasTheBotJustStarted = false;
@@ -326,7 +326,7 @@
return;
}
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) {
if (global.LOG_CONTROL[MODULE_NAME].logContent === true) {
logger.write("[INFO] initialize -> getExecutionContext -> onFileReceived -> Content received = " + text);
}
@@ -497,7 +497,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] saveThemAll -> onDone -> Execution finished well. :-)");
logger.write("[INFO] saveThemAll -> onDone -> Execution finished well.");
callBackFunction(global.DEFAULT_OK_RESPONSE);
return;
}
@@ -563,7 +563,7 @@
return;
}
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) {
if (global.LOG_CONTROL[MODULE_NAME].logContent === true) {
logger.write("[INFO] saveThemAll -> writeExecutionContext -> onFolderCreated -> onFileCreated -> Content written = " + fileContent);
}
+2 -2
View File
@@ -176,11 +176,11 @@
function write(Message) {
console.log("AACloud" + spacePad(thisObject.fileName, 40) + " : " + Message);
console.log("AACloud" + spacePad(thisObject.fileName, 50) + " : " + Message);
if (thisObject.bot === undefined) { return;}
if (firstCall === true && global.CURRENT_LOCATION === "Cloud") { createFolders(); }
if (firstCall === true && global.CURRENT_EXECUTION_AT === "Cloud") { createFolders(); }
if (thisObject.bot.loopCounter !== loopCounter) {
+4 -4
View File
@@ -162,7 +162,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> initializeStatusDependencies -> onInizialized -> Execution finished well. :-)");
logger.write("[INFO] run -> loop -> initializeStatusDependencies -> onInizialized -> Execution finished well.");
initializeUserBot();
return;
}
@@ -224,7 +224,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> initializeUserBot -> onInizialized > Execution finished well. :-)");
logger.write("[INFO] run -> loop -> initializeUserBot -> onInizialized > Execution finished well.");
startUserBot();
return;
}
@@ -284,7 +284,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> startUserBot -> onFinished > Execution finished well. :-)");
logger.write("[INFO] run -> loop -> startUserBot -> onFinished > Execution finished well.");
nextWaitTime = 'Normal';
loopControl(nextWaitTime);
return;
@@ -401,7 +401,7 @@
if (bot.runAtFixedInterval === true) { intervalHandle.clearInterval();}
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Stopping the Loop Gracefully. See you next time! :-)"); }
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Stopping the Loop Gracefully. See you next time!"); }
bot.eventHandler.raiseEvent("Loop Finished");
clearInterval(intervalHandle);
callBackFunction(global.DEFAULT_OK_RESPONSE);
+4 -4
View File
@@ -152,7 +152,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> initializeStatusDependencies -> onInizialized -> Execution finished well. :-)");
logger.write("[INFO] run -> loop -> initializeStatusDependencies -> onInizialized -> Execution finished well.");
initializeUserBot();
return;
}
@@ -211,7 +211,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> initializeUserBot -> onInizialized -> Execution finished well. :-)");
logger.write("[INFO] run -> loop -> initializeUserBot -> onInizialized -> Execution finished well.");
startUserBot();
return;
}
@@ -267,7 +267,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> startUserBot -> onFinished -> Execution finished well. :-)");
logger.write("[INFO] run -> loop -> startUserBot -> onFinished -> Execution finished well.");
nextWaitTime = 'Normal';
loopControl(nextWaitTime);
return;
@@ -372,7 +372,7 @@
function onStop() {
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Stopping the Loop Gracefully. See you next time! :-)"); }
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Stopping the Loop Gracefully. See you next time!"); }
bot.eventHandler.raiseEvent("Loop Finished");
callBackFunction(global.DEFAULT_OK_RESPONSE);
+43 -10
View File
@@ -127,7 +127,7 @@ exports.newRoot = function newRoot() {
let cloudStorage;
let logDisplace = "AACloud" + " ";
let logDisplace = "AACloud" + " ";
let UI_COMMANDS;
return thisObject;
@@ -148,7 +148,22 @@ exports.newRoot = function newRoot() {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
let filePath = global.USER_DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + "AACloud";
let filePath;
switch (global.CURRENT_EXECUTION_AT) {
case "Cloud": {
filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud.
break;
}
case "Browser": {
filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + "AACloud"; // DevTeam Members bots only are run at the browser.
break;
}
default: {
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser' ");
}
}
let fileName = "this.config.json";
cloudStorage.getTextFile(filePath, fileName, onFileReceived);
@@ -236,7 +251,22 @@ exports.newRoot = function newRoot() {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
let filePath = listItem.devTeam + "/" + listItem.repo;
let filePath;
switch (global.CURRENT_EXECUTION_AT) {
case "Cloud": {
filePath = global.DEV_TEAM + "/" + "bots" + "/" + listItem.repo; // DevTeams bots only are run at the cloud.
break;
}
case "Browser": {
filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + listItem.repo; // DevTeam Members bots only are run at the browser.
break;
}
default: {
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser' ");
}
}
let fileName = "this.bot.config.json";
cloudStorage.getTextFile(filePath, fileName, onFileReceived);
@@ -244,7 +274,10 @@ exports.newRoot = function newRoot() {
function onFileReceived(err, text) {
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> onFileReceived -> err = " + err.message);
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> onFileReceived -> err = " + err.message);
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> onFileReceived -> filePath = " + filePath);
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> onFileReceived -> fileName = " + fileName);
return;
}
@@ -563,9 +596,9 @@ exports.newRoot = function newRoot() {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
logger.write("[INFO] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully.");
logger.write("[INFO] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished sucessfully. :-)");
console.log(botId + " Bot execution finished sucessfully.");
} else {
@@ -615,9 +648,9 @@ exports.newRoot = function newRoot() {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
logger.write("[INFO] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully.");
logger.write("[INFO] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished sucessfully. :-)");
console.log(botId + " Bot execution finished sucessfully.");
} else {
@@ -662,9 +695,9 @@ exports.newRoot = function newRoot() {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
logger.write("[INFO] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully.");
logger.write("[INFO] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished sucessfully. :-)");
console.log(botId + " Bot execution finished sucessfully.");
} else {
+2 -4
View File
@@ -1,23 +1,21 @@
global.CURRENT_ENVIRONMENT = "Develop";
global.CURRENT_LOCATION = "Cloud";
global.CURRENT_EXECUTION_AT = "Cloud";
global.SHALL_BOT_STOP = false;
global.USER_LOGGED_IN = "ciencias";
global.USER_DEV_TEAM = "AAMasters";
global.DEV_TEAM = "AAMasters";
process.on('uncaughtException', function (err) {
console.log('[INFO] Run -> uncaughtException -> err.message = ' + err.message);
return;
});
process.on('unhandledRejection', (reason, p) => {
console.log('[INFO] Run -> unhandledRejection -> reason = ' + reason);
console.log('[INFO] Run -> unhandledRejection -> p = ' + JSON.stringify(p));
return;
});
process.on('exit', function (code) {
try {
console.log('[INFO] Run -> process.on.exit -> About to exit -> code = ' + code);
+1 -1
View File
@@ -464,7 +464,7 @@
/* We arrived to the point where we have checked all the status reports of every month and they are all complete. */
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> loop -> Verification Finished. Success. :-)"); }
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> loop -> Verification Finished. Success."); }
callBackFunction(global.DEFAULT_OK_RESPONSE);
return;
+13 -13
View File
@@ -295,7 +295,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> initializeStatusDependencies -> onInizialized -> Execution finished well. :-)");
logger.write("[INFO] run -> loop -> initializeStatusDependencies -> onInizialized -> Execution finished well.");
initializeDataDependencies();
return;
}
@@ -353,7 +353,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> initializeDataDependencies -> onInizialized -> Execution finished well. :-)");
logger.write("[INFO] run -> loop -> initializeDataDependencies -> onInizialized -> Execution finished well.");
initializeContext();
return;
}
@@ -410,7 +410,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> initializeContext -> onInizialized -> Execution finished well. :-)");
logger.write("[INFO] run -> loop -> initializeContext -> onInizialized -> Execution finished well.");
initializeExchangeAPI();
return;
}
@@ -468,7 +468,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> initializeExchangeAPI -> onInizialized -> Execution finished well. :-)");
logger.write("[INFO] run -> loop -> initializeExchangeAPI -> onInizialized -> Execution finished well.");
initializeAssistant();
return;
}
@@ -525,7 +525,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> initializeAssistant -> onInizialized -> Execution finished well. :-)");
logger.write("[INFO] run -> loop -> initializeAssistant -> onInizialized -> Execution finished well.");
initializeUserBot();
return;
}
@@ -583,7 +583,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> initializeUserBot -> onInizialized -> Execution finished well. :-)");
logger.write("[INFO] run -> loop -> initializeUserBot -> onInizialized -> Execution finished well.");
startUserBot();
return;
}
@@ -639,7 +639,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> startUserBot -> onFinished -> Execution finished well. :-)");
logger.write("[INFO] run -> loop -> startUserBot -> onFinished -> Execution finished well.");
saveContext();
return;
}
@@ -695,7 +695,7 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> saveContext -> onFinished -> Execution finished well. :-)");
logger.write("[INFO] run -> loop -> saveContext -> onFinished -> Execution finished well.");
nextWaitTime = 'Normal';
loopControl(nextWaitTime);
return;
@@ -753,7 +753,7 @@
function onStop() {
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Stopping the Loop Gracefully. See you next time! :-)"); }
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Stopping the Loop Gracefully. See you next time!"); }
bot.eventHandler.raiseEvent("Loop Finished");
callBackFunction(global.DEFAULT_OK_RESPONSE);
return;
@@ -766,25 +766,25 @@
switch (nextWaitTime) {
case 'Normal': {
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Restarting Loop in " + (processConfig.normalWaitTime / 1000) + " seconds."); }
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Normal -> Restarting Loop in " + (processConfig.normalWaitTime / 1000) + " seconds."); }
bot.eventHandler.raiseEvent("Loop Finished");
setTimeout(loop, processConfig.normalWaitTime);
}
break;
case 'Retry': {
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Restarting Loop in " + (processConfig.retryWaitTime / 1000) + " seconds."); }
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Retry -> Restarting Loop in " + (processConfig.retryWaitTime / 1000) + " seconds."); }
bot.eventHandler.raiseEvent("Loop Finished");
setTimeout(loop, processConfig.retryWaitTime);
}
break;
case 'Sleep': {
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Restarting Loop in " + (processConfig.sleepWaitTime / 60000) + " minutes."); }
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Sleep -> Restarting Loop in " + (processConfig.sleepWaitTime / 60000) + " minutes."); }
bot.eventHandler.raiseEvent("Loop Finished");
setTimeout(loop, processConfig.sleepWaitTime);
}
break;
case 'Coma': {
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Restarting Loop in " + (processConfig.comaWaitTime / 3600000) + " hours."); }
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Coma -> Restarting Loop in " + (processConfig.comaWaitTime / 3600000) + " hours."); }
bot.eventHandler.raiseEvent("Loop Finished");
setTimeout(loop, processConfig.comaWaitTime);
}