From 70915a296bba3d64979db95f23b5341a1c2980f3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 7 Oct 2020 23:41:08 +0200 Subject: [PATCH] Deep Scan Medium Severity --- DataSet.js | 6 ++++-- IndicatorBot.js | 2 +- LowFrequencyTrading/TradingPosition.js | 8 ++++---- LowFrequencyTrading/TradingSystem.js | 2 +- MultiPeriodDaily.js | 7 +++---- ProcessExecutionEvents.js | 2 +- ProcessOutput.js | 4 ++-- SensorBot.js | 2 +- Session.js | 2 +- TradingBot.js | 1 - server.js | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/DataSet.js b/DataSet.js index 5b43b7bbf..4637e72b9 100644 --- a/DataSet.js +++ b/DataSet.js @@ -24,8 +24,8 @@ exports.newDataSet = function newDataSet(BOT, logger) { try { thisObject.node = dataDependency.referenceParent; - logger.fileName = MODULE_NAME + "." + thisObject.node.type + "." + thisObject.node.name + "." + thisObject.node.id; - + logger.fileName = MODULE_NAME + /* Some very basic validations that we have all the information needed. */ if (thisObject.node === undefined) { logger.write(MODULE_NAME, "[ERROR] initialize -> Data Dependency without Reference Parent -> dataDependency = " + JSON.stringify(dataDependency)); @@ -33,6 +33,8 @@ exports.newDataSet = function newDataSet(BOT, logger) { return } + logger.fileName = MODULE_NAME + "." + thisObject.node.type + "." + thisObject.node.name + "." + thisObject.node.id; + if (thisObject.node.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] initialize -> Dataset witn no codeName defined -> Product Dataset = " + JSON.stringify(thisObject.node)); callBackFunction(global.DEFAULT_FAIL_RESPONSE); diff --git a/IndicatorBot.js b/IndicatorBot.js index cd513dee4..2f55a1daa 100644 --- a/IndicatorBot.js +++ b/IndicatorBot.js @@ -61,7 +61,7 @@ function onCommonsDownloaded(err, text) { if (err.result !== global.DEFAULT_OK_RESPONSE.result) { - parentLogger.write(MODULE_NAME, "[WARN] initialize -> onBotDownloaded -> onCommonsDownloaded -> Commons not found: " + err.code || err.message); + parentLogger.write(MODULE_NAME, "[WARN] initialize -> onBotDownloaded -> onCommonsDownloaded -> Commons not found: " + err.message); callBackFunction(global.DEFAULT_OK_RESPONSE); return; } diff --git a/LowFrequencyTrading/TradingPosition.js b/LowFrequencyTrading/TradingPosition.js index 8476a4685..bad18fabf 100644 --- a/LowFrequencyTrading/TradingPosition.js +++ b/LowFrequencyTrading/TradingPosition.js @@ -186,7 +186,7 @@ exports.newTradingPosition = function newTradingPosition(bot, logger, tradingEng const message = 'Target Size In Base Asset cannot be undefined. Fix this please.' badDefinitionUnhandledException(undefined, message, tradingSystemStageNode.initialTargets.targetSizeInBaseAsset.formula) } - if (value === undefined) { + if (value === 0) { const message = 'Target Size In Base Asset cannot be zero. Fix this please.' badDefinitionUnhandledException(undefined, message, tradingSystemStageNode.initialTargets.targetSizeInBaseAsset.formula) } @@ -222,7 +222,7 @@ exports.newTradingPosition = function newTradingPosition(bot, logger, tradingEng const message = 'Target Size In Quoted Asset cannot be undefined. Fix this please.' badDefinitionUnhandledException(undefined, message, tradingSystemStageNode.initialTargets.targetSizeInQuotedAsset.formula) } - if (value === undefined) { + if (value === 0) { const message = 'Target Size In Quoted Asset cannot be zero. Fix this please.' badDefinitionUnhandledException(undefined, message, tradingSystemStageNode.initialTargets.targetSizeInQuotedAsset.formula) } @@ -244,8 +244,8 @@ exports.newTradingPosition = function newTradingPosition(bot, logger, tradingEng /* Remember how the end user defined this stage. */ tradingEngineStageNode.stageDefinedIn.value = 'Quoted Asset' } else { - const errorText = 'You need to specify a Formula for this.' - badDefinitionUnhandledException(undefined, message, tradingSystemStageNode.initialTargets.targetSizeInQuotedAsset.formula) + const message = 'You need to specify a Formula for this.' + badDefinitionUnhandledException(undefined, message, tradingSystemStageNode.initialTargets.targetSizeInQuotedAsset) } } } diff --git a/LowFrequencyTrading/TradingSystem.js b/LowFrequencyTrading/TradingSystem.js index d90c558ae..2e3af7ee3 100644 --- a/LowFrequencyTrading/TradingSystem.js +++ b/LowFrequencyTrading/TradingSystem.js @@ -310,6 +310,7 @@ exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineM if (error !== undefined) { tradingSystem.errors.push([node.id, error]) + logger.write(MODULE_NAME, '[INFO] evalFormula -> error = ' + error) return } if (value !== undefined) { @@ -323,7 +324,6 @@ exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineM } logger.write(MODULE_NAME, '[INFO] evalFormula -> value = ' + value) - logger.write(MODULE_NAME, '[INFO] evalFormula -> error = ' + error) } } diff --git a/MultiPeriodDaily.js b/MultiPeriodDaily.js index cdc4a892b..68527a72f 100644 --- a/MultiPeriodDaily.js +++ b/MultiPeriodDaily.js @@ -67,7 +67,6 @@ function getContextVariables() { try { let thisReport; - let reportKey; let statusReport; /* We look first for the bot who knows the begining of the market in order to get when the market starts. @@ -89,7 +88,7 @@ thisReport = statusReport.file; if (thisReport.beginingOfMarket === undefined) { - logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Undefined Last File. -> reportKey = " + reportKey) + logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Undefined Last File. -> thisReport.beginingOfMarket === undefined ") logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> It is too early too run this process since the trade history of the market is not there yet.") let customOK = { @@ -122,7 +121,7 @@ thisReport = statusReport.file; if (thisReport.lastFile === undefined) { - logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Undefined Last File. -> reportKey = " + reportKey) + logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Undefined Last File. -> thisReport.lastFile === undefined") let customOK = { result: global.CUSTOM_OK_RESPONSE.result, @@ -157,7 +156,7 @@ beginingOfMarket = new Date(thisReport.beginingOfMarket) if (beginingOfMarket.valueOf() !== contextVariables.dateBeginOfMarket.valueOf()) { // Reset Mechanism for Begining of the Market - logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Reset Mechanism for Begining of the Market Activated. -> reportKey = " + reportKey) + logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Reset Mechanism for Begining of the Market Activated.") beginingOfMarket = new Date(contextVariables.dateBeginOfMarket.valueOf()) startFromBegining() diff --git a/ProcessExecutionEvents.js b/ProcessExecutionEvents.js index 9b94c0365..ae74beee2 100644 --- a/ProcessExecutionEvents.js +++ b/ProcessExecutionEvents.js @@ -11,7 +11,7 @@ let thisObject = { networkNode: undefined, - initialize, initialize, + initialize: initialize, finalize: finalize, start: start, finish: finish diff --git a/ProcessOutput.js b/ProcessOutput.js index 9f6f0ee71..6075ee9e7 100644 --- a/ProcessOutput.js +++ b/ProcessOutput.js @@ -86,7 +86,7 @@ let product = outputDataset.referenceParent.parentNode.config.codeName let dataset = outputDataset.referenceParent.config.codeName - key = dataMine + "-" + botName + "-" + product + "-" + dataset + "-" + bot.exchange + "-" + bot.market.baseAsset + '/' + bot.market.quotedAsset + let key = dataMine + "-" + botName + "-" + product + "-" + dataset + "-" + bot.exchange + "-" + bot.market.baseAsset + '/' + bot.market.quotedAsset let event = { lastFile: lastFile, timeFrames: timeFrames @@ -165,7 +165,7 @@ let product = outputDataset.referenceParent.parentNode.config.codeName let dataset = outputDataset.referenceParent.config.codeName - key = dataMine + "-" + botName + "-" + product + "-" + dataset + "-" + bot.exchange + "-" + bot.market.baseAsset + '/' + bot.market.quotedAsset + let key = dataMine + "-" + botName + "-" + product + "-" + dataset + "-" + bot.exchange + "-" + bot.market.baseAsset + '/' + bot.market.quotedAsset let event = { lastFile: lastFile, timeFrames: timeFrames diff --git a/SensorBot.js b/SensorBot.js index 13e5c251d..e4c1f6a70 100644 --- a/SensorBot.js +++ b/SensorBot.js @@ -63,7 +63,7 @@ function onCommonsDownloaded(err, text) { if (err.result !== global.DEFAULT_OK_RESPONSE.result) { - parentLogger.write(MODULE_NAME, "[WARN] initialize -> onBotDownloaded -> onCommonsDownloaded -> Commons not found: " + err.code || err.message); + parentLogger.write(MODULE_NAME, "[WARN] initialize -> onBotDownloaded -> onCommonsDownloaded -> Commons not found: " + err.message); callBackFunction(global.DEFAULT_OK_RESPONSE); return; } diff --git a/Session.js b/Session.js index 9b8c82b67..582500864 100644 --- a/Session.js +++ b/Session.js @@ -322,7 +322,7 @@ /* Slippage */ if (bot.SESSION.parameters.slippage === undefined) { // if the Slippage is missing we create a default one. - bot.SESSION.parameters.timeRange = { + bot.SESSION.parameters.slippage = { name: 'Missing Slippage', type: 'Slippage', config: { diff --git a/TradingBot.js b/TradingBot.js index 9d4d48ee7..4e0f2b6fb 100644 --- a/TradingBot.js +++ b/TradingBot.js @@ -251,7 +251,6 @@ global.unexpectedError = err.message processStopped() return - return; } default: { logger.write(MODULE_NAME, "[ERROR] run -> loop -> initializeStatusDependencies -> onInizialized -> Unhandled err.result received. -> err.result = " + err.result); diff --git a/server.js b/server.js index 5ec84ec11..1fd442a8b 100644 --- a/server.js +++ b/server.js @@ -381,7 +381,7 @@ global.EXIT_NODE_PROCESS = function exitProcess() { let config = global.TASK_NODE.bot.processes[i].config let process = global.TASK_NODE.bot.processes[i] - key = process.name + '-' + process.type + '-' + process.id + let key = process.name + '-' + process.type + '-' + process.id global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Stopped') // Meaning Process Stopped } }