diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index b8a398593..e7b6078e2 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -331,6 +331,12 @@ "propertyName": "timeFrames", "functionName": "newSuperalgosGlobalsTimeFrames", "fileName": "TimeFrames.js" + }, + { + "name": "Standard Responses", + "propertyName": "standardResponses", + "functionName": "newSuperalgosGlobalsStandardResponses", + "fileName": "StandardResponses.js" } ], "functionLibraries": [], diff --git a/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Daily/User.Bot.js b/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Daily/User.Bot.js index 7b9f87388..0c6919b2f 100644 --- a/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Daily/User.Bot.js +++ b/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Daily/User.Bot.js @@ -39,11 +39,11 @@ statusDependencies = pStatusDependencies; - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -95,13 +95,13 @@ if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } @@ -112,7 +112,7 @@ 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 = { - result: global.CUSTOM_OK_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result, message: "Dependency does not exist." } logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> customOK = " + customOK.message); @@ -131,13 +131,13 @@ if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } @@ -147,7 +147,7 @@ logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Undefined Last File. -> reportKey = " + reportKey); let customOK = { - result: global.CUSTOM_OK_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result, message: "Dependency not ready." } logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> customOK = " + customOK.message); @@ -166,13 +166,13 @@ if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because self dependecy Status Report is corrupt. Aborting Process."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return; } @@ -235,7 +235,7 @@ logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Check the bot configuration to see if all of its statusDependencies declarations are correct. "); logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Dependencies loaded -> keys = " + JSON.stringify(statusDependencies.keys)); } - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -273,7 +273,7 @@ const logText = "Head of the market found @ " + previousDay.getUTCFullYear() + "/" + (previousDay.getUTCMonth() + 1) + "/" + previousDay.getUTCDate() + "."; if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildBands -> advanceTime -> " + logText); } - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return; } @@ -291,7 +291,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> advanceTime -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -313,7 +313,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -323,7 +323,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildBands -> loopBody -> Entering function."); } - const timeFrame = global.dailyFilePeriods[n][1]; + const timeFrame = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1]; let candles = []; // Here we will put all the candles of the 2 files read. @@ -361,13 +361,13 @@ logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> loopBody -> getPreviousDayFile -> onCurrentDayFileReceived -> filePath = " + filePath); logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> loopBody -> getPreviousDayFile -> onCurrentDayFileReceived -> market = " + market.baseAsset + '_' + market.quotedAsset); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> loopBody -> getPreviousDayFile -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -408,7 +408,7 @@ logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> loopBody -> getProcessDayFile -> onCurrentDayFileReceived -> filePath = " + filePath); logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> loopBody -> getProcessDayFile -> onCurrentDayFileReceived -> market = " + market.baseAsset + '_' + market.quotedAsset); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } } @@ -416,7 +416,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> loopBody -> getProcessDayFile -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -466,14 +466,14 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> loopBody -> buildBands -> addCandlesToSingleArray -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return; } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> loopBody -> buildBands -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return; } } @@ -571,7 +571,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> loopBody -> calculateBands -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return; } } @@ -623,7 +623,7 @@ logger.write(MODULE_NAME, "[INFO] start -> buildBands -> loopBody -> writeBandBandsFile -> writeBandsFile -> onFileCreated -> Content written = " + fileContent); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> writeBandBandsFile -> writeBandsFile -> onFileCreated -> err = " + err.stack); callBackFunction(err); return; @@ -636,13 +636,13 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> loopBody -> writeBandBandsFile -> writeBandsFile -> onFileCreated -> err = " + err.stack); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> loopBody -> writeBandBandsFile -> writeBandsFile -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -693,7 +693,7 @@ logger.write(MODULE_NAME, "[INFO] start -> buildBands -> loopBody -> writeBandBandsFile -> writePBFile -> onFileCreated -> Content written = " + fileContent); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> writeBandBandsFile -> writePBFile -> onFileCreated -> err = " + err.stack); callBackFunction(err); return; @@ -706,20 +706,20 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> loopBody -> writeBandBandsFile -> writePBFile -> onFileCreated -> err = " + err.stack); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> loopBody -> writeBandBandsFile -> writePBFile -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> loopBody -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -731,7 +731,7 @@ n++; - if (n < global.dailyFilePeriods.length) { + if (n < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length) { loopBody(); @@ -747,7 +747,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildBands -> controlLoop -> onWritten -> Entering function."); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> controlLoop -> onWritten -> err = " + err.stack); callBackFunction(err); return; @@ -757,21 +757,21 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> controlLoop -> onWritten -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> controlLoop -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> err.message = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -787,7 +787,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeDataRanges -> Entering function."); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] writeDataRanges -> writeDataRanges -> onBandsBandsDataRangeWritten -> err = " + err.stack); callBack(err); return; @@ -799,13 +799,13 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeDataRanges -> Entering function."); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] writeDataRanges -> writeDataRanges -> onBandsBandsDataRangeWritten -> onPercentageBandwidthDataRangeWritten -> err = " + err.stack); callBack(err); return; } - callBack(global.DEFAULT_OK_RESPONSE); + callBack(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } @@ -813,7 +813,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeDataRanges -> err = " + err.stack); - callBack(global.DEFAULT_FAIL_RESPONSE); + callBack(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -842,7 +842,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeDataRange -> onFileCreated -> Entering function."); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> writeDataRange -> onFileCreated -> err = " + err.stack); callBack(err); return; @@ -852,12 +852,12 @@ logger.write(MODULE_NAME, "[INFO] start -> writeDataRange -> onFileCreated -> Content written = " + fileContent); } - callBack(global.DEFAULT_OK_RESPONSE); + callBack(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeDataRange -> err = " + err.stack); - callBack(global.DEFAULT_FAIL_RESPONSE); + callBack(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -879,13 +879,13 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeStatusReport -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> err.message = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } }; diff --git a/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Market/User.Bot.js b/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Market/User.Bot.js index 2c9cad690..930462866 100644 --- a/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Market/User.Bot.js +++ b/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Market/User.Bot.js @@ -33,11 +33,11 @@ statusDependencies = pStatusDependencies; - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -88,7 +88,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> periodsLoop -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -98,8 +98,8 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildBands -> loopBody -> Entering function."); } - const outputPeriod = global.marketFilesPeriods[n][0]; - const timeFrame = global.marketFilesPeriods[n][1]; + const outputPeriod = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0]; + const timeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1]; nextCandleFile(); @@ -124,7 +124,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> Entering function."); } if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> text = " + text); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> err = " + err.stack); callBackFunction(err); @@ -174,7 +174,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> buildCandles -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -265,7 +265,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> buildBands -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -312,7 +312,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> writeBandsFile -> onFileCreated -> Entering function."); } if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> writeBandsFile -> onFileCreated -> fileContent = " + fileContent); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> writeBandsFile -> onFileCreated -> err = " + err.stack); logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> writeBandsFile -> onFileCreated -> filePath = " + filePath); @@ -328,13 +328,13 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> writeBandsFile -> onFileCreated -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> writeBandsFile -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -382,7 +382,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> writePBFile -> onFileCreated -> Entering function."); } if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> writePBFile -> onFileCreated -> fileContent = " + fileContent); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> writePBFile -> onFileCreated -> err = " + err.stack); logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> writePBFile -> onFileCreated -> filePath = " + filePath); @@ -398,33 +398,33 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> writePBFile -> onFileCreated -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> writePBFile -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> nextCandleFile -> onFileReceived -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> nextCandleFile -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> loopBody -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -436,7 +436,7 @@ n++; - if (n < global.marketFilesPeriods.length) { + if (n < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length) { loopBody(); @@ -448,14 +448,14 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> controlLoop -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildBands -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -483,13 +483,13 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeStatusReport -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } }; diff --git a/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Daily/User.Bot.js b/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Daily/User.Bot.js index 8b484ff31..c03521d77 100644 --- a/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Daily/User.Bot.js +++ b/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Daily/User.Bot.js @@ -41,11 +41,11 @@ statusDependencies = pStatusDependencies; - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -94,13 +94,13 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } @@ -111,7 +111,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each 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 = { - result: global.CUSTOM_OK_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result, message: "Dependency does not exist." } logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> customOK = " + customOK.message); @@ -130,13 +130,13 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } @@ -146,7 +146,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Undefined Last File. -> reportKey = " + reportKey); let customOK = { - result: global.CUSTOM_OK_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result, message: "Dependency not ready." } logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> customOK = " + customOK.message); @@ -165,13 +165,13 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because self dependecy Status Report is corrupt. Aborting Process."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return; } @@ -222,7 +222,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Check the bot configuration to see if all of its statusDependencies declarations are correct. "); logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Dependencies loaded -> keys = " + JSON.stringify(statusDependencies.keys)); } - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -252,7 +252,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildCandles -> advanceTime -> Head of the market found @ " + contextVariables.lastCandleFile.getUTCFullYear() + "/" + (contextVariables.lastCandleFile.getUTCMonth() + 1) + "/" + contextVariables.lastCandleFile.getUTCDate() + "."); } - callBackFunction(global.DEFAULT_OK_RESPONSE); // Here is where we finish processing and wait for the platform to run this module again. + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); // Here is where we finish processing and wait for the platform to run this module again. return; } @@ -274,7 +274,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each outputCandles = []; outputVolumes = []; - for (let n = 0; n < global.dailyFilePeriods.length; n++) { + for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; n++) { const emptyArray1 = []; const emptyArray2 = []; @@ -304,8 +304,8 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildCandles -> periodsLoop -> loopBody -> Entering function."); } - const outputPeriod = global.dailyFilePeriods[n][0]; - const timeFrame = global.dailyFilePeriods[n][1]; + const outputPeriod = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][0]; + const timeFrame = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1]; nextCandleFile(); @@ -333,14 +333,14 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each let candlesFile; - if (err.result === global.DEFAULT_OK_RESPONSE.result) { + if (err.result === TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { try { candlesFile = JSON.parse(text); } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildCandles -> periodsLoop -> loopBody -> nextCandleFile -> onFileReceived -> Error Parsing JSON -> err = " + err.stack); logger.write(MODULE_NAME, "[ERROR] start -> buildCandles -> periodsLoop -> loopBody -> nextCandleFile -> onFileReceived -> Asuming this is a temporary situation. Requesting a Retry."); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } } else { @@ -349,7 +349,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each logger.write(MODULE_NAME, "[WARN] start -> buildCandles -> periodsLoop -> loopBody -> nextCandleFile -> onFileReceived -> Dependency Not Ready -> err = " + err.stack); logger.write(MODULE_NAME, "[WARN] start -> buildCandles -> periodsLoop -> loopBody -> nextCandleFile -> onFileReceived -> Asuming this is a temporary situation. Requesting a Retry."); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } else { @@ -429,7 +429,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildCandles -> periodsLoop -> loopBody -> nextCandleFile -> onFileReceived -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } @@ -458,14 +458,14 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each let volumesFile; - if (err.result === global.DEFAULT_OK_RESPONSE.result) { + if (err.result === TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { try { volumesFile = JSON.parse(text); } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildCandles -> periodsLoop -> loopBody -> nextVolumeFile -> onFileReceived -> Error Parsing JSON -> err = " + err.stack); logger.write(MODULE_NAME, "[ERROR] start -> buildCandles -> periodsLoop -> loopBody -> nextVolumeFile -> onFileReceived -> Asuming this is a temporary situation. Requesting a Retry."); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } } else { @@ -527,7 +527,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildCandles -> periodsLoop -> loopBody -> nextVolumeFile -> onFileReceived -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } @@ -538,7 +538,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each n++; - if (n < global.dailyFilePeriods.length) { + if (n < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length) { loopBody(); @@ -550,7 +550,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildCandles -> periodsLoop -> controlLoop -> onWritten -> Entering function."); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] writeDataRanges -> writeDataRanges -> onCandlesDataRangeWritten -> err = " + err.stack); callBack(err); return; @@ -565,7 +565,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildCandles -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -618,7 +618,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeFiles -> writeCandles -> onFileCreated -> Entering function."); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> writeFiles -> writeCandles -> onFileCreated -> err = " + err.stack); callBackFunction(err); return; @@ -669,7 +669,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeFiles -> writeVolumes -> onFileCreated -> Entering function."); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> writeFiles -> writeVolumes -> onFileCreated -> err = " + err.stack); callBackFunction(err); return; @@ -687,7 +687,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeFiles -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -703,7 +703,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeDataRanges -> Entering function."); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] writeDataRanges -> writeDataRanges -> onCandlesDataRangeWritten -> err = " + err.stack); callBack(err); return; @@ -715,19 +715,19 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] writeDataRanges -> writeDataRanges -> onVolumeDataRangeWritten -> Entering function."); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] writeDataRanges -> writeDataRanges -> onVolumeDataRangeWritten -> err = " + err.stack); callBack(err); return; } - callBack(global.DEFAULT_OK_RESPONSE); + callBack(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeDataRanges -> err = " + err.stack); - callBack(global.DEFAULT_FAIL_RESPONSE); + callBack(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -755,7 +755,7 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeDataRange -> onFileCreated -> Entering function."); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> writeDataRange -> onFileCreated -> err = " + err.stack); callBack(err); return; @@ -772,12 +772,12 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Data Range Updated', event) - callBack(global.DEFAULT_OK_RESPONSE); + callBack(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeDataRange -> err = " + err.stack); - callBack(global.DEFAULT_FAIL_RESPONSE); + callBack(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -799,14 +799,14 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeStatusReport -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] 'Start' - ERROR : " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } }; diff --git a/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Market/User.Bot.js b/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Market/User.Bot.js index 5b2621dbe..cd4a18117 100644 --- a/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Market/User.Bot.js +++ b/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Market/User.Bot.js @@ -40,10 +40,10 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] initialize -> Entering function."); } statusDependencies = pStatusDependencies; - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -103,13 +103,13 @@ if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } @@ -120,7 +120,7 @@ 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 = { - result: global.CUSTOM_OK_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result, message: "Dependency does not exist." } logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> customOK = " + customOK.message); @@ -139,13 +139,13 @@ if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } @@ -155,7 +155,7 @@ logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Undefined Last File. -> reportKey = " + reportKey); let customOK = { - result: global.CUSTOM_OK_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result, message: "Dependency not ready." } logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> customOK = " + customOK.message); @@ -174,13 +174,13 @@ if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because self dependecy Status Report is corrupt. Aborting Process."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return; } @@ -232,7 +232,7 @@ logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Dependencies loaded -> keys = " + JSON.stringify(statusDependencies.keys)); logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Dependencies loaded -> Double check that you are not running a process that only can be run at noTime mode at a certain month when it is not prepared to do so."); } - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -258,7 +258,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findPreviousContent -> loopBody -> Entering function."); } - let timeFrame = global.marketFilesPeriods[n][1]; + let timeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1]; if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findPreviousContent -> loopBody -> timeFrame = " + timeFrame); } let previousCandles; @@ -285,7 +285,7 @@ let candlesFile; - if (err.result === global.DEFAULT_OK_RESPONSE.result) { + if (err.result === TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { try { candlesFile = JSON.parse(text); @@ -298,7 +298,7 @@ logger.write(MODULE_NAME, "[ERROR] start -> findPreviousContent -> loopBody -> getCandles -> onFileReceived -> filePath = " + filePath); logger.write(MODULE_NAME, "[ERROR] start -> findPreviousContent -> loopBody -> getCandles -> onFileReceived -> err = " + err.stack); logger.write(MODULE_NAME, "[ERROR] start -> findPreviousContent -> loopBody -> getCandles -> onFileReceived -> Asuming this is a temporary situation. Requesting a Retry."); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); } } else { logger.write(MODULE_NAME, "[ERROR] start -> findPreviousContent -> loopBody -> getCandles -> onFileReceived -> err = " + err.stack); @@ -326,7 +326,7 @@ let volumesFile; - if (err.result === global.DEFAULT_OK_RESPONSE.result) { + if (err.result === TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { try { volumesFile = JSON.parse(text); @@ -342,7 +342,7 @@ logger.write(MODULE_NAME, "[ERROR] start -> findPreviousContent -> loopBody -> getVolumes -> onFileReceived -> filePath = " + filePath); logger.write(MODULE_NAME, "[ERROR] start -> findPreviousContent -> loopBody -> getVolumes -> onFileReceived -> err = " + err.stack); logger.write(MODULE_NAME, "[ERROR] start -> findPreviousContent -> loopBody -> getVolumes -> onFileReceived -> Asuming this is a temporary situation. Requesting a Retry."); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); } } else { logger.write(MODULE_NAME, "[ERROR] start -> findPreviousContent -> loopBody -> getVolumes -> onFileReceived -> err = " + err.stack); @@ -359,7 +359,7 @@ n++; - if (n < global.marketFilesPeriods.length) { + if (n < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length) { loopBody(); @@ -372,7 +372,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> findPreviousContent -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -392,7 +392,7 @@ let outputCandles = []; let outputVolumes = []; - for (let n = 0; n < global.marketFilesPeriods.length; n++) { + for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; n++) { const emptyArray1 = []; const emptyArray2 = []; @@ -418,7 +418,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildCandles -> advanceTime -> Head of the market found @ " + contextVariables.lastCandleFile.getUTCFullYear() + "/" + (contextVariables.lastCandleFile.getUTCMonth() + 1) + "/" + contextVariables.lastCandleFile.getUTCDate() + "."); } - callBackFunction(global.DEFAULT_OK_RESPONSE); // Here is where we finish processing and wait for the platform to run this module again. + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); // Here is where we finish processing and wait for the platform to run this module again. return; } @@ -464,8 +464,8 @@ } - const outputPeriod = global.marketFilesPeriods[n][0]; - const timeFrame = global.marketFilesPeriods[n][1]; + const outputPeriod = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0]; + const timeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1]; /* Here we are inside a Loop that is going to advance 1 day at the time, at each pass, will ready one of Exchange Raw Data's daily files and @@ -554,14 +554,14 @@ let candlesFile; - if (err.result === global.DEFAULT_OK_RESPONSE.result) { + if (err.result === TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { try { candlesFile = JSON.parse(text); } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildCandles -> periodsLoop -> loopBody -> nextCandleFile -> onFileReceived -> Error Parsing JSON -> err = " + err.stack); logger.write(MODULE_NAME, "[ERROR] start -> buildCandles -> periodsLoop -> loopBody -> nextCandleFile -> onFileReceived -> Asuming this is a temporary situation. Requesting a Retry."); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } } else { @@ -570,7 +570,7 @@ logger.write(MODULE_NAME, "[WARN] start -> buildCandles -> periodsLoop -> loopBody -> nextCandleFile -> onFileReceived -> Dependency Not Ready -> err = " + JSON.stringify(err)); logger.write(MODULE_NAME, "[WARN] start -> buildCandles -> periodsLoop -> loopBody -> nextCandleFile -> onFileReceived -> Asuming this is a temporary situation. Requesting a Retry."); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } else { @@ -655,7 +655,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildCandles -> periodsLoop -> loopBody -> nextCandleFile -> onFileReceived -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } @@ -684,14 +684,14 @@ let volumesFile; - if (err.result === global.DEFAULT_OK_RESPONSE.result) { + if (err.result === TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { try { volumesFile = JSON.parse(text); } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildCandles -> periodsLoop -> loopBody -> nextVolumeFile -> onFileReceived -> Error Parsing JSON -> err = " + err.stack); logger.write(MODULE_NAME, "[ERROR] start -> buildCandles -> periodsLoop -> loopBody -> nextVolumeFile -> onFileReceived -> Asuming this is a temporary situation. Requesting a Retry."); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } } else { @@ -751,7 +751,7 @@ } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildCandles -> periodsLoop -> loopBody -> nextVolumeFile -> onFileReceived -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } @@ -762,7 +762,7 @@ n++; - if (n < global.marketFilesPeriods.length) { + if (n < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length) { loopBody(); @@ -775,7 +775,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> buildCandles -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -827,7 +827,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeFiles -> writeCandles -> onFileCreated -> Entering function."); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> writeFiles -> writeCandles -> onFileCreated -> err = " + err.stack); callBackFunction(err); return; @@ -877,7 +877,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeFiles -> writeVolumes -> onFileCreated -> Entering function."); } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> writeFiles -> writeVolumes -> onFileCreated -> err = " + err.stack); callBackFunction(err); return; @@ -895,7 +895,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeFiles -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -917,13 +917,13 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeStatusReport -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } }; diff --git a/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-OHLCVs/User.Bot.js b/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-OHLCVs/User.Bot.js index 69a78ef46..caabec2a7 100644 --- a/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-OHLCVs/User.Bot.js +++ b/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-OHLCVs/User.Bot.js @@ -113,7 +113,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S exchange = new exchangeClass(exchangeConstructorParams) - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); @@ -127,7 +127,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S console.log('Exchange Class ' + exchangeId) console.log(exchangeClass) - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -135,7 +135,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S try { if (global.STOP_TASK_GRACEFULLY === true) { - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return } @@ -150,7 +150,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S await getOHLCVs() if (abort === true) { return } if (global.STOP_TASK_GRACEFULLY === true) { - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return } await saveOHLCVs() @@ -166,7 +166,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S if (statusDependencies.statusReports.get(reportKey).status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } @@ -212,7 +212,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Check the bot Status Dependencies. "); logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Dependencies loaded -> keys = " + JSON.stringify(statusDependencies.keys)); } - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); abort = true } } @@ -370,7 +370,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S } logger.write(MODULE_NAME, "[ERROR] start -> getOHLCVs -> Retrying Later -> err = " + err.stack); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); abort = true return } @@ -580,7 +580,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S } function onFileCreated(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> OHLCVsReadyToBeSaved -> onFileBCreated -> err = " + JSON.stringify(err)); error = err // This allows the loop to be breaked. return; @@ -604,7 +604,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S function controlLoop() { if (global.STOP_TASK_GRACEFULLY === true) { - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return } @@ -638,7 +638,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> saveOHLCVs -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); abort = true } } @@ -672,23 +672,23 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S thisReport.save(onSaved); function onSaved(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> writeStatusReport -> onSaved -> err = " + err.stack); callBackFunction(err); return; } - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeStatusReport -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } }; diff --git a/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-Trades/User.Bot.js b/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-Trades/User.Bot.js index dfa816cf6..30e80e937 100644 --- a/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-Trades/User.Bot.js +++ b/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-Trades/User.Bot.js @@ -98,11 +98,11 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S exchange = new exchangeClass(exchangeConstructorParams) - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -110,7 +110,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S try { if (global.STOP_TASK_GRACEFULLY === true) { - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return } @@ -125,7 +125,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S await getTrades() if (abort === true) { return} if (global.STOP_TASK_GRACEFULLY === true) { - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return } await saveTrades() @@ -141,7 +141,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S if (statusDependencies.statusReports.get(reportKey).status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } @@ -184,7 +184,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Check the bot Status Dependencies. "); logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Dependencies loaded -> keys = " + JSON.stringify(statusDependencies.keys)); } - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); abort = true } } @@ -278,7 +278,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> getTrades -> Retrying Later -> err = " + err.stack); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); abort = true } } @@ -406,7 +406,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S } } function onFileCreated(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> tradesReadyToBeSaved -> onFileBCreated -> err = " + JSON.stringify(err)); error = err // This allows the loop to be breaked. return; @@ -432,7 +432,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S } function controlLoop() { if (global.STOP_TASK_GRACEFULLY === true) { - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return } @@ -446,7 +446,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> saveTrades -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); abort = true } } @@ -479,23 +479,23 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S thisReport.save(onSaved); function onSaved(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> writeStatusReport -> onSaved -> err = " + err.stack); callBackFunction(err); return; } - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeStatusReport -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } }; diff --git a/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Webhooks-Sensor-Bot/Check-Webhook/User.Bot.js b/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Webhooks-Sensor-Bot/Check-Webhook/User.Bot.js index 654ae8953..e1c1ed379 100644 --- a/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Webhooks-Sensor-Bot/Check-Webhook/User.Bot.js +++ b/Projects/Superalgos/Bots-Plotters-Code/Masters/bots/Webhooks-Sensor-Bot/Check-Webhook/User.Bot.js @@ -25,11 +25,11 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S statusDependencies = pStatusDependencies; - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -37,7 +37,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S try { if (global.STOP_TASK_GRACEFULLY === true) { - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return } @@ -56,7 +56,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S if (statusDependencies.statusReports.get(reportKey).status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return; } @@ -69,9 +69,9 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S fileStorage.getTextFile(filePath + '/' + fileName, onFileReceived); function onFileReceived(err, text) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> onFileReceived -> Could read file. -> filePath = " + filePath + "/" + fileName); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } else { fileContent = text @@ -89,7 +89,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Check the bot Status Dependencies. "); logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Dependencies loaded -> keys = " + JSON.stringify(statusDependencies.keys)); } - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); abort = true } } @@ -141,9 +141,9 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S fileStorage.createTextFile(filePath + '/' + fileName, fileContent + '\n', onFileCreated); function onFileCreated(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> saveMessages -> onResponse -> onEnd -> onFileCreated -> Could not save file. -> filePath = " + filePath + "/" + fileName); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } else { writeStatusReport() } @@ -153,7 +153,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> saveMessages -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); abort = true } } @@ -168,23 +168,23 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S thisReport.save(onSaved); function onSaved(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> writeStatusReport -> onSaved -> err = " + err.stack); callBackFunction(err); return; } - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeStatusReport -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } }; diff --git a/Projects/Superalgos/TS/Globals/StandardResponses.js b/Projects/Superalgos/TS/Globals/StandardResponses.js new file mode 100644 index 000000000..b5980e95d --- /dev/null +++ b/Projects/Superalgos/TS/Globals/StandardResponses.js @@ -0,0 +1,27 @@ +exports.newSuperalgosGlobalsStandardResponses = function () { + /* Callbacks default responses. */ + let thisObject = { + DEFAULT_OK_RESPONSE: { + result: "Ok", + message: "Operation Succeeded" + }, + DEFAULT_FAIL_RESPONSE: { + result: "Fail", + message: "Operation Failed" + }, + DEFAULT_RETRY_RESPONSE: { + result: "Retry", + message: "Retry Later" + }, + CUSTOM_OK_RESPONSE: { + result: "Ok, but check Message", + message: "Custom Message" + }, + CUSTOM_FAIL_RESPONSE: { + result: "Fail Because", + message: "Custom Message" + } + } + + return thisObject +} \ No newline at end of file diff --git a/Projects/Superalgos/TS/Globals/TimeFrames.js b/Projects/Superalgos/TS/Globals/TimeFrames.js index 28c0639ce..35ac1070c 100644 --- a/Projects/Superalgos/TS/Globals/TimeFrames.js +++ b/Projects/Superalgos/TS/Globals/TimeFrames.js @@ -5,7 +5,7 @@ exports.newSuperalgosGlobalsTimeFrames = function () { dailyFilePeriods: dailyFilePeriods } - return thisObject; + return thisObject function marketFilesPeriods() { @@ -20,7 +20,7 @@ exports.newSuperalgosGlobalsTimeFrames = function () { '[' + 2 * 60 * 60 * 1000 + ',' + '"02-hs"' + ']' + ',' + '[' + 1 * 60 * 60 * 1000 + ',' + '"01-hs"' + ']' + ']' - return JSON.parse(marketFilesPeriods); + return JSON.parse(marketFilesPeriods) } function dailyFilePeriods() { @@ -39,6 +39,6 @@ exports.newSuperalgosGlobalsTimeFrames = function () { '[' + 02 * 60 * 1000 + ',' + '"02-min"' + ']' + ',' + '[' + 01 * 60 * 1000 + ',' + '"01-min"' + ']' + ']' - return JSON.parse(dailyFilePeriods); + return JSON.parse(dailyFilePeriods) } } \ No newline at end of file diff --git a/TaskServer/CloudUtilities.js b/TaskServer/CloudUtilities.js index 42f639f92..37917ffd2 100644 --- a/TaskServer/CloudUtilities.js +++ b/TaskServer/CloudUtilities.js @@ -35,14 +35,14 @@ exports.newCloudUtilities = function newCloudUtilities(logger) { azureFileStorage.createFolder(partialPath, checkLoop); function checkLoop(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] createFolderIfNeeded -> loop -> checkLoop -> err = " + err.stack); callBackFunction(err); return; } if (i === splittedPath.length) { - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } else { loop(); } @@ -50,7 +50,7 @@ exports.newCloudUtilities = function newCloudUtilities(logger) { } } catch (err) { logger.write(MODULE_NAME, "[ERROR] createFolderIfNeeded -> Error = " + err.message); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } diff --git a/TaskServer/Commons.js b/TaskServer/Commons.js index c5929c4ae..2f1a9816b 100644 --- a/TaskServer/Commons.js +++ b/TaskServer/Commons.js @@ -25,17 +25,17 @@ /* Basic validations to see if we have everything we need. */ if (dataDependencyNode.referenceParent.parentNode.config.singularVariableName === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Product Definition without a Single Variable Name defined. Product Definition = " + JSON.stringify(dataDependencyNode.referenceParent.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (dataDependencyNode.referenceParent.parentNode.config.pluralVariableName === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Product Definition without a Plural Variable Name defined. Product Definition = " + JSON.stringify(dataDependencyNode.referenceParent.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (dataDependencyNode.referenceParent.parentNode.record === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Product Definition without a Record Definition. Product Definition = " + JSON.stringify(dataDependencyNode.referenceParent.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } } @@ -48,27 +48,27 @@ if (outputDatasetNode.referenceParent === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Output Dataset without Reference Parent. Output Dataset = " + JSON.stringify(outputDatasetNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (outputDatasetNode.referenceParent.parentNode === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Dataset not a child of a Product Definition. Dataset = " + JSON.stringify(outputDatasetNode.referenceParent)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (outputDatasetNode.referenceParent.parentNode.config.singularVariableName === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Product Definition without a Single Variable Name defined. Product Definition = " + JSON.stringify(outputDatasetNode.referenceParent.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (outputDatasetNode.referenceParent.parentNode.config.pluralVariableName === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Product Definition without a Plural Variable Name defined. Product Definition = " + JSON.stringify(outputDatasetNode.referenceParent.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (outputDatasetNode.referenceParent.parentNode.record === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Product Definition without a Record Definition. Product Definition = " + JSON.stringify(outputDatasetNode.referenceParent.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (outputDatasetNode.referenceParent.parentNode.dataBuilding === undefined) { @@ -76,19 +76,19 @@ } if (outputDatasetNode.referenceParent.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Dataset witn no codeName defined. Product Dataset = " + JSON.stringify(outputDatasetNode.referenceParent)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (outputDatasetNode.referenceParent.parentNode === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Dataset not attached to a Product Definition. Dataset = " + JSON.stringify(outputDatasetNode.referenceParent)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (outputDatasetNode.referenceParent.parentNode.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Product Definition witn no codeName defined. Product Definition = " + JSON.stringify(outputDatasetNode.referenceParent.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } @@ -101,13 +101,13 @@ } if (botNode === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Product Definition not attached to a Bot. Product Definition = "); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (botNode.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Bot witn no codeName defined."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } @@ -118,26 +118,26 @@ let learningMineNode = global.FIND_NODE_IN_NODE_MESH(outputDatasetNode, 'Learning Mine') if (learningMineNode === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Bot not attached to a Data Mine, Trading Mine or Learning Mine."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } else { if (tradingMineNode.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Learning Mine witn no codeName defined."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } } } else { if (tradingMineNode.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Trading Mine witn no codeName defined."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } } } else { if (dataMineNode.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Data Mine witn no codeName defined."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } } @@ -506,7 +506,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> generateFileContent -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -530,7 +530,7 @@ function onFileCreated(err) { try { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> writeFile -> onFileCreated -> err = " + err.stack); logger.write(MODULE_NAME, "[ERROR] start -> writeFile -> onFileCreated -> filePath = " + filePath); @@ -546,13 +546,13 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeFile -> onFileCreated -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeFile -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } } diff --git a/TaskServer/DataDependencies.js b/TaskServer/DataDependencies.js index 8df8ad724..cc392d7b1 100644 --- a/TaskServer/DataDependencies.js +++ b/TaskServer/DataDependencies.js @@ -23,7 +23,7 @@ thisObject.nodeArray = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processDependencies, 'Data Dependency') if (thisObject.nodeArray.length === 0) { logger.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible to not have data dependencies at all."); - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) return } /* @@ -35,7 +35,7 @@ } else { logger.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible not to have process dependencies, which means not data dependencies."); - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) return } @@ -43,7 +43,7 @@ // We allow old indicators not to declare their data dependencies. - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return; } @@ -80,7 +80,7 @@ function onInitilized(err, wasInitialized) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> err = " + JSON.stringify(err)); alreadyCalledBack = true; @@ -107,7 +107,7 @@ if (alreadyCalledBack === false) { alreadyCalledBack = true thisObject.nodeArray = newNodeArray - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return; } } @@ -116,7 +116,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } diff --git a/TaskServer/DataSet.js b/TaskServer/DataSet.js index 4c6c99163..76995af1b 100644 --- a/TaskServer/DataSet.js +++ b/TaskServer/DataSet.js @@ -29,7 +29,7 @@ exports.newDataSet = function newDataSet(BOT, logger) { /* 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)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } @@ -37,43 +37,43 @@ exports.newDataSet = function newDataSet(BOT, logger) { 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); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (thisObject.node.parentNode === undefined) { logger.write(MODULE_NAME, "[ERROR] initialize -> Dataset not attached to a Product Definition -> Dataset = " + JSON.stringify(thisObject.node)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (thisObject.node.parentNode.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] initialize -> Product Definition witn no codeName defined -> Product Definition = " + JSON.stringify(thisObject.node.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (thisObject.node.parentNode.parentNode === undefined) { logger.write(MODULE_NAME, "[ERROR] initialize -> Product Definition not attached to a Bot -> Product Definition = " + JSON.stringify(thisObject.node.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (thisObject.node.parentNode.parentNode.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] initialize -> Bot witn no codeName defined. Bot = " + JSON.stringify(thisObject.node.parentNode.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (thisObject.node.parentNode.parentNode.parentNode === undefined) { logger.write(MODULE_NAME, "[ERROR] initialize -> Bot not attached to a Data Mine or Trading Mine. Bot = " + JSON.stringify(thisObject.node.parentNode.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (thisObject.node.parentNode.parentNode.parentNode.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] initialize -> Data Mine witn no codeName defined. Data Mine = " + JSON.stringify(thisObject.node.parentNode.parentNode.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } @@ -88,7 +88,7 @@ exports.newDataSet = function newDataSet(BOT, logger) { logger.write(MODULE_NAME, "[WARN] initialize -> Network Node not found.") logger.write(MODULE_NAME, "[WARN] initialize -> Initialization Failed because we could not find where the data of this dataset is located within the network. Check the logs for more info."); logger.write(MODULE_NAME, "[WARN] initialize -> Could not find where " + datasetProductDefinition.name + " for " + bot.exchange + " " + bot.market.baseAsset + "/" + bot.market.quotedAsset + " is stored within the network."); - callBackFunction(global.DEFAULT_OK_RESPONSE, false); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE, false); return } @@ -96,11 +96,11 @@ exports.newDataSet = function newDataSet(BOT, logger) { logger.write(MODULE_NAME, "[INFO] initialize -> Retrieving data from " + networkNode.name + " -> host = " + networkNode.config.host + ' -> port = ' + networkNode.config.webPort + '.') fileStorage = FILE_STORAGE.newFileStorage(logger, networkNode.config.host, networkNode.config.webPort); - callBackFunction(global.DEFAULT_OK_RESPONSE, true); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE, true); } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -131,7 +131,7 @@ exports.newDataSet = function newDataSet(BOT, logger) { } catch (err) { logger.write(MODULE_NAME, "[ERROR] 'getTextFile' -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -148,7 +148,7 @@ exports.newDataSet = function newDataSet(BOT, logger) { if (ownerId !== botId) { let customErr = { - result: global.CUSTOM_FAIL_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_FAIL_RESPONSE.result, message: "Only bots owners of a Data Set can create text files on them." }; logger.write(MODULE_NAME, "[ERROR] save -> customErr = " + customErr.message); @@ -167,7 +167,7 @@ exports.newDataSet = function newDataSet(BOT, logger) { } catch (err) { logger.write(MODULE_NAME, "[ERROR] 'createTextFile' -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } }; diff --git a/TaskServer/DebugLog.js b/TaskServer/DebugLog.js index 91b318fe7..bff28958d 100644 --- a/TaskServer/DebugLog.js +++ b/TaskServer/DebugLog.js @@ -114,7 +114,7 @@ exports.newDebugLog = function newDebugLog() { /* Will delete this file only if it does not contains ERROR inside. */ let fileContent = fileStorage.getTextFile(fileToDelete, onGetFile, true) function onGetFile(err, fileContent) { - if (err.result === global.DEFAULT_OK_RESPONSE.result) { + if (err.result === TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { if (fileContent.indexOf("ERROR") < 0) { /* Logs will only be deleted when they contain no ERROR in them. */ fileStorage.deleteTextFile(fileToDelete); @@ -129,7 +129,7 @@ exports.newDebugLog = function newDebugLog() { fileStorage.createTextFile(filePath + '/' + fileName, contentToPersist + '\r\n' + "]", onFileCreated, undefined, true); function onFileCreated(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { console.log("[ERROR] DebugLog -> persist -> onInizialized -> onFileCreated -> err = " + err.message); setTimeout(writeLog, 10000); // Lets retry until we make it. return; diff --git a/TaskServer/FileStorage.js b/TaskServer/FileStorage.js index 39715642a..e323e47c6 100644 --- a/TaskServer/FileStorage.js +++ b/TaskServer/FileStorage.js @@ -106,7 +106,7 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { if (noRetry === true) { logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> onFileRead -> File does not exist. Not Retrying. ') let customResponse = { - result: global.CUSTOM_FAIL_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_FAIL_RESPONSE.result, message: 'File does not exist.' } callBackFunction(customResponse) @@ -139,7 +139,7 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { if (mustBeJason === false) { /* In this case there is nothing else to check. */ - callBackFunction(global.DEFAULT_OK_RESPONSE, text.toString()) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE, text.toString()) return } @@ -150,7 +150,7 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { let jsonCheck = JSON.parse(text.toString()) /* The file was correctly read and could be parsed. */ - callBackFunction(global.DEFAULT_OK_RESPONSE, text.toString()) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE, text.toString()) return } catch (err) { @@ -172,12 +172,12 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { if (err) { logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> onFileRead -> canUsePrevious -> Could not read the Previous file either. Giving up.') logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> onFileRead -> canUsePrevious -> err = ' + err.stack) - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) return } /* Returning the previous file */ - callBackFunction(global.DEFAULT_OK_RESPONSE, text.toString()) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE, text.toString()) return } } else { @@ -207,7 +207,7 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { if (fileDoesNotExist === true) { logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> retry -> Max retries reached reading a file. File Not Found.') let customResponse = { - result: global.CUSTOM_FAIL_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_FAIL_RESPONSE.result, message: 'File does not exist.' } callBackFunction(customResponse) @@ -216,7 +216,7 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { logger.write(MODULE_NAME, '[ERROR] FileStorage -> getTextFile -> retry -> Max retries reached reading a file. Giving up.') logger.write(MODULE_NAME, '[ERROR] FileStorage -> getTextFile -> retry -> file = ' + fileLocation) - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) return } } @@ -269,7 +269,7 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { } else { if (noTemp === true) { - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) return } if (keepPrevious === true) { @@ -316,7 +316,7 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { setTimeout(retry, retryTimeToUse) } else { - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) } } @@ -349,7 +349,7 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { setTimeout(retry, retryTimeToUse) } else { - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) } } @@ -373,7 +373,7 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { currentRetryWriteTextFile = 0 logger.write(MODULE_NAME, '[ERROR] FileStorage -> createTextFile -> retry -> Max retries reached writting a file. Giving up.') logger.write(MODULE_NAME, '[ERROR] FileStorage -> createTextFile -> retry -> file = ' + fileLocation) - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } } } @@ -410,7 +410,7 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { } if (err) { if (callBackFunction !== undefined) { - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } } else { setTimeout(retry, retryTimeToUse) @@ -420,7 +420,7 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { logger.write(MODULE_NAME, '[WARN] FileStorage -> deleteTextFile -> Error writing file -> file = ' + fileLocation) logger.write(MODULE_NAME, '[WARN] FileStorage -> deleteTextFile -> Error writing file -> err = ' + err.stack) if (callBackFunction !== undefined) { - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } } @@ -434,7 +434,7 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { logger.write(MODULE_NAME, '[ERROR] FileStorage -> deleteTextFile -> retry -> Max retries reached deleting a file. Giving up.') logger.write(MODULE_NAME, '[ERROR] FileStorage -> deleteTextFile -> retry -> file = ' + fileLocation) if (callBackFunction !== undefined) { - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) } } } @@ -491,7 +491,7 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { request.on('error', function (err) { logger.write(MODULE_NAME, "[ERROR] getFileViaHTTP -> onError -> err = " + err.stack); logger.write(MODULE_NAME, "[ERROR] getFileViaHTTP -> onError -> Failed to fetch file via HTTP. Will retry later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); }) function onResponse(response) { @@ -520,13 +520,13 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { } catch (err) { logger.write(MODULE_NAME, "[ERROR] getFileViaHTTP -> onResponse -> err = " + err.stack); logger.write(MODULE_NAME, "[ERROR] getFileViaHTTP -> onResponse -> Failed to fetch file via HTTP. Will retry later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] getFileViaHTTP -> err = " + err.stack); logger.write(MODULE_NAME, "[ERROR] getFileViaHTTP -> Failed to fetch file via HTTP. Will retry later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); } } } diff --git a/TaskServer/Globals.js b/TaskServer/Globals.js index ef0ce0105..0c3c3cdb6 100644 --- a/TaskServer/Globals.js +++ b/TaskServer/Globals.js @@ -8,32 +8,6 @@ exports.newGlobals = function newGlobals() { function initialize() { - /* Callbacks default responses. */ - global.DEFAULT_OK_RESPONSE = { - result: "Ok", - message: "Operation Succeeded" - }; - - global.DEFAULT_FAIL_RESPONSE = { - result: "Fail", - message: "Operation Failed" - }; - - global.DEFAULT_RETRY_RESPONSE = { - result: "Retry", - message: "Retry Later" - }; - - global.CUSTOM_OK_RESPONSE = { - result: "Ok, but check Message", - message: "Custom Message" - }; - - global.CUSTOM_FAIL_RESPONSE = { - result: "Fail Because", - message: "Custom Message" - }; - /* This is the Execution Datetime */ global.EXECUTION_DATETIME = new Date(); diff --git a/TaskServer/IndicatorBot.js b/TaskServer/IndicatorBot.js index 15d38736c..242aa949b 100644 --- a/TaskServer/IndicatorBot.js +++ b/TaskServer/IndicatorBot.js @@ -30,7 +30,7 @@ if (bot.repo === undefined) { /* The code of the bot is defined at the UI. No need to load a file with the code. */ - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return } @@ -48,11 +48,11 @@ function onBotDownloaded(err, text) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> err = " + err.message); parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> filePath = " + filePath); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return; } @@ -65,20 +65,20 @@ fileStorage.getTextFile(filePath, onCommonsDownloaded); function onCommonsDownloaded(err, text) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { parentLogger.write(MODULE_NAME, "[WARN] initialize -> onBotDownloaded -> onCommonsDownloaded -> Commons not found: " + err.message); - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return; } COMMONS_MODULE = {} COMMONS_MODULE.newCommons = eval(text); // TODO This needs to be changed function - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } } } catch (err) { parentLogger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -152,18 +152,18 @@ function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeProcessExecutionEvents -> onInizialized -> Execution finished well."); startProcessExecutionEvents() return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> initializeProcessExecutionEvents -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> initializeProcessExecutionEvents -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -199,7 +199,7 @@ function onStarted(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> startProcessExecutionEvents -> onStarted -> Execution finished well."); if (global.STOP_TASK_GRACEFULLY === true) { @@ -210,13 +210,13 @@ initializeStatusDependencies(); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> startProcessExecutionEvents -> onStarted -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> startProcessExecutionEvents -> onStarted -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -253,18 +253,18 @@ function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeStatusDependencies -> onInizialized -> Execution finished well."); initializeDataDependencies(); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> initializeStatusDependencies -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> initializeStatusDependencies -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -301,7 +301,7 @@ function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { /* If the process is configured to run inside a framework, we continue there, otherwise we run the bot directly. */ if (processConfig.framework === undefined) { initializeUserBot(); @@ -329,13 +329,13 @@ } return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> initializeDataDependencies -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. processStopped() logger.write(MODULE_NAME, "[ERROR] run -> loop -> initializeDataDependencies -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message @@ -373,24 +373,24 @@ function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeUserBot -> onInizialized -> Execution finished well."); startUserBot(); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> initializeUserBot -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> initializeUserBot -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() return } - case global.CUSTOM_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result: { switch (err.message) { default: { @@ -431,24 +431,24 @@ function onFinished(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> startUserBot -> onFinished -> Execution finished well."); finishProcessExecutionEvents() return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> startUserBot -> onFinished -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> startUserBot -> onFinished -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() return } - case global.CUSTOM_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result: { switch (err.message) { case "Dependency does not exist.": { @@ -501,24 +501,24 @@ function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> intitializeProcessFramework -> onInizialized -> Execution finished well."); startProcessFramework(); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> intitializeProcessFramework -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> intitializeProcessFramework -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() return } - case global.CUSTOM_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result: { switch (err.message) { default: { @@ -566,24 +566,24 @@ statusDependencies = undefined switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> startProcessFramework -> onFinished -> Execution finished well."); finishProcessExecutionEvents() return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> startProcessFramework -> onFinished -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> startProcessFramework -> onFinished -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() return } - case global.CUSTOM_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result: { switch (err.message) { case "Dependency does not exist.": { @@ -639,19 +639,19 @@ processExecutionEvents = undefined switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> finishProcessExecutionEvents -> onFinished -> Execution finished well."); nextWaitTime = 'Normal'; loopControl(nextWaitTime); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> finishProcessExecutionEvents -> onFinished -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> finishProcessExecutionEvents -> onFinished -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -775,9 +775,9 @@ clearInterval(fixedTimeLoopIntervalHandle); clearTimeout(nextLoopTimeoutHandle); if (global.unexpectedError !== undefined) { - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } else { - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) } } @@ -785,7 +785,7 @@ parentLogger.write(MODULE_NAME, "[ERROR] run -> err = " + err.stack); clearInterval(fixedTimeLoopIntervalHandle); clearTimeout(nextLoopTimeoutHandle); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } }; diff --git a/TaskServer/IndicatorOutput.js b/TaskServer/IndicatorOutput.js index 27a53494b..6e83fd57a 100644 --- a/TaskServer/IndicatorOutput.js +++ b/TaskServer/IndicatorOutput.js @@ -27,11 +27,11 @@ logger.fileName = MODULE_NAME; logger.initialize(); - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -144,13 +144,13 @@ function anotherFileWritten() { totalFilesWritten++ if (totalFilesWritten === outputDatasets.length) { - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } }; diff --git a/TaskServer/LearningSession.js b/TaskServer/LearningSession.js index e392d44af..54e68de39 100644 --- a/TaskServer/LearningSession.js +++ b/TaskServer/LearningSession.js @@ -29,7 +29,7 @@ exports.newLearningSession = function newLearningSession(bot, parentLogger) { /* Check if there is a session */ if (bot.processNode.session === undefined) { parentLogger.write(MODULE_NAME, "[ERROR] initialize -> Cannot run without a Session."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return; } @@ -50,7 +50,7 @@ exports.newLearningSession = function newLearningSession(bot, parentLogger) { /* Heartbeats sent to the UI */ bot.sessionHeartBeat = sessionHeartBeat - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) return function onSessionStatus() { @@ -512,7 +512,7 @@ exports.newLearningSession = function newLearningSession(bot, parentLogger) { } catch (err) { parentLogger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } }; diff --git a/TaskServer/LowFrequencyTrading/Snapshots.js b/TaskServer/LowFrequencyTrading/Snapshots.js index 1d4cd36cc..9fbc4cd88 100644 --- a/TaskServer/LowFrequencyTrading/Snapshots.js +++ b/TaskServer/LowFrequencyTrading/Snapshots.js @@ -328,7 +328,7 @@ exports.newSnapshots = function newSnapshots(bot, logger) { fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] writeSnapshotFile -> onFileCreated -> err = " + err.stack); logger.write(MODULE_NAME, "[ERROR] writeSnapshotFile -> onFileCreated -> filePath = " + filePath); logger.write(MODULE_NAME, "[ERROR] writeSnapshotFile -> onFileCreated -> market = " + market.baseAsset + "_" + market.quotedAsset); diff --git a/TaskServer/LowFrequencyTrading/TradingOutput.js b/TaskServer/LowFrequencyTrading/TradingOutput.js index 49b944cda..81960c2a5 100644 --- a/TaskServer/LowFrequencyTrading/TradingOutput.js +++ b/TaskServer/LowFrequencyTrading/TradingOutput.js @@ -165,7 +165,7 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, tradingEngineM outputDatasetsMap.set(productName, []) return } - if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw(response.err) } outputDatasetsMap.set(productName, JSON.parse(response.text)) @@ -219,14 +219,14 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, tradingEngineM let response = await fileStorage.asyncCreateTextFile(filePath, fileContent) - if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw(response.err) } } } catch (err) { logger.write(MODULE_NAME, '[ERROR] start -> err = ' + err.stack) - throw(global.DEFAULT_FAIL_RESPONSE) + throw(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } } } diff --git a/TaskServer/LowFrequencyTrading/TradingProcess.js b/TaskServer/LowFrequencyTrading/TradingProcess.js index 3171879a5..0ac8f2cfc 100644 --- a/TaskServer/LowFrequencyTrading/TradingProcess.js +++ b/TaskServer/LowFrequencyTrading/TradingProcess.js @@ -44,11 +44,11 @@ tradingOutputModule.initialize() - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -120,7 +120,7 @@ if (await processMarketFiles() === false) { bot.TRADING_SESSIONHeartBeat(undefined, undefined, 'Waiting for Data Mining to be run') - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } /* @@ -152,7 +152,7 @@ bot.TRADING_SESSIONHeartBeat(undefined, undefined, 'Sleeping') } else { bot.TRADING_SESSIONHeartBeat(undefined, undefined, 'Waiting for Data Mining to be up to date. No candles found at.') - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } @@ -174,7 +174,7 @@ bot.TRADING_SESSIONHeartBeat(undefined, undefined, 'Waking up') if (await processDailyFiles() === false) { bot.TRADING_SESSIONHeartBeat(undefined, undefined, 'Waiting for Data Mining to be run') - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } /* @@ -193,7 +193,7 @@ bot.TRADING_SESSIONHeartBeat(undefined, undefined, 'Sleeping') } else { bot.TRADING_SESSIONHeartBeat(undefined, undefined, 'Waiting for Data Mining to be up to date') - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } /* @@ -216,7 +216,7 @@ Everything worked as expected. We return an OK code and wait for the Bot Loop to call us again later. */ - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) function checkThereAreCandles(chart) { let sessionParameters = bot.TRADING_SESSION.tradingParameters @@ -244,13 +244,13 @@ if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return false } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return false } @@ -260,7 +260,7 @@ logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Undefined Last File. -> thisReport = " + JSON.stringify(thisReport)); let customOK = { - result: global.CUSTOM_OK_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result, message: "Dependency not ready." } logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> customOK = " + customOK.message); @@ -275,13 +275,13 @@ if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return false } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because self dependecy Status Report is corrupt. Aborting Process."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return false } @@ -321,7 +321,7 @@ logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Check the bot configuration to see if all of its statusDependencies declarations are correct. "); logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Dependencies loaded -> keys = " + JSON.stringify(statusDependencies.keys)); } - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -346,7 +346,7 @@ /* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */ let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) - if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw (response.err) } @@ -399,7 +399,7 @@ return false } - if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw (response.err) } @@ -508,7 +508,7 @@ if (response.err.message === 'File does not exist.') { return false } - if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw (response.err) } @@ -657,7 +657,7 @@ let response = await fileStorage.asyncCreateTextFile(filePath, fileContent + '\n') - if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw (response.err) } @@ -695,7 +695,7 @@ let filePath = bot.filePathRoot + "/Output/" + bot.TRADING_SESSION.folderName + "/" + productCodeName + "/" + processType + fileName; let response = await fileStorage.asyncCreateTextFile(filePath, fileContent + '\n') - if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw (response.err) } } @@ -741,21 +741,21 @@ /* An unhandled exception occured. in this case we return Fail and log the stack. */ if (err.stack) { logger.write(MODULE_NAME, "[ERROR] start -> Unhandled Exception. Will Abort this process. err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } /* Some expected file was not found. We will return a RETRY code and move on. */ if ((err.result === "Fail Because" && err.message === "File does not exist.") || err.code === 'The specified key does not exist.') { logger.write(MODULE_NAME, "[ERROR] File not Found. Will Retry the Process Loop.") - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return } /* Some other handled exception occured. We return Fail and move on. */ - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> Handled Exception. Will Abort this process. err = " + err.message); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } } diff --git a/TaskServer/LowFrequencyTrading/TradingSimulation.js b/TaskServer/LowFrequencyTrading/TradingSimulation.js index 3ecb71540..6957719c6 100644 --- a/TaskServer/LowFrequencyTrading/TradingSimulation.js +++ b/TaskServer/LowFrequencyTrading/TradingSimulation.js @@ -403,7 +403,7 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin } catch (err) { logger.write(MODULE_NAME, '[ERROR] runSimulation -> getElement -> datasetName = ' + datasetName) logger.write(MODULE_NAME, '[ERROR] runSimulation -> getElement -> err = ' + err.stack) - throw (global.DEFAULT_FAIL_RESPONSE) + throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } } @@ -531,7 +531,7 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin } } catch (err) { logger.write(MODULE_NAME, '[ERROR] runSimulation -> err = ' + err.stack) - throw (global.DEFAULT_FAIL_RESPONSE) + throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } } } diff --git a/TaskServer/MultiPeriodDaily.js b/TaskServer/MultiPeriodDaily.js index 5bbca2277..4a95965a6 100644 --- a/TaskServer/MultiPeriodDaily.js +++ b/TaskServer/MultiPeriodDaily.js @@ -74,13 +74,13 @@ if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Market Starting Point -> Status Report does not exist or Market Starting Point not defined. Retrying Later. ") - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. ") - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } @@ -91,7 +91,7 @@ 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 = { - result: global.CUSTOM_OK_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result, message: "Dependency does not exist." } logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> customOK = " + customOK.message) @@ -107,13 +107,13 @@ if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Market Ending Point -> Status Report does not exist or Market Ending Point not defined. Retrying Later. ") - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. ") - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } @@ -123,7 +123,7 @@ logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Undefined Last File. -> thisReport.lastFile === undefined") let customOK = { - result: global.CUSTOM_OK_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result, message: "Dependency not ready." } logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> customOK = " + customOK.message) @@ -138,13 +138,13 @@ if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Self Reference -> Status Report does not exist or Self Reference not defined or badly configured. Check that at the Status Dependency you have chosen Self Reference at the config. Retrying Later. ") - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because self dependecy Status Report is corrupt. Aborting Process.") - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) return } @@ -213,7 +213,7 @@ logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Check the bot configuration to see if all of its statusDependencies declarations are correct. ") logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Dependencies loaded -> keys = " + JSON.stringify(statusDependencies.keys)) } - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } } @@ -240,7 +240,7 @@ const logText = "Head of the market found @ " + previousDay.getUTCFullYear() + "/" + (previousDay.getUTCMonth() + 1) + "/" + previousDay.getUTCDate() + "."; logger.write(MODULE_NAME, "[INFO] start -> processTimeFrames -> advanceTime -> " + logText) - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) return } @@ -259,7 +259,7 @@ function checkStopTaskGracefully() { /* Validation that we dont need to stop. */ if (global.STOP_TASK_GRACEFULLY === true) { - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) return } timeFramesLoop() @@ -309,7 +309,7 @@ if (dependency === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> processTimeFrames -> timeFramesLoopBody -> dependencyLoopBody -> You need to add at least one Data Dependency to the process Multi Period Daily. Aborting process.") - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) return } @@ -354,11 +354,11 @@ if ((err.result === "Fail Because" && err.message === "File does not exist.") || err.code === 'The specified key does not exist.') { logger.write(MODULE_NAME, "[ERROR] start -> processTimeFrames -> timeFramesLoopBody -> dependencyLoopBody -> getPreviousFile -> onFileReceived -> err = " + err.stack) - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> processTimeFrames -> timeFramesLoopBody -> dependencyLoopBody -> getPreviousFile -> onFileReceived -> err = " + err.stack) callBackFunction(err) @@ -398,11 +398,11 @@ logger.write(MODULE_NAME, "[ERROR] start -> processTimeFrames -> timeFramesLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> err = " + err.code) logger.write(MODULE_NAME, "[ERROR] start -> processTimeFrames -> timeFramesLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> filePath = " + filePath) logger.write(MODULE_NAME, "[ERROR] start -> processTimeFrames -> timeFramesLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> fileName = " + fileName) - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> processTimeFrames -> timeFramesLoopBody -> dependencyLoopBody -> getCurrentFile -> Not OK -> onFileReceived -> err = " + err.code) callBackFunction(err) return @@ -435,7 +435,7 @@ onOutputGenerated) function onOutputGenerated(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { callBackFunction(err) return } @@ -455,7 +455,7 @@ writeDataRanges(onWritten) function onWritten(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> processTimeFrames -> controlLoop -> onWritten -> err = " + err.stack) callBackFunction(err) return @@ -481,7 +481,7 @@ if (outputDatasetIndex < outputDatasets.length) { productLoopBody() } else { - callBack(global.DEFAULT_OK_RESPONSE) + callBack(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) } } } @@ -498,7 +498,7 @@ fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated) function onFileCreated(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> writeDataRange -> onFileCreated -> err = " + err.stack) callBack(err) return @@ -536,12 +536,12 @@ fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated) function onFileCreated(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> writeTimeFramesFiles -> onFileCreated -> err = " + err.stack) callBack(err) return } - callBack(global.DEFAULT_OK_RESPONSE) + callBack(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) } } @@ -563,7 +563,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> err = " + err.stack) - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } } }; diff --git a/TaskServer/MultiPeriodMarket.js b/TaskServer/MultiPeriodMarket.js index 2ad1acfb8..4ca45d651 100644 --- a/TaskServer/MultiPeriodMarket.js +++ b/TaskServer/MultiPeriodMarket.js @@ -85,7 +85,7 @@ datasetModule.getTextFile(filePath, fileName, onFileReceived) function onFileReceived(err, text) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> processTimeFrames -> timeFramesLoopBody -> dependencyLoopBody -> getFile -> onFileReceived -> err = " + err.stack) callBackFunction(err) return; @@ -117,7 +117,7 @@ onOutputGenerated) function onOutputGenerated(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { callBackFunction(err) return; } @@ -183,7 +183,7 @@ fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated) function onFileCreated(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> writeTimeFramesFile -> onFileCreated -> err = " + err.stack) callBack(err) return @@ -215,7 +215,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> err = " + err.stack) - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } } } diff --git a/TaskServer/ProcessExecutionEvents.js b/TaskServer/ProcessExecutionEvents.js index 9b8c39457..8be95ef5f 100644 --- a/TaskServer/ProcessExecutionEvents.js +++ b/TaskServer/ProcessExecutionEvents.js @@ -31,7 +31,7 @@ logger.fileName = MODULE_NAME + "." + name; if (bot.processNode.referenceParent === undefined) { - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); logger.write(MODULE_NAME, "[ERROR] initialize -> Initialization Failed because the Process Instance needs to have a Reference Parent."); return } @@ -140,7 +140,7 @@ ' -> port = ' + networkNode.config.webSocketsPort + '.'); - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return } return @@ -156,15 +156,15 @@ } } } - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); logger.write(MODULE_NAME, "[ERROR] initialize -> Initialization Failed because we could not find where the task that runs the Process Definition we are waiting for is located within the network. Check the logs for more info."); return } - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -208,9 +208,9 @@ bot.processHeartBeat(undefined, undefined, "Waiting for " + thisObject.networkNode.name + "->" + processThisDependsOn.parentNode.parentNode.name + "->" + processThisDependsOn.parentNode.config.codeName + "->" + processThisDependsOn.config.codeName) function responseCallBack(message) { - if (message.result !== global.DEFAULT_OK_RESPONSE.result) { + if (message.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> responseCallBack -> message = " + JSON.stringify(message)) - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } else { subscriptionId = message.eventSubscriptionId logger.write(MODULE_NAME, "[INFO] start -> waitForDependantProcess -> subscriptionId = " + subscriptionId) @@ -226,10 +226,10 @@ logger.write(MODULE_NAME, "[INFO] start -> eventsCallBack -> subscriptionId = " + subscriptionId) eventServerClient.stopListening(key, 'Process Execution Finished', subscriptionId) - if (message.event.err.result === global.DEFAULT_OK_RESPONSE.result) { + if (message.event.err.result === TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { /* We emit our own event that the process started. */ let event = { - err: global.DEFAULT_OK_RESPONSE + err: TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE } global.EVENT_SERVER_CLIENT_MODULE.createEventHandler(currentProcessKey, 'Process Execution Started') global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(currentProcessKey, 'Process Execution Started', event) @@ -245,19 +245,19 @@ /* In this case, the Process does not depends on a process which needs to wait for. */ /* We emit our own event that the process started. */ let event = { - err: global.DEFAULT_OK_RESPONSE + err: TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE } global.EVENT_SERVER_CLIENT_MODULE.createEventHandler(currentProcessKey, 'Process Execution Started') global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(currentProcessKey, 'Process Execution Started', event) logger.write(MODULE_NAME, "[INFO] start -> " + currentProcessKey + " Process Execution Started ") - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -268,7 +268,7 @@ logger.write(MODULE_NAME, "[INFO] finish -> Entering function.") let event = { - err: global.DEFAULT_OK_RESPONSE + err: TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE } global.EVENT_SERVER_CLIENT_MODULE.createEventHandler(currentProcessKey, 'Process Execution Finished') @@ -276,11 +276,11 @@ logger.write(MODULE_NAME, "[INFO] finish -> " + currentProcessKey + " Process Execution Finished ") - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } catch (err) { logger.write(MODULE_NAME, "[ERROR] finish -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } diff --git a/TaskServer/ProcessInstance.js b/TaskServer/ProcessInstance.js index 164289d14..584d3e031 100644 --- a/TaskServer/ProcessInstance.js +++ b/TaskServer/ProcessInstance.js @@ -279,7 +279,7 @@ function onInitializeReady(err) { - if (err.result === global.DEFAULT_OK_RESPONSE.result) { + if (err.result === TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { botInstance.run(whenRunFinishes); @@ -289,7 +289,7 @@ let botId = botConfig.dataMine + "." + botConfig.codeName + "." + botConfig.process; - if (err.result === global.DEFAULT_OK_RESPONSE.result) { + if (err.result === TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[INFO] start -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully."); logger.write(MODULE_NAME, "[INFO] start -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId); diff --git a/TaskServer/ProcessOutput.js b/TaskServer/ProcessOutput.js index ccbc41df8..a465b79cb 100644 --- a/TaskServer/ProcessOutput.js +++ b/TaskServer/ProcessOutput.js @@ -40,45 +40,45 @@ if (outputDataset.referenceParent !== undefined) { if (outputDataset.referenceParent.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Dataset Definition not defined. Dataset Definition = " + JSON.stringify(outputDataset.referenceParent)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (outputDataset.referenceParent.parentNode !== undefined) { if (outputDataset.referenceParent.parentNode.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Product not defined. Product = " + JSON.stringify(outputDataset.referenceParent.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (botNode !== undefined) { if (botNode.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Bot not defined. Bot = " + JSON.stringify(botNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } if (botNode.parentNode !== undefined) { if (botNode.parentNode.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Data Mine not defined. Data Mine = " + JSON.stringify(botNode.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } } else { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> Bot not attached to a Data Mine or Trading Mine. Bot = " + JSON.stringify(botNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } } else { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> Product not attached to a Bot. Product = " + JSON.stringify(outputDataset.referenceParent.parentNode)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } } else { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> Dataset Definition not attached to a Product. Dataset Definition = " + JSON.stringify(outputDataset.referenceParent)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } } else { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> Output Dataset with no reference to a Dataset Definition. Output Dataset = " + JSON.stringify(outputDataset)); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } @@ -99,11 +99,11 @@ } } - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } catch (err) { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -130,38 +130,38 @@ if (outputDataset.referenceParent !== undefined) { if (outputDataset.referenceParent.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Dataset Definition not defined. Dataset Definition = " + JSON.stringify(outputDataset.referenceParent)); - throw (global.DEFAULT_FAIL_RESPONSE); + throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } if (outputDataset.referenceParent.parentNode !== undefined) { if (outputDataset.referenceParent.parentNode.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Product not defined. Product = " + JSON.stringify(outputDataset.referenceParent.parentNode)); - throw (global.DEFAULT_FAIL_RESPONSE); + throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } if (botNode !== undefined) { if (botNode.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Bot not defined. Bot = " + JSON.stringify(botNode)); - throw (global.DEFAULT_FAIL_RESPONSE); + throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } if (botNode.parentNode !== undefined) { if (botNode.parentNode.config.codeName === undefined) { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Mine not defined. Mine = " + JSON.stringify(botNode.parentNode)); - throw (global.DEFAULT_FAIL_RESPONSE); + throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } else { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> Bot not attached to a Data Mine | Trading Mine | Learning Mine. Bot = " + JSON.stringify(botNode)); - throw (global.DEFAULT_FAIL_RESPONSE); + throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } else { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> Product not attached to a Bot. Product = " + JSON.stringify(outputDataset.referenceParent.parentNode)); - throw (global.DEFAULT_FAIL_RESPONSE); + throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } else { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> Dataset Definition not attached to a Product. Dataset Definition = " + JSON.stringify(outputDataset.referenceParent)); - throw (global.DEFAULT_FAIL_RESPONSE); + throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } else { logger.write(MODULE_NAME, "[ERROR] raiseEvents -> Output Dataset with no reference to a Dataset Definition. Output Dataset = " + JSON.stringify(outputDataset)); - throw (global.DEFAULT_FAIL_RESPONSE); + throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } /* All good, lets emit the event. */ diff --git a/TaskServer/ReinforcementLearning/LearningBot.js b/TaskServer/ReinforcementLearning/LearningBot.js index 548c20203..c24f20a35 100644 --- a/TaskServer/ReinforcementLearning/LearningBot.js +++ b/TaskServer/ReinforcementLearning/LearningBot.js @@ -35,7 +35,7 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { } catch (err) { parentLogger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -134,18 +134,18 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeProcessExecutionEvents -> onInizialized -> Execution finished well."); startProcessExecutionEvents() return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> initializeProcessExecutionEvents -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> initializeProcessExecutionEvents -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -181,7 +181,7 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { function onStarted(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> startProcessExecutionEvents -> onStarted -> Execution finished well."); if (global.STOP_TASK_GRACEFULLY === true) { @@ -192,13 +192,13 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { initializeStatusDependencies(); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> startProcessExecutionEvents -> onStarted -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> startProcessExecutionEvents -> onStarted -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -235,18 +235,18 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeStatusDependencies -> onInizialized -> Execution finished well."); initializeDataDependencies(); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> initializeStatusDependencies -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> initializeStatusDependencies -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -283,7 +283,7 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeDataDependencies -> onInizialized -> Execution finished well."); } switch (processConfig.framework.name) { case 'Low-Frequency-Trading-Process': { @@ -301,13 +301,13 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { } return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> initializeDataDependencies -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> initializeDataDependencies -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -343,24 +343,24 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> intitializeProcessFramework -> onInizialized -> Execution finished well."); startProcessFramework(); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> intitializeProcessFramework -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> intitializeProcessFramework -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() return } - case global.CUSTOM_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[ERROR] run -> loop -> intitializeProcessFramework -> onInizialized > Unhandled custom response received. -> err = " + err.message); global.unexpectedError = err.message processStopped() @@ -403,25 +403,25 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { statusDependencies = undefined switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> startProcessFramework -> onFinished -> Execution finished well."); nextWaitTime = 'Normal'; finishProcessExecutionEvents() return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> startProcessFramework -> onFinished -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> startProcessFramework -> onFinished -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() return } - case global.CUSTOM_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result: { switch (err.message) { case "Dependency does not exist.": { @@ -477,19 +477,19 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { processExecutionEvents = undefined switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> finishProcessExecutionEvents -> onFinished -> Execution finished well."); nextWaitTime = 'Normal'; loopControl(nextWaitTime); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> finishProcessExecutionEvents -> onFinished -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> finishProcessExecutionEvents -> onFinished -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -662,9 +662,9 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { clearInterval(fixedTimeLoopIntervalHandle); clearTimeout(nextLoopTimeoutHandle); if (global.unexpectedError !== undefined) { - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } else { - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) } } @@ -679,7 +679,7 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { parentLogger.write(MODULE_NAME, "[ERROR] run -> err = " + err.stack); clearInterval(fixedTimeLoopIntervalHandle); clearTimeout(nextLoopTimeoutHandle); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } }; diff --git a/TaskServer/ReinforcementLearning/LearningProcess.js b/TaskServer/ReinforcementLearning/LearningProcess.js index c4e195cd0..8c7f80df9 100644 --- a/TaskServer/ReinforcementLearning/LearningProcess.js +++ b/TaskServer/ReinforcementLearning/LearningProcess.js @@ -44,11 +44,11 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) algorithmModule.initialize() - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -120,7 +120,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) if (await processMarketFiles() === false) { bot.TRADING_SESSIONHeartBeat(undefined, undefined, 'Waiting for Data Mining to be run') - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } /* @@ -152,7 +152,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) bot.TRADING_SESSIONHeartBeat(undefined, undefined, 'Sleeping') } else { bot.TRADING_SESSIONHeartBeat(undefined, undefined, 'Waiting for Data Mining to be up to date. No candles found at.') - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } @@ -174,7 +174,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) bot.TRADING_SESSIONHeartBeat(undefined, undefined, 'Waking up') if (await processDailyFiles() === false) { bot.TRADING_SESSIONHeartBeat(undefined, undefined, 'Waiting for Data Mining to be run') - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } /* @@ -193,7 +193,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) bot.TRADING_SESSIONHeartBeat(undefined, undefined, 'Sleeping') } else { bot.TRADING_SESSIONHeartBeat(undefined, undefined, 'Waiting for Data Mining to be up to date') - callBackFunction(global.DEFAULT_RETRY_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } /* @@ -216,7 +216,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) Everything worked as expected. We return an OK code and wait for the Bot Loop to call us again later. */ - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) function checkThereAreCandles(chart) { let sessionParameters = bot.TRADING_SESSION.tradingParameters @@ -244,13 +244,13 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return } @@ -260,7 +260,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Undefined Last File. -> thisReport = " + JSON.stringify(thisReport)); let customOK = { - result: global.CUSTOM_OK_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result, message: "Dependency not ready." } logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> customOK = " + customOK.message); @@ -275,13 +275,13 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return } if (statusReport.status === "Status Report is corrupt.") { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> Can not continue because self dependecy Status Report is corrupt. Aborting Process."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } @@ -321,7 +321,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Check the bot configuration to see if all of its statusDependencies declarations are correct. "); logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> Dependencies loaded -> keys = " + JSON.stringify(statusDependencies.keys)); } - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -346,7 +346,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) /* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */ let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) - if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw (response.err) } @@ -399,7 +399,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) return false } - if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw (response.err) } @@ -508,7 +508,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) if (response.err.message === 'File does not exist.') { return false } - if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw (response.err) } @@ -657,7 +657,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) let response = await fileStorage.asyncCreateTextFile(filePath, fileContent + '\n') - if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw (response.err) } @@ -695,7 +695,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) let filePath = bot.filePathRoot + "/Output/" + bot.TRADING_SESSION.folderName + "/" + productCodeName + "/" + processType + fileName; let response = await fileStorage.asyncCreateTextFile(filePath, fileContent + '\n') - if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw (response.err) } } @@ -741,21 +741,21 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) /* An unhandled exception occured. in this case we return Fail and log the stack. */ if (err.stack) { logger.write(MODULE_NAME, "[ERROR] start -> Unhandled Exception. Will Abort this process. err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } /* Some expected file was not found. We will return a RETRY code and move on. */ if ((err.result === "Fail Because" && err.message === "File does not exist.") || err.code === 'The specified key does not exist.') { logger.write(MODULE_NAME, "[ERROR] File not Found. Will Retry the Process Loop.") - callBackFunction(global.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); return } /* Some other handled exception occured. We return Fail and move on. */ - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] start -> Handled Exception. Will Abort this process. err = " + err.message); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return } } diff --git a/TaskServer/SensorBot.js b/TaskServer/SensorBot.js index 132c283e3..5f56d3f15 100644 --- a/TaskServer/SensorBot.js +++ b/TaskServer/SensorBot.js @@ -30,7 +30,7 @@ if (bot.repo === undefined) { /* The code of the bot is defined at the UI. No need to load a file with the code. */ - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return } @@ -46,11 +46,11 @@ fileStorage.getTextFile(filePath, onBotDownloaded); function onBotDownloaded(err, text) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> err = " + err.message); parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> filePath = " + filePath); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return; } USER_BOT_MODULE = {} @@ -59,7 +59,7 @@ USER_BOT_MODULE.newUserBot = eval(text); // TODO This needs to be changed function } catch (err) { parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onBotDownloaded -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } filePath = bot.dataMine + "/" + "bots" + "/" + bot.processNode.referenceParent.parentNode.config.repo; @@ -68,22 +68,22 @@ fileStorage.getTextFile(filePath, onCommonsDownloaded); function onCommonsDownloaded(err, text) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { parentLogger.write(MODULE_NAME, "[WARN] initialize -> onBotDownloaded -> onCommonsDownloaded -> Commons not found: " + err.message); - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return; } COMMONS_MODULE = {} COMMONS_MODULE.newCommons = eval(text); // TODO This needs to be changed function - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } } } catch (err) { parentLogger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -156,18 +156,18 @@ function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeProcessExecutionEvents -> onInizialized -> Execution finished well."); startProcessExecutionEvents() return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> initializeProcessExecutionEvents -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> initializeProcessExecutionEvents -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -204,7 +204,7 @@ function onStarted(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> startProcessExecutionEvents -> onStarted -> Execution finished well."); if (global.STOP_TASK_GRACEFULLY === true) { @@ -215,13 +215,13 @@ initializeStatusDependencies(); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> startProcessExecutionEvents -> onStarted -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> startProcessExecutionEvents -> onStarted -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -258,18 +258,18 @@ function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeStatusDependencies -> onInizialized -> Execution finished well."); initializeUserBot(); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> initializeStatusDependencies -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> initializeStatusDependencies -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -306,24 +306,24 @@ function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeUserBot -> onInizialized > Execution finished well."); startUserBot(); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> initializeUserBot -> onInizialized > Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> initializeUserBot -> onInizialized > Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() return } - case global.CUSTOM_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result: { switch (err.message) { default: { @@ -364,24 +364,24 @@ function onFinished(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> startUserBot -> onFinished > Execution finished well."); finishProcessExecutionEvents() return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> startUserBot -> onFinished > Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> startUserBot -> onFinished > Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() return } - case global.CUSTOM_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result: { switch (err.message) { case "Dependency does not exist.": { @@ -437,19 +437,19 @@ processExecutionEvents = undefined switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> finishProcessExecutionEvents -> onFinished -> Execution finished well."); nextWaitTime = 'Normal'; loopControl(nextWaitTime); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> finishProcessExecutionEvents -> onFinished -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> finishProcessExecutionEvents -> onFinished -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -584,9 +584,9 @@ clearInterval(fixedTimeLoopIntervalHandle); clearTimeout(nextLoopTimeoutHandle); if (global.unexpectedError !== undefined) { - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } else { - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) } } } @@ -595,7 +595,7 @@ parentLogger.write(MODULE_NAME, "[ERROR] run -> err = " + err.stack); clearInterval(fixedTimeLoopIntervalHandle); clearTimeout(nextLoopTimeoutHandle); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } }; diff --git a/TaskServer/StatusDependencies.js b/TaskServer/StatusDependencies.js index 284d51c84..aa5306320 100644 --- a/TaskServer/StatusDependencies.js +++ b/TaskServer/StatusDependencies.js @@ -23,12 +23,12 @@ thisObject.nodeArray = bot.processNode.referenceParent.processDependencies.statusDependencies } else { logger.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible to not have status dependencies at all."); - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) return } } else { logger.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible to not have process dependencies, which means not status dependencies."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) return } @@ -58,7 +58,7 @@ logger.write(MODULE_NAME, "[INFO] initialize -> onInitilized -> Initialized Status Report # " + (i + 1)); - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { if (alreadyCalledBack === false) { logger.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> err = " + err.stack); logger.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> err.message = " + err.message); @@ -81,7 +81,7 @@ statusReportModule.status = err.message; switch (err.message) { - case global.DEFAULT_OK_RESPONSE.message: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.message: { addReport(); return; } @@ -116,7 +116,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> onLoad -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -142,7 +142,7 @@ if (loadCount === dependenciesToProcess.length) { if (alreadyCalledBack === false) { alreadyCalledBack = true - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return; } else { logger.write(MODULE_NAME, "[WARN] initialize -> addReport -> Can not call back because I already did.") @@ -153,7 +153,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } diff --git a/TaskServer/StatusReport.js b/TaskServer/StatusReport.js index 6c28ca7d2..636b9daad 100644 --- a/TaskServer/StatusReport.js +++ b/TaskServer/StatusReport.js @@ -84,7 +84,7 @@ let nodeString = JSON.stringify(errorInNode) logger.write(MODULE_NAME, "[ERROR] initialize -> " + errorMessage + ' -> nodeString = ' + nodeString) global.PROCESS_ERROR(bot.processKey, errorInNode, errorMessage) - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } /* Simplifying the access to basic info */ @@ -161,7 +161,7 @@ logger.write(MODULE_NAME, "[INFO] initialize -> Retrieving status report from " + networkNode.name + " -> host = " + networkNode.config.host + ' -> port = ' + networkNode.config.webPort + '.') fileStorage = FILE_STORAGE.newFileStorage(logger, networkNode.config.host, networkNode.config.webPort) - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) return true } } @@ -212,7 +212,7 @@ logger.write(MODULE_NAME, "[INFO] initialize -> Retrieving status report from " + networkNode.name + " -> host = " + networkNode.config.host + ' -> port = ' + networkNode.config.webPort + '.') fileStorage = FILE_STORAGE.newFileStorage(logger, networkNode.config.host, networkNode.config.webPort) - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) return true } } @@ -231,11 +231,11 @@ logger.write(MODULE_NAME, "[ERROR] initialize -> bottype = " + statusDependencyNode.bottype) logger.write(MODULE_NAME, "[ERROR] initialize -> dataMine = " + statusDependencyNode.dataMine) - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -284,7 +284,7 @@ function onFileReceived(err, text) { - if (err.result === global.CUSTOM_FAIL_RESPONSE.result && (err.message === 'Folder does not exist.' || err.message === 'File does not exist.') + if (err.result === TS.projects.superalgos.globals.standardResponses.CUSTOM_FAIL_RESPONSE.result && (err.message === 'Folder does not exist.' || err.message === 'File does not exist.') || err.code === "The specified key does not exist.") { logger.write(MODULE_NAME, "[INFO] load -> onFileReceived -> err = " + err.message) @@ -294,7 +294,7 @@ thisObject.file = JSON.parse('{}'); let customOK = { - result: global.CUSTOM_OK_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result, message: "Status Report was never created." }; logger.write(MODULE_NAME, "[WARN] load -> onFileReceived -> customOK = " + customOK.message) @@ -302,7 +302,7 @@ return; } - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] load -> onFileReceived -> err = " + err.message) callBackFunction(err); return; @@ -310,7 +310,7 @@ try { thisObject.file = JSON.parse(text); - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) } catch (err) { /* @@ -322,7 +322,7 @@ logger.write(MODULE_NAME, "[WARN] load -> onFileReceived -> Error Parsing the Status report. -> text = " + text) let customFail = { - result: global.CUSTOM_FAIL_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_FAIL_RESPONSE.result, message: "Status Report is corrupt." }; logger.write(MODULE_NAME, "[WARN] load -> onFileReceived -> customFail = " + customFail.message) @@ -333,7 +333,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] load -> err = " + err.stack) - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } } @@ -347,7 +347,7 @@ if (ownerId !== botId && statusDependencyNode.process !== "Context") { // Context is a special case where the report is created by the Context.js module itself. let customErr = { - result: global.CUSTOM_FAIL_RESPONSE.result, + result: TS.projects.superalgos.globals.standardResponses.CUSTOM_FAIL_RESPONSE.result, message: "Only bots owners of a Status Report can save them." }; logger.write(MODULE_NAME, "[ERROR] save -> customErr = " + customErr.message) @@ -364,7 +364,7 @@ fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated, true) function onFileCreated(err) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { logger.write(MODULE_NAME, "[ERROR] save -> onFileCreated -> err = " + err.stack) callBackFunction(err) return @@ -380,7 +380,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] save -> err = " + err.stack) - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -394,7 +394,7 @@ let response = await fileStorage.asyncCreateTextFile(filePath, fileContent + '\n', true) - if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) { + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw (response.err) } diff --git a/TaskServer/TradingBot.js b/TaskServer/TradingBot.js index 5180e20fa..03bfeab72 100644 --- a/TaskServer/TradingBot.js +++ b/TaskServer/TradingBot.js @@ -35,7 +35,7 @@ } catch (err) { parentLogger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } @@ -134,18 +134,18 @@ function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeProcessExecutionEvents -> onInizialized -> Execution finished well."); startProcessExecutionEvents() return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> initializeProcessExecutionEvents -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> initializeProcessExecutionEvents -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -181,7 +181,7 @@ function onStarted(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> startProcessExecutionEvents -> onStarted -> Execution finished well."); if (global.STOP_TASK_GRACEFULLY === true) { @@ -192,13 +192,13 @@ initializeStatusDependencies(); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> startProcessExecutionEvents -> onStarted -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> startProcessExecutionEvents -> onStarted -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -235,18 +235,18 @@ function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeStatusDependencies -> onInizialized -> Execution finished well."); initializeDataDependencies(); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> initializeStatusDependencies -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> initializeStatusDependencies -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -283,7 +283,7 @@ function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeDataDependencies -> onInizialized -> Execution finished well.") switch (processConfig.framework.name) { case 'Low-Frequency-Trading-Process': { @@ -301,13 +301,13 @@ } return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> initializeDataDependencies -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> initializeDataDependencies -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -343,24 +343,24 @@ function onInizialized(err) { try { switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> intitializeProcessFramework -> onInizialized -> Execution finished well."); startProcessFramework(); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> intitializeProcessFramework -> onInizialized -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> intitializeProcessFramework -> onInizialized -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() return } - case global.CUSTOM_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[ERROR] run -> loop -> intitializeProcessFramework -> onInizialized > Unhandled custom response received. -> err = " + err.message); global.unexpectedError = err.message processStopped() @@ -403,25 +403,25 @@ statusDependencies = undefined switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> startProcessFramework -> onFinished -> Execution finished well."); nextWaitTime = 'Normal'; finishProcessExecutionEvents() return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> startProcessFramework -> onFinished -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> startProcessFramework -> onFinished -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() return } - case global.CUSTOM_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result: { switch (err.message) { case "Dependency does not exist.": { @@ -477,19 +477,19 @@ processExecutionEvents = undefined switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { + case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result: { logger.write(MODULE_NAME, "[INFO] run -> loop -> finishProcessExecutionEvents -> onFinished -> Execution finished well."); nextWaitTime = 'Normal'; loopControl(nextWaitTime); return; } - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. logger.write(MODULE_NAME, "[WARN] run -> loop -> finishProcessExecutionEvents -> onFinished -> Retry Later. Requesting Execution Retry."); nextWaitTime = 'Retry'; loopControl(nextWaitTime); return; } - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + case TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. logger.write(MODULE_NAME, "[ERROR] run -> loop -> finishProcessExecutionEvents -> onFinished -> Operation Failed. Aborting the process."); global.unexpectedError = err.message processStopped() @@ -662,9 +662,9 @@ clearInterval(fixedTimeLoopIntervalHandle); clearTimeout(nextLoopTimeoutHandle); if (global.unexpectedError !== undefined) { - callBackFunction(global.DEFAULT_FAIL_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } else { - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) } } @@ -679,7 +679,7 @@ parentLogger.write(MODULE_NAME, "[ERROR] run -> err = " + err.stack); clearInterval(fixedTimeLoopIntervalHandle); clearTimeout(nextLoopTimeoutHandle); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } }; diff --git a/TaskServer/TradingSession.js b/TaskServer/TradingSession.js index 1ffe7a8fb..656132e50 100644 --- a/TaskServer/TradingSession.js +++ b/TaskServer/TradingSession.js @@ -29,7 +29,7 @@ /* Check if there is a session */ if (bot.processNode.session === undefined) { parentLogger.write(MODULE_NAME, "[ERROR] initialize -> Cannot run without a Session."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); return; } @@ -50,7 +50,7 @@ /* Heartbeats sent to the UI */ bot.TRADING_SESSIONHeartBeat = sessionHeartBeat - callBackFunction(global.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) return function onSessionStatus() { @@ -512,7 +512,7 @@ } catch (err) { parentLogger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } };