diff --git a/Assistant.js b/Assistant.js
index 654685440..7252104e4 100644
--- a/Assistant.js
+++ b/Assistant.js
@@ -1,8 +1,5 @@
exports.newAssistant = function newAssistant(BOT, DEBUG_MODULE, UTILITIES) {
- const FULL_LOG = true;
- const LOG_FILE_CONTENT = false;
-
/*
This module allows trading bots to execute actions on the exchange, and also on its current recorded state.
@@ -50,7 +47,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> Entering function."); }
/* Save local values. */
@@ -78,7 +75,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> getMarketRateFromExchange -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getMarketRateFromExchange -> Entering function."); }
exchangeAPI.getTicker(global.MARKET.assetA + '_' + global.MARKET.assetB, onTicker);
@@ -88,11 +85,11 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> getMarketRateFromExchange -> onTicker -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getMarketRateFromExchange -> onTicker -> Entering function."); }
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> getMarketRateFromExchange -> onTicker -> We could not get the Market Price now."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getMarketRateFromExchange -> onTicker -> We could not get the Market Price now."); }
callBackFunction(err);
return;
@@ -121,7 +118,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> getMarketRateFromIndicator -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getMarketRateFromIndicator -> Entering function."); }
/* Procedure to get the current market rate. */
@@ -132,7 +129,7 @@
global.PLATFORM_CONFIG.marketRateProvider.dataSet + "-" +
global.PLATFORM_CONFIG.marketRateProvider.dataSetVersion;
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> getMarketRateFromIndicator -> key = " + key); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getMarketRateFromIndicator -> key = " + key); }
let dataSet = thisObject.dataDependencies.dataSets.get(key);
@@ -144,8 +141,8 @@
function onFileReceived(err, text) {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> getMarketRateFromIndicator -> onFileReceived -> Entering function."); }
- if (LOG_FILE_CONTENT === true) { logger.write("[INFO] initialize -> getMarketRateFromIndicator -> onFileReceived -> text = " + text); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getMarketRateFromIndicator -> onFileReceived -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logContent === true) { logger.write("[INFO] initialize -> getMarketRateFromIndicator -> onFileReceived -> text = " + text); }
let candleArray;
@@ -211,7 +208,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> validateExchangeSyncronicity -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> validateExchangeSyncronicity -> Entering function."); }
/* Procedure to validate we are in sync with the exchange. */
@@ -220,7 +217,7 @@
function onDone(err) {
try {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> validateExchangeSyncronicity -> onDone -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> validateExchangeSyncronicity -> onDone -> Entering function."); }
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
@@ -259,7 +256,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> calculateProfits -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> calculateProfits -> Entering function."); }
/* Calculate Profits */
@@ -314,7 +311,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] getPositionsAtExchange -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getPositionsAtExchange -> Entering function."); }
/*
@@ -328,14 +325,14 @@
case "Live": {
- if (FULL_LOG === true) { logger.write("[INFO] getPositionsAtExchange -> Live Mode Detected."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getPositionsAtExchange -> Live Mode Detected."); }
exchangeAPI.getOpenPositions(global.MARKET, onResponse);
break;
}
case "Backtest": {
- if (FULL_LOG === true) { logger.write("[INFO] getPositionsAtExchange -> Backtest Mode Detected."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getPositionsAtExchange -> Backtest Mode Detected."); }
let exchangePositions = []; // We simulate all positions were executed.
onResponse(global.DEFAULT_OK_RESPONSE, exchangePositions);
break;
@@ -343,7 +340,7 @@
case "Competition": {
- if (FULL_LOG === true) { logger.write("[INFO] getPositionsAtExchange -> Competition Mode Detected."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getPositionsAtExchange -> Competition Mode Detected."); }
exchangeAPI.getOpenPositions(global.MARKET, onResponse);
break;
}
@@ -358,8 +355,8 @@
function onResponse(err, pExchangePositions) {
- if (FULL_LOG === true) { logger.write("[INFO] getPositionsAtExchange -> onResponse -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] getPositionsAtExchange -> onResponse -> pExchangePositions = " + JSON.stringify(pExchangePositions)); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getPositionsAtExchange -> onResponse -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getPositionsAtExchange -> onResponse -> pExchangePositions = " + JSON.stringify(pExchangePositions)); }
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: { // Everything went well, we have the information requested.
@@ -393,7 +390,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> Entering function."); }
/*
@@ -437,7 +434,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> Entering function."); }
let position = context.executionContext.positions[i];
let exchangePosition;
@@ -457,7 +454,7 @@
function positionFound() {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> positionFound -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> positionFound -> Entering function."); }
/*
@@ -484,7 +481,7 @@
function positionNotFound() {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> positionNotFound -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> positionNotFound -> Entering function."); }
/* Position not found: we need to know if the order was executed. */
@@ -496,8 +493,8 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> pPositionId = " + pPositionId); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> pPositionId = " + pPositionId); }
/*
@@ -509,7 +506,7 @@
case "Live": {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> Live Mode Detected."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> Live Mode Detected."); }
exchangeAPI.getExecutedTrades(pPositionId, onResponse);
return;
@@ -517,7 +514,7 @@
case "Backtest": {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> Backtest Mode Detected."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> Backtest Mode Detected."); }
let trades = [];
@@ -559,7 +556,7 @@
case "Competition": {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> Competition Mode Detected."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> Competition Mode Detected."); }
exchangeAPI.getExecutedTrades(pPositionId, onResponse);
return;
}
@@ -575,7 +572,7 @@
function onResponse(err, pTrades) {
try {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> Entering function."); }
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: { // Everything went well, we have the information requested.
@@ -611,8 +608,8 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> pTrades = " + JSON.stringify(pTrades)); }
+ 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)); }
/*
@@ -682,7 +679,7 @@
function confirmOrderWasPartiallyExecuted(pTrades) {
try {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> confirmOrderWasPartiallyExecuted -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> confirmOrderWasPartiallyExecuted -> Entering function."); }
/*
@@ -756,7 +753,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> applyTradesToContext -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> applyTradesToContext -> Entering function."); }
/* Here we apply the trades that already happened at the exchange to the balance and available balance of the bot. We also calculate its profits. */
@@ -814,7 +811,7 @@
function next() {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> next -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> next -> Entering function."); }
i++;
controlLoop();
@@ -823,7 +820,7 @@
function controlLoop() {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> controlLoop -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> controlLoop -> Entering function."); }
if (i < context.executionContext.positions.length) {
@@ -838,7 +835,7 @@
function final() {
- if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> final -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] ordersExecutionCheck -> final -> Entering function."); }
callBack(global.DEFAULT_OK_RESPONSE);
@@ -853,11 +850,11 @@
function putPosition(pType, pRate, pAmountA, pAmountB, callBackFunction) {
try {
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> pType = " + pType); }
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> pRate = " + pRate); }
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> pAmountA = " + pAmountA); }
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> pAmountB = " + pAmountB); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> pType = " + pType); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> pRate = " + pRate); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> pAmountA = " + pAmountA); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> pAmountB = " + pAmountB); }
/* Removing extra decimals. */
@@ -958,7 +955,7 @@
}
let positionId = Math.trunc(Math.random(1) * 1000000);
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> Simulating Exchange Response -> orderId = " + positionId); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> Simulating Exchange Response -> orderId = " + positionId); }
onResponse(global.DEFAULT_OK_RESPONSE, positionId);
return;
}
@@ -980,8 +977,8 @@
function onResponse(err, pPositionId) {
try {
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> onResponse -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> onResponse -> pPositionId = " + pPositionId); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> onResponse -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> onResponse -> pPositionId = " + pPositionId); }
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: { // Everything went well, we have the information requested.
@@ -1058,9 +1055,9 @@
function movePosition(pPosition, pNewRate, callBackFunction) {
try {
- if (FULL_LOG === true) { logger.write("[INFO] movePosition -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] movePosition -> pPosition = " + JSON.stringify(pPosition)); }
- if (FULL_LOG === true) { logger.write("[INFO] movePosition -> pNewRate = " + pNewRate); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] movePosition -> Entering function."); }
+ 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) {
@@ -1073,7 +1070,7 @@
case "Backtest": {
let positionId = Math.trunc(Math.random(1) * 1000000);
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> Simulating Exchange Response -> orderId = " + positionId); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> Simulating Exchange Response -> orderId = " + positionId); }
onResponse(global.DEFAULT_OK_RESPONSE, positionId);
return;
}
@@ -1095,8 +1092,8 @@
function onResponse(err, pPositionId) {
try {
- if (FULL_LOG === true) { logger.write("[INFO] movePosition -> onResponse -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] movePosition -> onResponse -> pPositionId = " + pPositionId); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] movePosition -> onResponse -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] movePosition -> onResponse -> pPositionId = " + pPositionId); }
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: { // Everything went well, we have the information requested.
diff --git a/Context.js b/Context.js
index 42f2a7da4..315985a51 100644
--- a/Context.js
+++ b/Context.js
@@ -1,8 +1,5 @@
exports.newContext = function newContext(BOT, DEBUG_MODULE, BLOB_STORAGE, UTILITIES, STATUS_REPORT) {
- const FULL_LOG = true;
- const LOG_FILE_CONTENT = false;
-
let bot = BOT;
const MODULE_NAME = "Context";
@@ -97,7 +94,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> Entering function."); }
statusDependencies = pStatusDependencies;
@@ -166,7 +163,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> getStatusReport -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getStatusReport -> Entering function."); }
let key = bot.devTeam + "-" + bot.codeName + "-" + bot.process + "-" + bot.dataSetVersion;
@@ -221,13 +218,13 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionHistory -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getExecutionHistory -> Entering function."); }
let fileName = "Execution.History." + bot.runMode + "." + runIndex + ".json";
let filePath = bot.filePathRoot + "/Output/" + bot.process;
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionHistory -> fileName = " + fileName); }
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionHistory -> filePath = " + filePath); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getExecutionHistory -> fileName = " + fileName); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getExecutionHistory -> filePath = " + filePath); }
cloudStorage.getTextFile(filePath, fileName, onFileReceived);
@@ -239,7 +236,7 @@
return;
}
- if (LOG_FILE_CONTENT === true) {
+ if (global.LOG_CONTROL[MODULE_NAME].logContent === true) {
logger.write("[INFO] initialize -> getExecutionHistory -> onFileReceived -> Content received = " + text);
}
@@ -279,7 +276,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionContext -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getExecutionContext -> Entering function."); }
let date;
@@ -316,8 +313,8 @@
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;
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionContext -> fileName = " + fileName); }
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionContext -> filePath = " + filePath); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getExecutionContext -> fileName = " + fileName); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> getExecutionContext -> filePath = " + filePath); }
cloudStorage.getTextFile(filePath, fileName, onFileReceived);
@@ -329,7 +326,7 @@
return;
}
- if (FULL_LOG === true) {
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) {
logger.write("[INFO] initialize -> getExecutionContext -> onFileReceived -> Content received = " + text);
}
@@ -372,7 +369,7 @@
function createConext(callBack) {
try {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> createConext -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> createConext -> Entering function."); }
/*
When the bot is executed for the very first time, there are a few files that do not exist and need to be created, and that
@@ -529,14 +526,14 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> Entering function."); }
let fileName = "Execution.Context." + bot.runMode + "." + 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;
- if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> fileName = " + fileName); }
- if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> filePath = " + filePath); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> fileName = " + fileName); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> filePath = " + filePath); }
utilities.createFolderIfNeeded(filePath, cloudStorage, onFolderCreated);
@@ -544,7 +541,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> onFolderCreated -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> onFolderCreated -> Entering function."); }
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
logger.write("[ERROR] saveThemAll -> writeExecutionContext -> onFolderCreated -> err = " + err.message);
@@ -558,7 +555,7 @@
function onFileCreated(err) {
- if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> onFolderCreated -> onFileCreated -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> onFolderCreated -> onFileCreated -> Entering function."); }
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
logger.write("[ERROR] saveThemAll -> writeExecutionContext -> onFolderCreated -> onFileCreated -> err = " + err.message);
@@ -566,7 +563,7 @@
return;
}
- if (FULL_LOG === true) {
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) {
logger.write("[INFO] saveThemAll -> writeExecutionContext -> onFolderCreated -> onFileCreated -> Content written = " + fileContent);
}
@@ -590,13 +587,13 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> Entering function."); }
let fileName = "Execution.History." + bot.runMode + "." + runIndex + ".json";
let filePath = bot.filePathRoot + "/Output/" + bot.process;
- if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> fileName = " + fileName); }
- if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> filePath = " + filePath); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> fileName = " + fileName); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> filePath = " + filePath); }
utilities.createFolderIfNeeded(filePath, cloudStorage, onFolderCreated);
@@ -604,7 +601,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> Entering function."); }
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
logger.write("[ERROR] saveThemAll -> writeExucutionHistory -> onFolderCreated -> err = " + err.message);
@@ -644,7 +641,7 @@
function onFileCreated(err) {
- if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> Entering function."); }
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
logger.write("[ERROR] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> err = " + err.message);
@@ -652,7 +649,7 @@
return;
}
- if (LOG_FILE_CONTENT === true) {
+ if (global.LOG_CONTROL[MODULE_NAME].logContent === true) {
logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> Content written = " + fileContent);
}
@@ -666,7 +663,7 @@
function onSequenceFileCreated(err) {
- if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> onSequenceFileCreated -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> onSequenceFileCreated -> Entering function."); }
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
logger.write("[ERROR] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> onSequenceFileCreated -> err = " + err.message);
@@ -695,7 +692,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeStatusReport -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] saveThemAll -> writeStatusReport -> Entering function."); }
statusReportModule.file = thisObject.statusReport;
statusReportModule.save(callBack);
diff --git a/DataSet.js b/DataSet.js
index ef6692acc..f7e95bf82 100644
--- a/DataSet.js
+++ b/DataSet.js
@@ -1,9 +1,6 @@
exports.newDataSet = function newDataSet(BOT, DEBUG_MODULE, BLOB_STORAGE, UTILITIES) {
- const FULL_LOG = true;
- const LOG_FILE_CONTENT = false;
-
- const MODULE_NAME = "Data Set";
+ const MODULE_NAME = "DataSet";
let bot = BOT;
@@ -39,7 +36,7 @@
dependencyConfig = pDependencyConfig;
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> Entering function."); }
initializeStorage();
@@ -51,7 +48,7 @@
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> initializeStorage -> onInizialized -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> initializeStorage -> onInizialized -> Entering function."); }
callBackFunction(global.DEFAULT_OK_RESPONSE);
} else {
@@ -70,9 +67,9 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] getTextFile -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] getTextFile -> pFolderPath = " + pFolderPath); }
- if (FULL_LOG === true) { logger.write("[INFO] getTextFile -> pFileName = " + pFileName); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getTextFile -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getTextFile -> pFolderPath = " + pFolderPath); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getTextFile -> pFileName = " + pFileName); }
let filePathRoot = dependencyConfig.devTeam + "/" + dependencyConfig.bot + "." + dependencyConfig.botVersion.major + "." + dependencyConfig.botVersion.minor + "/" + global.PLATFORM_CONFIG.codeName + "." + global.PLATFORM_CONFIG.version.major + "." + global.PLATFORM_CONFIG.version.minor + "/" + global.EXCHANGE_NAME + "/" + dependencyConfig.dataSetVersion;
let filePath = filePathRoot + "/Output/" + pFolderPath;
@@ -81,7 +78,7 @@
function onFileReceived(err, text) {
- if (FULL_LOG === true) { logger.write("[INFO] getTextFile -> onFileReceived -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getTextFile -> onFileReceived -> Entering function."); }
callBackFunction(err, text);
@@ -97,9 +94,9 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] createTextFile -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] createTextFile -> pFolderPath = " + pFolderPath); }
- if (FULL_LOG === true) { logger.write("[INFO] createTextFile -> pFileName = " + pFileName); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] createTextFile -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] createTextFile -> pFolderPath = " + pFolderPath); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] createTextFile -> pFileName = " + pFileName); }
let ownerId = dependencyConfig.devTeam + "-" + dependencyConfig.bot + "-" + dependencyConfig.botVersion.major + "-" + dependencyConfig.botVersion.minor + "-" + dependencyConfig.dataSetVersion;
let botId = bot.devTeam + "-" + bot.codeName + "-" + bot.version.major + "-" + bot.version.minor + "-" + bot.dataSetVersion;
@@ -122,7 +119,7 @@
function onFileCreated(err) {
- if (FULL_LOG === true) { logger.write("[INFO] createTextFile -> onFileCreated -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] createTextFile -> onFileCreated -> Entering function."); }
callBackFunction(err);
diff --git a/Dummy.js b/Dummy.js
deleted file mode 100644
index f0a31eb8b..000000000
--- a/Dummy.js
+++ /dev/null
@@ -1,5 +0,0 @@
-exports.newDummy = function newDummy() {
-
-
-
-}
\ No newline at end of file
diff --git a/ExchangeAPI.js b/ExchangeAPI.js
index ca56ddd8d..9b6d78ab0 100644
--- a/ExchangeAPI.js
+++ b/ExchangeAPI.js
@@ -1,15 +1,12 @@
exports.newExchangeAPI = function newExchangeAPI(BOT, DEBUG_MODULE, POLONIEX_CLIENT_MODULE) {
- const FULL_LOG = true;
- const LOG_FILE_CONTENT = false;
-
/*
This module allows trading bots to connect to the exchange and do trading operations on it. So far it can only work with Poloniex.
*/
- const MODULE_NAME = "Exchange API";
+ const MODULE_NAME = "ExchangeAPI";
let bot = BOT;
@@ -35,7 +32,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> Entering function."); }
poloniexApiClient = POLONIEX_CLIENT_MODULE.newPoloniexAPIClient(global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Key, global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Secret);
@@ -52,8 +49,8 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] getOpenPositions -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] getOpenPositions -> pMarket = " + JSON.stringify(pMarket)); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getOpenPositions -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getOpenPositions -> pMarket = " + JSON.stringify(pMarket)); }
poloniexApiClient.API.returnOpenOrders(pMarket.assetA, pMarket.assetB, onExchangeCallReturned);
@@ -61,9 +58,9 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] getOpenPositions -> onExchangeCallReturned -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] getOpenPositions -> onExchangeCallReturned -> err = " + err); }
- if (LOG_FILE_CONTENT === true) { logger.write("[INFO] getOpenPositions -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getOpenPositions -> onExchangeCallReturned -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getOpenPositions -> onExchangeCallReturned -> err = " + err); }
+ if (global.LOG_CONTROL[MODULE_NAME].logContent === true) { logger.write("[INFO] getOpenPositions -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
poloniexApiClient.API.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
@@ -118,8 +115,8 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] getExecutedTrades -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] getExecutedTrades -> pPositionId = " + pPositionId); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getExecutedTrades -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getExecutedTrades -> pPositionId = " + pPositionId); }
poloniexApiClient.API.returnOrderTrades(pPositionId, onExchangeCallReturned);
@@ -127,9 +124,9 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] getExecutedTrades -> onExchangeCallReturned -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] getExecutedTrades -> onExchangeCallReturned -> err = " + err); }
- if (LOG_FILE_CONTENT === true) { logger.write("[INFO] getExecutedTrades -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getExecutedTrades -> onExchangeCallReturned -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getExecutedTrades -> onExchangeCallReturned -> err = " + err); }
+ if (global.LOG_CONTROL[MODULE_NAME].logContent === true) { logger.write("[INFO] getExecutedTrades -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
poloniexApiClient.API.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
@@ -191,12 +188,12 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> pMarket = " + JSON.stringify(pMarket)); }
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> pType = " + pType); }
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> pRate = " + pRate); }
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> pAmountA = " + pAmountA); }
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> pAmountB = " + pAmountB); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> pMarket = " + JSON.stringify(pMarket)); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> pType = " + pType); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> pRate = " + pRate); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> pAmountA = " + pAmountA); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> pAmountB = " + pAmountB); }
if (pType === "buy") {
poloniexApiClient.API.buy(pMarket.assetA, pMarket.assetB, pRate, pAmountB, onExchangeCallReturned);
@@ -216,9 +213,9 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> onExchangeCallReturned -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] putPosition -> onExchangeCallReturned -> err = " + err); }
- if (LOG_FILE_CONTENT === true) { logger.write("[INFO] putPosition -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> onExchangeCallReturned -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] putPosition -> onExchangeCallReturned -> err = " + err); }
+ if (global.LOG_CONTROL[MODULE_NAME].logContent === true) { logger.write("[INFO] putPosition -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
poloniexApiClient.API.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
@@ -262,17 +259,17 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] movePosition -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] movePosition -> pPosition = " + JSON.stringify(pPosition)); }
- if (FULL_LOG === true) { logger.write("[INFO] movePosition -> pNewRate = " + pNewRate); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] movePosition -> Entering function."); }
+ 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); }
poloniexApiClient.API.moveOrder(pPosition.id, pNewRate, pPosition.amountB, onExchangeCallReturned);
function onExchangeCallReturned(err, exchangeResponse) {
- if (FULL_LOG === true) { logger.write("[INFO] movePosition -> onExchangeCallReturned -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] movePosition -> onExchangeCallReturned -> err = " + err); }
- if (LOG_FILE_CONTENT === true) { logger.write("[INFO] movePosition -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] movePosition -> onExchangeCallReturned -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] movePosition -> onExchangeCallReturned -> err = " + err); }
+ if (global.LOG_CONTROL[MODULE_NAME].logContent === true) { logger.write("[INFO] movePosition -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
try {
@@ -323,15 +320,15 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] getTicker -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] getTicker -> Entering function."); }
poloniexApiClient.API.returnTicker(onExchangeCallReturned);
function onExchangeCallReturned(err, exchangeResponse) {
- if (FULL_LOG === true) { logger.write("[INFO] movePosition -> onExchangeCallReturned -> Entering function."); }
- if (FULL_LOG === true) { logger.write("[INFO] movePosition -> onExchangeCallReturned -> err = " + err); }
- if (LOG_FILE_CONTENT === true) { logger.write("[INFO] movePosition -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] movePosition -> onExchangeCallReturned -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] movePosition -> onExchangeCallReturned -> err = " + err); }
+ if (global.LOG_CONTROL[MODULE_NAME].logContent === true) { logger.write("[INFO] movePosition -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
try {
diff --git a/Project.njsproj b/Project.njsproj
index e598fe529..ea7ab1eb3 100644
--- a/Project.njsproj
+++ b/Project.njsproj
@@ -35,9 +35,6 @@
Code
-
- Code
-
Code
diff --git a/Root.js b/Root.js
index 43931b0a7..82c1bd778 100644
--- a/Root.js
+++ b/Root.js
@@ -4,6 +4,44 @@ exports.newRoot = function newRoot() {
/* Global constants definitions. */
+ global.LOG_CONTROL = {
+ Assistant: {
+ logInfo: true,
+ logWarnings: true,
+ logErrors: true,
+ logContent: false,
+ intensiveLogging: false
+ },
+ ExchangeAPI: {
+ logInfo: true,
+ logWarnings: true,
+ logErrors: true,
+ logContent: false,
+ intensiveLogging: false
+ },
+ StatusReport: {
+ logInfo: true,
+ logWarnings: true,
+ logErrors: true,
+ logContent: false,
+ intensiveLogging: false
+ },
+ DataSet: {
+ logInfo: true,
+ logWarnings: true,
+ logErrors: true,
+ logContent: false,
+ intensiveLogging: false
+ },
+ Context: {
+ logInfo: true,
+ logWarnings: true,
+ logErrors: true,
+ logContent: false,
+ intensiveLogging: false
+ }
+ };
+
/* Callbacks default responses. */
global.DEFAULT_OK_RESPONSE = {
diff --git a/StatusReport.js b/StatusReport.js
index 6cd0d8830..70ad6076e 100644
--- a/StatusReport.js
+++ b/StatusReport.js
@@ -1,8 +1,5 @@
exports.newStatusReport = function newStatusReport(BOT, DEBUG_MODULE, BLOB_STORAGE, UTILITIES) {
- const FULL_LOG = true;
- const LOG_FILE_CONTENT = false;
-
/*
A Status Report is a file that every bot reads at the begining of its execution and saves after it finishes its job.
@@ -11,7 +8,7 @@
*/
- const MODULE_NAME = "Status Report";
+ const MODULE_NAME = "StatusReport";
let bot = BOT;
@@ -61,7 +58,7 @@
timePath = "/" + year + "/" + month;
}
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> Entering function."); }
initializeStorage();
@@ -74,7 +71,7 @@
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> initializeStorage -> onInizialized -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> initializeStorage -> onInizialized -> Entering function."); }
callBackFunction(global.DEFAULT_OK_RESPONSE);
} else {
@@ -93,14 +90,14 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> load -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> load -> Entering function."); }
let rootPath = owner.devTeam + "/" + owner.bot + "." + owner.botVersion.major + "." + owner.botVersion.minor + "/" + global.PLATFORM_CONFIG.codeName + "." + global.PLATFORM_CONFIG.version.major + "." + global.PLATFORM_CONFIG.version.minor + "/" + global.EXCHANGE_NAME + "/" + owner.dataSetVersion;
let fileName = "Status.Report." + global.MARKET.assetA + '_' + global.MARKET.assetB + ".json";
let filePath = rootPath + "/Reports/" + owner.process + timePath;
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> load -> fileName = " + fileName); }
- if (FULL_LOG === true) { logger.write("[INFO] initialize -> load -> filePath = " + filePath); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> load -> fileName = " + fileName); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] initialize -> load -> filePath = " + filePath); }
cloudStorage.getTextFile(filePath, fileName, onFileReceived);
@@ -131,7 +128,7 @@
return;
}
- if (LOG_FILE_CONTENT === true) {
+ if (global.LOG_CONTROL[MODULE_NAME].logContent === true) {
logger.write("[INFO] initialize -> load -> onFileReceived -> Content received = " + text);
}
@@ -169,7 +166,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] save -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] save -> Entering function."); }
let ownerId = owner.devTeam + "-" + owner.bot + "-" + owner.botVersion.major + "-" + owner.botVersion.minor + "-" + owner.process + "-" + owner.dataSetVersion;
let botId = bot.devTeam + "-" + bot.codeName + "-" + bot.version.major + "-" + bot.version.minor + "-" + bot.process + "-" + bot.dataSetVersion;
@@ -188,8 +185,8 @@
let fileName = "Status.Report." + global.MARKET.assetA + '_' + global.MARKET.assetB + ".json";
let filePath = bot.filePathRoot + "/Reports/" + owner.process + timePath;
- if (FULL_LOG === true) { logger.write("[INFO] save -> fileName = " + fileName); }
- if (FULL_LOG === true) { logger.write("[INFO] save -> filePath = " + filePath); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] save -> fileName = " + fileName); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] save -> filePath = " + filePath); }
utilities.createFolderIfNeeded(filePath, cloudStorage, onFolderCreated);
@@ -197,7 +194,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] save -> onFolderCreated -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] save -> onFolderCreated -> Entering function."); }
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
logger.write("[ERROR] save -> onFolderCreated -> err = " + err.message);
@@ -211,7 +208,7 @@
function onFileCreated(err) {
- if (FULL_LOG === true) { logger.write("[INFO] save -> onFolderCreated -> onFileCreated -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] save -> onFolderCreated -> onFileCreated -> Entering function."); }
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
logger.write("[ERROR] save -> onFolderCreated -> onFileCreated -> err = " + err.message);
@@ -219,7 +216,7 @@
return;
}
- if (LOG_FILE_CONTENT === true) {
+ if (global.LOG_CONTROL[MODULE_NAME].logContent === true) {
logger.write("[INFO] save -> onFolderCreated -> onFileCreated -> Content written = " + fileContent);
}
@@ -253,7 +250,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] verifyMarketComplete -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> Entering function."); }
let initialYear;
let initialMonth;
@@ -269,7 +266,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] verifyMarketComplete -> onLoad -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> onLoad -> Entering function."); }
if (
err.result === global.CUSTOM_FAIL_RESPONSE.result &&
@@ -279,7 +276,7 @@
/* The first month of the market didnt create the main report yet. Aborting verification. */
- if (FULL_LOG === true) { logger.write("[INFO] verifyMarketComplete -> onLoad -> Verification ABORTED since the main status report does not exist."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> onLoad -> Verification ABORTED since the main status report does not exist."); }
callBackFunction(global.DEFAULT_OK_RESPONSE);
return;
@@ -309,7 +306,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] verifyMarketComplete -> loopCycle -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> loopCycle -> Entering function."); }
/* Here we read the status report file of each month / year to verify if it is complete or not. */
@@ -323,7 +320,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] verifyMarketComplete -> loopCycle -> onLoad -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> loopCycle -> onLoad -> Entering function."); }
if (
err.result === global.CUSTOM_FAIL_RESPONSE.result &&
@@ -333,7 +330,7 @@
/* The first month of the market didnt create the main report yet. Aborting verification. */
- if (FULL_LOG === true) { logger.write("[INFO] verifyMarketComplete -> loopCycle -> onLoad -> Verification ABORTED since the status report for year " + initialYear + " and month " + initialMonth + " did not exist. "); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> loopCycle -> onLoad -> Verification ABORTED since the status report for year " + initialYear + " and month " + initialMonth + " did not exist. "); }
callBackFunction(global.DEFAULT_OK_RESPONSE);
return;
@@ -353,7 +350,7 @@
/* If any of the files says that month is not checked then it is enough to know the market continuity is broken. */
- if (FULL_LOG === true) { logger.write("[INFO] verifyMarketComplete -> loopCycle -> onLoad -> Verification ABORTED since the status report for year " + initialYear + " and month " + initialMonth + " is not marked as complete."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> loopCycle -> onLoad -> Verification ABORTED since the status report for year " + initialYear + " and month " + initialMonth + " is not marked as complete."); }
callBackFunction(global.DEFAULT_OK_RESPONSE);
return;
@@ -376,7 +373,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] verifyMarketComplete -> readAndWriteNewReport -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> readAndWriteNewReport -> Entering function."); }
/* We will read the current file to preserve its data, and save it again with the new lastFile */
@@ -390,7 +387,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] verifyMarketComplete -> readAndWriteNewReport -> onLoad -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> readAndWriteNewReport -> onLoad -> Entering function."); }
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
logger.write("[ERROR] verifyMarketComplete -> readAndWriteNewReport -> onLoad -> err = " + err.message);
@@ -410,7 +407,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] verifyMarketComplete -> readAndWriteNewReport -> onLoad -> onSave -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> readAndWriteNewReport -> onLoad -> onSave -> Entering function."); }
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
logger.write("[ERROR] verifyMarketComplete -> readAndWriteNewReport -> onLoad -> onSave -> err = " + err.message);
@@ -429,8 +426,8 @@
} else {
- if (FULL_LOG === true) { logger.write("[INFO] verifyMarketComplete -> readAndWriteNewReport -> onLoad -> Main Status Report Not Updated."); }
- if (FULL_LOG === true) { logger.write("[INFO] verifyMarketComplete -> readAndWriteNewReport -> onLoad -> Current Trade Id (" + monthlyStatusReport.lastTrade.id + ") is <= than Id at main status report file. (" + thisObject.file.lastTrade.id + ")"); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> readAndWriteNewReport -> onLoad -> Main Status Report Not Updated."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> readAndWriteNewReport -> onLoad -> Current Trade Id (" + monthlyStatusReport.lastTrade.id + ") is <= than Id at main status report file. (" + thisObject.file.lastTrade.id + ")"); }
loop(); // Lets see the next month.
}
@@ -452,7 +449,7 @@
try {
- if (FULL_LOG === true) { logger.write("[INFO] verifyMarketComplete -> loop -> Entering function."); }
+ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write("[INFO] verifyMarketComplete -> loop -> Entering function."); }
initialMonth++;
@@ -467,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 (FULL_LOG === 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;