diff --git a/Commons.js b/Commons.js index 6b850d879..aaf3d3dcf 100644 --- a/Commons.js +++ b/Commons.js @@ -480,7 +480,7 @@ let filePath = filePathRoot + "/Output/" + contextSummary.product + "/" + contextSummary.dataset + "/" + timeFrameLabel + dateForPath; filePath += '/' + fileName - fileStorage.createTextFile(contextSummary.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { diff --git a/Context.js b/Context.js index deb8305db..bc347977b 100644 --- a/Context.js +++ b/Context.js @@ -168,7 +168,7 @@ let fileName = "Execution.History." + bot.startMode + "." + runIndex + ".json"; let filePath = bot.filePathRoot + "/Output/" + sessionPath + "Trading-Process/" + fileName; - fileStorage.getTextFile(bot.dataMine, filePath, onFileReceived); + fileStorage.getTextFile(filePath, onFileReceived); function onFileReceived(err, text) { @@ -229,7 +229,7 @@ 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/" + sessionPath + "Trading-Process/" + dateForPath + fileName; - fileStorage.getTextFile(bot.dataMine, filePath, onFileReceived); + fileStorage.getTextFile(filePath, onFileReceived); function onFileReceived(err, text) { @@ -411,7 +411,7 @@ if (global.LOG_CONTROL[MODULE_NAME].logContent === true) { logger.write(MODULE_NAME, "[INFO] saveThemAll -> writeExecutionContext -> fileContent = " + fileContent); } - fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -472,7 +472,7 @@ let fileContent = JSON.stringify(thisObject.executionHistory); - fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -494,7 +494,7 @@ fileName = "Execution.History." + bot.startMode + "." + "Sequence" + ".json"; filePath = bot.filePathRoot + "/Output/" + sessionPath + "Trading-Process/" + fileName; - fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onSequenceFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onSequenceFileCreated); function onSequenceFileCreated(err) { diff --git a/DataSet.js b/DataSet.js index 5110f2301..4ecbbb6b3 100644 --- a/DataSet.js +++ b/DataSet.js @@ -108,7 +108,7 @@ exports.newDataSet = function newDataSet(BOT, logger) { let filePath = filePathRoot + "/Output/" + pFolderPath; filePath += '/' + pFileName - fileStorage.getTextFile(dataDependencyNode.dataMine, filePath, onFileReceived); + fileStorage.getTextFile(filePath, onFileReceived); function onFileReceived(err, text) { @@ -149,7 +149,7 @@ exports.newDataSet = function newDataSet(BOT, logger) { let filePathRoot = dataDependencyNode.dataMine + "/" + dataDependencyNode.bot + "/" + bot.exchange; let filePath = filePathRoot + "/Output/" + pFolderPath + '/' + pFileName; - fileStorage.createTextFile(dataDependencyNode.dataMine, filePath, pFileContent, onFileCreated); + fileStorage.createTextFile(filePath, pFileContent, onFileCreated); function onFileCreated(err) { diff --git a/DebugLog.js b/DebugLog.js index 22be40b3a..ebc3e6d39 100644 --- a/DebugLog.js +++ b/DebugLog.js @@ -92,22 +92,22 @@ exports.newDebugLog = function newDebugLog() { let fileToDelete = thisObject.bot.LOGS_TO_DELETE_QUEUE[0] thisObject.bot.LOGS_TO_DELETE_QUEUE.splice(0, 1) /* Will delete this file only if it does not contains ERROR inside. */ - let fileContent = fileStorage.getTextFile(thisObject.bot.dataMine, fileToDelete, onGetFile, true) + let fileContent = fileStorage.getTextFile(fileToDelete, onGetFile, true) function onGetFile(err, fileContent) { if (err.result === global.DEFAULT_OK_RESPONSE.result) { if (fileContent.indexOf("ERROR") < 0) { /* Logs will only be deleted when they contain no ERROR in them. */ - fileStorage.deleteTextFile(thisObject.bot.dataMine, fileToDelete); + fileStorage.deleteTextFile(fileToDelete); } } else { - fileStorage.deleteTextFile(thisObject.bot.dataMine, fileToDelete); + fileStorage.deleteTextFile(fileToDelete); } } } function writeLog() { - fileStorage.createTextFile(thisObject.bot.dataMine, filePath + '/' + fileName, contentToPersist + '\r\n' + "]", onFileCreated); + fileStorage.createTextFile(filePath + '/' + fileName, contentToPersist + '\r\n' + "]", onFileCreated); function onFileCreated(err) { if (err.result !== global.DEFAULT_OK_RESPONSE.result) { console.log("[ERROR] DebugLog -> persist -> onInizialized -> onFileCreated -> err = "+ err.message); diff --git a/FileStorage.js b/FileStorage.js index ee784f5fa..8bca500eb 100644 --- a/FileStorage.js +++ b/FileStorage.js @@ -25,20 +25,18 @@ exports.newFileStorage = function newFileStorage(logger) { return thisObject - function getTextFile(container, filePath, callBackFunction, noRetry) { + function getTextFile(filePath, callBackFunction, noRetry) { logger.write(MODULE_NAME, '[INFO] FileStorage -> getTextFile -> Entering Function.') let fileDoesNotExist = false - container = container.toLowerCase() - /* Choose path for either bots or data */ let fileLocation if (filePath.indexOf("/bots/") > 0) { - fileLocation = process.env.BOTS_PATH + '/' + container + '/' + filePath + fileLocation = process.env.BOTS_PATH + '/' + filePath } else { - fileLocation = process.env.STORAGE_PATH + '/' + container + '/' + filePath + fileLocation = process.env.STORAGE_PATH + '/' + filePath } try { @@ -71,7 +69,6 @@ exports.newFileStorage = function newFileStorage(logger) { } logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> onFileRead -> Error reading file -> err = ' + err.stack) - logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> onFileRead -> Error reading file -> container = ' + container) logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> onFileRead -> Error reading file -> filePath = ' + filePath) logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> onFileRead -> Error reading file -> err = ' + err.stack) setTimeout(retry, RETRY_TIME_IN_MILISECONDS) @@ -97,7 +94,7 @@ exports.newFileStorage = function newFileStorage(logger) { if (currentRetryGetTextFile < MAX_RETRY) { currentRetryGetTextFile++ logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> retry -> Will try to read the file again -> Retry #: ' + currentRetryGetTextFile) - getTextFile(container, filePath, callBackFunction) + getTextFile(filePath, callBackFunction) } else { currentRetryGetTextFile = 0 @@ -119,18 +116,16 @@ exports.newFileStorage = function newFileStorage(logger) { } } - function createTextFile(container, filePath, fileContent, callBackFunction) { + function createTextFile(filePath, fileContent, callBackFunction) { logger.write(MODULE_NAME, '[INFO] FileStorage -> createTextFile -> Entering Function.') - container = container.toLowerCase() - /* Choose path for either logs or data */ let fileLocation if (filePath.indexOf("/Logs/") > 0) { - fileLocation = process.env.LOG_PATH + '/' + container + '/' + filePath + fileLocation = process.env.LOG_PATH + '/' + filePath } else { - fileLocation = process.env.STORAGE_PATH + '/' + container + '/' + filePath + fileLocation = process.env.STORAGE_PATH + '/' + filePath } try { @@ -198,7 +193,7 @@ exports.newFileStorage = function newFileStorage(logger) { if (currentRetryWriteTextFile < MAX_RETRY) { currentRetryWriteTextFile++ logger.write(MODULE_NAME, '[WARN] FileStorage -> createTextFile -> retry -> Will try to write the file again -> Retry #: ' + currentRetryWriteTextFile) - createTextFile(container, filePath, fileContent, callBackFunction) + createTextFile(filePath, fileContent, callBackFunction) } else { currentRetryWriteTextFile = 0 logger.write(MODULE_NAME, '[ERROR] FileStorage -> createTextFile -> retry -> Max retries reached writting a file. Giving up.') @@ -208,18 +203,16 @@ exports.newFileStorage = function newFileStorage(logger) { } } - function deleteTextFile(container, filePath, callBackFunction) { + function deleteTextFile(filePath, callBackFunction) { logger.write(MODULE_NAME, '[INFO] FileStorage -> deleteTextFile -> Entering Function.') - container = container.toLowerCase() - /* Choose path for either logs or data */ let fileLocation if (filePath.indexOf("/Logs/") > 0) { - fileLocation = process.env.LOG_PATH + '/' + container + '/' + filePath + fileLocation = process.env.LOG_PATH + '/' + filePath } else { - fileLocation = process.env.STORAGE_PATH + '/' + container + '/' + filePath + fileLocation = process.env.STORAGE_PATH + '/' + filePath } try { @@ -252,7 +245,7 @@ exports.newFileStorage = function newFileStorage(logger) { if (currentRetryWriteTextFile < MAX_RETRY) { currentRetryWriteTextFile++ logger.write(MODULE_NAME, '[WARN] FileStorage -> createTextFile -> retry -> Will try to write the file again -> Retry #: ' + currentRetryWriteTextFile) - createTextFile(container, filePath, fileContent, callBackFunction) + createTextFile(filePath, fileContent, callBackFunction) } else { currentRetryWriteTextFile = 0 logger.write(MODULE_NAME, '[ERROR] FileStorage -> createTextFile -> retry -> Max retries reached writting a file. Giving up.') diff --git a/IndicatorBotProcessMainLoop.js b/IndicatorBotProcessMainLoop.js index 39e613201..0e46ea1e7 100644 --- a/IndicatorBotProcessMainLoop.js +++ b/IndicatorBotProcessMainLoop.js @@ -46,7 +46,7 @@ let filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.codeName filePath += "/User.Bot.js" - fileStorage.getTextFile(bot.dataMine, filePath, onBotDownloaded); + fileStorage.getTextFile(filePath, onBotDownloaded); function onBotDownloaded(err, text) { @@ -64,7 +64,7 @@ filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo; filePath += "/Commons.js" - fileStorage.getTextFile(bot.dataMine, filePath, onCommonsDownloaded); + fileStorage.getTextFile(filePath, onCommonsDownloaded); function onCommonsDownloaded(err, text) { diff --git a/MultiPeriod.js b/MultiPeriod.js index 4db5534d0..62141ce01 100644 --- a/MultiPeriod.js +++ b/MultiPeriod.js @@ -995,7 +995,7 @@ let fileName = '/Data.Range.' + market.baseAsset + '_' + market.quotedAsset + '.json'; let filePath = bot.filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + productCodeName + "/" + 'Multi-Period-Daily' + fileName; - fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { diff --git a/MultiPeriodDaily.js b/MultiPeriodDaily.js index 505dd2247..b50e975c0 100644 --- a/MultiPeriodDaily.js +++ b/MultiPeriodDaily.js @@ -729,7 +729,7 @@ let fileName = '/Data.Range.' + market.baseAsset + '_' + market.quotedAsset + '.json'; let filePath = bot.filePathRoot + "/Output/" + productCodeName + "/" + bot.process + fileName; - fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { diff --git a/Root.js b/Root.js index 68f372a6e..9e9019f79 100644 --- a/Root.js +++ b/Root.js @@ -166,7 +166,7 @@ let filePath = global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.code.codeName + '/bots/' + global.TASK_NODE.bot.code.repo + '/this.bot.config.json'; - fileStorage.getTextFile(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.code.codeName, filePath, onFileReceived); + fileStorage.getTextFile(filePath, onFileReceived); function onFileReceived(err, text) { diff --git a/SensorBotProcessMainLoop.js b/SensorBotProcessMainLoop.js index e63b2c6cf..98053dbb7 100644 --- a/SensorBotProcessMainLoop.js +++ b/SensorBotProcessMainLoop.js @@ -44,7 +44,7 @@ let filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.codeName filePath += "/User.Bot.js" - fileStorage.getTextFile(bot.dataMine, filePath, onBotDownloaded); + fileStorage.getTextFile(filePath, onBotDownloaded); function onBotDownloaded(err, text) { @@ -69,7 +69,7 @@ filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo; filePath += "/Commons.js" - fileStorage.getTextFile(bot.dataMine, filePath, onCommonsDownloaded); + fileStorage.getTextFile(filePath, onCommonsDownloaded); function onCommonsDownloaded(err, text) { diff --git a/StatusReport.js b/StatusReport.js index 90de88b4d..89ff5dca7 100644 --- a/StatusReport.js +++ b/StatusReport.js @@ -163,7 +163,7 @@ filePath += '/' + fileName - fileStorage.getTextFile(statusDependencyNode.dataMine, filePath, onFileReceived); + fileStorage.getTextFile(filePath, onFileReceived); function onFileReceived(err, text) { @@ -251,7 +251,7 @@ filePath += '/' + fileName let fileContent = JSON.stringify(thisObject.file); - fileStorage.createTextFile(statusDependencyNode.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { diff --git a/TradingBot.js b/TradingBot.js index 357e6bc93..e969a90fc 100644 --- a/TradingBot.js +++ b/TradingBot.js @@ -225,7 +225,7 @@ let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + SIMULATED_RECORDS_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + timeFrameLabel; filePath += '/' + fileName - fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -303,7 +303,7 @@ let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + CONDITIONS_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + timeFrameLabel; filePath += '/' + fileName - fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -373,7 +373,7 @@ let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + STRATEGIES_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + timeFrameLabel; filePath += '/' + fileName - fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -446,7 +446,7 @@ let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + TRADES_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + timeFrameLabel; filePath += '/' + fileName - fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -572,7 +572,7 @@ let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + SIMULATED_RECORDS_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + timeFrameLabel; filePath += '/' + fileName - fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -679,7 +679,7 @@ let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + SIMULATED_RECORDS_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + timeFrameLabel + "/" + dateForPath; filePath += '/' + fileName - fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -767,7 +767,7 @@ let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + CONDITIONS_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + timeFrameLabel + "/" + dateForPath; filePath += '/' + fileName - fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -844,7 +844,7 @@ let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + STRATEGIES_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + timeFrameLabel + "/" + dateForPath; filePath += '/' + fileName - fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -924,7 +924,7 @@ let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + TRADES_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + timeFrameLabel + "/" + dateForPath; filePath += '/' + fileName - fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { diff --git a/TradingBotProcessMainLoop.js b/TradingBotProcessMainLoop.js index 0db6a9df3..7f7124abe 100644 --- a/TradingBotProcessMainLoop.js +++ b/TradingBotProcessMainLoop.js @@ -56,7 +56,7 @@ let filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.codeName filePath += "/User.Bot.js" - fileStorage.getTextFile(bot.dataMine, filePath, onBotDownloaded); + fileStorage.getTextFile(filePath, onBotDownloaded); function onBotDownloaded(err, text) { @@ -75,7 +75,7 @@ filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo; filePath += "/Commons.js" - fileStorage.getTextFile(bot.dataMine, filePath, onCommonsDownloaded); + fileStorage.getTextFile(filePath, onCommonsDownloaded); function onCommonsDownloaded(err, text) {