diff --git a/.gitignore b/.gitignore index c7aaa09d1..07cadad8b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ Data-Storage Log-Files My-Workspaces My-Social-Trading-Data +My-Network-Nodes-Data debug.log .DS_Store *.db diff --git a/Desktop/UI/WebApp.js b/Desktop/UI/WebApp.js index bce4eb31d..4a3b9a63b 100644 --- a/Desktop/UI/WebApp.js +++ b/Desktop/UI/WebApp.js @@ -319,7 +319,7 @@ function newWebApp() { eventType: eventType, eventId: SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId(), targetUserProfileId: userProfileId, - timestamp: new Date() + timestamp: (new Date()).valueOf() } event = { @@ -355,7 +355,7 @@ function newWebApp() { eventType: SA.projects.socialTrading.globals.eventTypes.NEW_USER_POST, eventId: SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId(), text: postText, - timestamp: new Date() + timestamp: (new Date()).valueOf() } event = { diff --git a/Network/NetwokNode.js b/Network/NetwokNode.js index af1913a24..54f053306 100644 --- a/Network/NetwokNode.js +++ b/Network/NetwokNode.js @@ -4,6 +4,8 @@ exports.newNetworkNode = function newNetworkNode() { run: run } + let indexLastSavedEvent = -1 + return thisObject function run() { @@ -18,7 +20,99 @@ exports.newNetworkNode = function newNetworkNode() { async function start() { let socialGraphService = NT.projects.socialTrading.modules.socialGraph.newSocialGraph() await socialGraphService.initialize() + + setInterval(saveEventsAtStorage, 60000) + } + } + + async function saveEventsAtStorage() { + + let oneMore = true + let needToDoGit = false + + while (oneMore === true) { + oneMore = saveOneMinuteOfEvents() + if (oneMore === true) { + needToDoGit = true + } } + if (needToDoGit === true) { + doGit() + } + + function saveOneMinuteOfEvents() { + /* + Here we will save all the events that were not saved before, + in one minute chunchs files. + */ + let eventsToSave = [] + let minuteToSave + + for (let i = indexLastSavedEvent + 1; i < NT.projects.socialTrading.globals.memory.arrays.EVENTS.length; i++) { + let event = NT.projects.socialTrading.globals.memory.arrays.EVENTS[i] + + let currentMinute = Math.trunc((new Date()).valueOf() / SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) + let eventMinute = Math.trunc(event.timestamp / SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) + + if (minuteToSave === undefined) { + minuteToSave = eventMinute + } + /* + We will save events only of the last closed minute. + We will also pack events into one minute chunks only. + */ + if ( + eventMinute < currentMinute && + eventMinute === minuteToSave + ) { + let eventToSave = { + eventId: event.eventId, + eventType: event.eventType, + emitterUserProfileId: event.emitterUserProfileId, + targetUserProfileId: event.targetUserProfileId, + emitterBotProfileId: event.emitterBotProfileId, + targetBotProfileId: event.targetBotProfileId, + emitterPostHash: event.emitterPostHash, + targetPostHash: event.targetPostHash, + timestamp: event.timestamp, + botAsset: event.botAsset, + botExchange: event.botExchange, + botEnabled: event.botEnabled + } + + eventsToSave.push(eventToSave) + indexLastSavedEvent = i + } + } + + if (eventsToSave.length === 0) { return false } + + let timestamp = minuteToSave * SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS + + const fileContent = JSON.stringify(eventsToSave, undefined, 4) + const fileName = "Events" + ".json" + + let filePath = './My-Network-Nodes-Data/Nodes/Node-1/' + SA.projects.foundations.utilities.filesAndDirectories.pathFromDatetime(timestamp) + + SA.projects.foundations.utilities.filesAndDirectories.mkDirByPathSync(filePath + '/') + SA.nodeModules.fs.writeFileSync(filePath + '/' + fileName, fileContent) + + return true + } + + async function doGit() { + const options = { + baseDir: process.cwd() + '/My-Network-Nodes-Data', + binary: 'git', + maxConcurrentProcesses: 6, + } + const commitMessage = 'New Events' + const git = SA.nodeModules.simpleGit(options) + + await git.add('./*') + await git.commit(commitMessage) + await git.push('origin') + } } } diff --git a/NetworkRoot.js b/NetworkRoot.js index 075a6f6a7..9fbe271d2 100644 --- a/NetworkRoot.js +++ b/NetworkRoot.js @@ -41,9 +41,11 @@ exports.newNetworkRoot = function newNetworkRoot() { */ SA.nodeModules = { fs: require('fs'), + path: require('path'), nodeFetch: require('node-fetch'), web3: require('web3'), - ws: require('ws') + ws: require('ws'), + simpleGit: require('simple-git') } /* diff --git a/Projects/Foundations/TS/Globals/TimeConstants.js b/Projects/Foundations/SA/Globals/TimeConstants.js similarity index 100% rename from Projects/Foundations/TS/Globals/TimeConstants.js rename to Projects/Foundations/SA/Globals/TimeConstants.js diff --git a/Projects/Foundations/SA/Utilities/FilesAndDirectories.js b/Projects/Foundations/SA/Utilities/FilesAndDirectories.js index f635977ab..9db22af7e 100644 --- a/Projects/Foundations/SA/Utilities/FilesAndDirectories.js +++ b/Projects/Foundations/SA/Utilities/FilesAndDirectories.js @@ -4,6 +4,7 @@ exports.newFoundationsUtilitiesFilesAndDirectories = function () { getDirectories: getDirectories, getAllFilesInDirectoryAndSubdirectories: getAllFilesInDirectoryAndSubdirectories, pathFromDate: pathFromDate, + pathFromDatetime: pathFromDatetime, mkDirByPathSync: mkDirByPathSync } @@ -55,15 +56,35 @@ exports.newFoundationsUtilitiesFilesAndDirectories = function () { } function pathFromDate(timestamp) { + let file = { date: new Date(timestamp) } + file.year = file.date.getUTCFullYear() file.month = file.date.getUTCMonth() + 1 file.day = file.date.getUTCDate() + return file.year + '/' + SA.projects.foundations.utilities.miscellaneousFunctions.pad(file.month, 2) + '/' + SA.projects.foundations.utilities.miscellaneousFunctions.pad(file.day, 2) } + function pathFromDatetime(timestamp) { + + let file = { date: new Date(timestamp) } + + file.year = file.date.getUTCFullYear() + file.month = file.date.getUTCMonth() + 1 + file.day = file.date.getUTCDate() + file.hour = file.date.getUTCHours() + file.minute = file.date.getMinutes() + + return file.year + '/' + + SA.projects.foundations.utilities.miscellaneousFunctions.pad(file.month, 2) + '/' + + SA.projects.foundations.utilities.miscellaneousFunctions.pad(file.day, 2) + '/' + + SA.projects.foundations.utilities.miscellaneousFunctions.pad(file.hour, 2) + '/' + + SA.projects.foundations.utilities.miscellaneousFunctions.pad(file.minute, 2) + } + /* Function to create folders of missing folders at any path. */ function mkDirByPathSync(targetDir, { isRelativeToScript = false } = {}) { const path = SA.nodeModules.path diff --git a/Projects/Foundations/Schemas/Docs-Concepts/R/replaceBy/replaceBy-Config-Property/replaceby-config-property.json b/Projects/Foundations/Schemas/Docs-Concepts/R/replaceBy/replaceBy-Config-Property/replaceby-config-property.json index cd560e721..4d53d5ba4 100644 --- a/Projects/Foundations/Schemas/Docs-Concepts/R/replaceBy/replaceBy-Config-Property/replaceby-config-property.json +++ b/Projects/Foundations/Schemas/Docs-Concepts/R/replaceBy/replaceBy-Config-Property/replaceby-config-property.json @@ -141,7 +141,7 @@ }, { "style": "Javascript", - "text": "parameterValue = \nMath.trunc((new Date()).valueOf() / \nTS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) * \nTS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS", + "text": "parameterValue = \nMath.trunc((new Date()).valueOf() / \nSA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) * \nSA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS", "updated": 1622477009814 }, { @@ -151,7 +151,7 @@ }, { "style": "Javascript", - "text": "parameterValue = Math.trunc((new Date()).valueOf() / \nTS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) * \nTS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS + \nTS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS - 1", + "text": "parameterValue = Math.trunc((new Date()).valueOf() / \nSA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) * \nSA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS + \nSA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS - 1", "updated": 1622477088684 }, { diff --git a/Projects/Foundations/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js b/Projects/Foundations/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js index d6f697034..1c3a6ef54 100644 --- a/Projects/Foundations/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js +++ b/Projects/Foundations/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js @@ -462,11 +462,11 @@ exports.newFoundationsBotModulesFetchingProcess = function (processIndex) { break } case '@BeginCurrentMinute': { - parameterValue = Math.trunc((new Date()).valueOf() / TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) * TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS + parameterValue = Math.trunc((new Date()).valueOf() / SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) * SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS break } case '@EndCurrentMinute': { - parameterValue = Math.trunc((new Date()).valueOf() / TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) * TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS + TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS - 1 + parameterValue = Math.trunc((new Date()).valueOf() / SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) * SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS + SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS - 1 break } } diff --git a/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiTimeFrameDaily.js b/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiTimeFrameDaily.js index 7fdba9a41..e7a62f89e 100644 --- a/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiTimeFrameDaily.js +++ b/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiTimeFrameDaily.js @@ -94,7 +94,7 @@ thisReport.beginingOfMarket.days + " " + thisReport.beginingOfMarket.hours + ":" + thisReport.beginingOfMarket.minutes + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS); + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); /* Second, we get the report from Exchange Raw Data, to know when the marted ends. */ statusReport = statusDependenciesModule.reportsByMainUtility.get('Market Ending Point') @@ -158,15 +158,15 @@ contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS); + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); contextVariables.lastBandFile = new Date( contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS); + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); contextVariables.lastBandFile = new Date( contextVariables.lastBandFile.valueOf() + - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); buildBands(); return; @@ -199,16 +199,16 @@ contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS); + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); contextVariables.lastBandFile = new Date( contextVariables.lastBandFile.valueOf() + - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); beginingOfMarket = new Date( contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS); + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[INFO] start -> getContextVariables -> thisReport.lastFile === undefined") @@ -237,7 +237,7 @@ try { let n; - processDate = new Date(contextVariables.lastBandFile.valueOf() - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); // Go back one day to start well when we advance time at the begining of the loop. + processDate = new Date(contextVariables.lastBandFile.valueOf() - SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); // Go back one day to start well when we advance time at the begining of the loop. let fromDate = new Date(processDate.valueOf()) let lastDate = TS.projects.foundations.utilities.dateTimeFunctions.removeTime(new Date()) @@ -249,8 +249,8 @@ function advanceTime() { try { - processDate = new Date(processDate.valueOf() + TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); - previousDay = new Date(processDate.valueOf() - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); + processDate = new Date(processDate.valueOf() + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); + previousDay = new Date(processDate.valueOf() - SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[INFO] start -> buildBands -> advanceTime -> processDate = " + processDate) @@ -784,7 +784,7 @@ try { let dataRange = { begin: pBegin.valueOf(), - end: pEnd.valueOf() + TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + end: pEnd.valueOf() + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS } let fileContent = JSON.stringify(dataRange); diff --git a/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiTimeFrameDaily.js b/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiTimeFrameDaily.js index 83cf08131..56962ad7f 100644 --- a/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiTimeFrameDaily.js +++ b/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiTimeFrameDaily.js @@ -89,7 +89,7 @@ thisReport.beginingOfMarket.days + " " + thisReport.beginingOfMarket.hours + ":" + thisReport.beginingOfMarket.minutes + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS) + SA.projects.foundations.globals.timeConstants.GMT_SECONDS) /* Second, we get the report from Exchange Raw Data, to know when the marted ends. */ statusReport = statusDependenciesModule.reportsByMainUtility.get('Market Ending Point') @@ -125,7 +125,7 @@ thisReport.lastFile.year + "-" + thisReport.lastFile.month + "-" + thisReport.lastFile.days + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS) + SA.projects.foundations.globals.timeConstants.GMT_SECONDS) /* Finally we get our own Status Report. */ statusReport = statusDependenciesModule.reportsByMainUtility.get('Self Reference') @@ -150,15 +150,15 @@ beginingOfMarket = new Date(thisReport.beginingOfMarket) if (beginingOfMarket.valueOf() !== contextVariables.datetimeBeginingOfMarketFile.valueOf()) { // Reset Mechanism for Begining of the Market - beginingOfMarket = new Date(contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + TS.projects.foundations.globals.timeConstants.GMT_SECONDS); + beginingOfMarket = new Date(contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); contextVariables.datetimeLastProducedFile = new Date( contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS) + SA.projects.foundations.globals.timeConstants.GMT_SECONDS) contextVariables.datetimeLastProducedFile = new Date( contextVariables.datetimeLastProducedFile.valueOf() - - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) // Go back one day to start well. + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) // Go back one day to start well. buildCandles() return @@ -171,7 +171,7 @@ For that reason we go back one day, the partial information is discarded and added again with whatever new info is available. */ - contextVariables.datetimeLastProducedFile = new Date(contextVariables.datetimeLastProducedFile.valueOf() - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + contextVariables.datetimeLastProducedFile = new Date(contextVariables.datetimeLastProducedFile.valueOf() - SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) buildCandles() return @@ -180,13 +180,13 @@ contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS) + SA.projects.foundations.globals.timeConstants.GMT_SECONDS) contextVariables.datetimeLastProducedFile = new Date( contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS) - contextVariables.datetimeLastProducedFile = new Date(contextVariables.datetimeLastProducedFile.valueOf() - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); // Go back one day to start well. + SA.projects.foundations.globals.timeConstants.GMT_SECONDS) + contextVariables.datetimeLastProducedFile = new Date(contextVariables.datetimeLastProducedFile.valueOf() - SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); // Go back one day to start well. buildCandles() return @@ -216,7 +216,7 @@ advanceTime() function advanceTime() { - contextVariables.datetimeLastProducedFile = new Date(contextVariables.datetimeLastProducedFile.valueOf() + TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); + contextVariables.datetimeLastProducedFile = new Date(contextVariables.datetimeLastProducedFile.valueOf() + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[INFO] start -> buildCandles -> advanceTime -> New processing time @ " + contextVariables.datetimeLastProducedFile.getUTCFullYear() + "/" + (contextVariables.datetimeLastProducedFile.getUTCMonth() + 1) + "/" + contextVariables.datetimeLastProducedFile.getUTCDate() + ".") @@ -665,7 +665,7 @@ try { let dataRange = { begin: pBegin.valueOf(), - end: pEnd.valueOf() + TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + end: pEnd.valueOf() + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS } let fileContent = JSON.stringify(dataRange); diff --git a/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiTimeFrameMarket.js b/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiTimeFrameMarket.js index 0ca8fa025..ea86ca2f6 100644 --- a/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiTimeFrameMarket.js +++ b/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiTimeFrameMarket.js @@ -107,7 +107,7 @@ thisReport.beginingOfMarket.days + " " + thisReport.beginingOfMarket.hours + ":" + thisReport.beginingOfMarket.minutes + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS); + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); /* Second, we get the report from Exchange Raw Data, to know when the marted ends. */ statusReport = statusDependenciesModule.reportsByMainUtility.get('Market Ending Point') @@ -143,7 +143,7 @@ thisReport.lastFile.year + "-" + thisReport.lastFile.month + "-" + thisReport.lastFile.days + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS); + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); /* Finally we get our own Status Report. */ statusReport = statusDependenciesModule.reportsByMainUtility.get('Self Reference') @@ -174,15 +174,15 @@ contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS); + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); contextVariables.datetimeLastProducedFile = new Date( contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS); + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); contextVariables.datetimeLastProducedFile = new Date( contextVariables.datetimeLastProducedFile.valueOf() - - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); // Go back one day to start well. + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); // Go back one day to start well. buildCandles() return @@ -196,7 +196,7 @@ For that reason we go back one day, the partial information is discarded and added again with whatever new info is available. */ - contextVariables.datetimeLastProducedFile = new Date(contextVariables.datetimeLastProducedFile.valueOf() - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); + contextVariables.datetimeLastProducedFile = new Date(contextVariables.datetimeLastProducedFile.valueOf() - SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); findPreviousContent() return @@ -205,15 +205,15 @@ contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS); + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); contextVariables.datetimeLastProducedFile = new Date( contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS); + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); contextVariables.datetimeLastProducedFile = new Date( contextVariables.datetimeLastProducedFile.valueOf() - - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); // Go back one day to start well. + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); // Go back one day to start well. buildCandles() return @@ -394,7 +394,7 @@ date and then adding again all the elements found right now at that date and then from there into the future. */ - contextVariables.datetimeLastProducedFile = new Date(contextVariables.datetimeLastProducedFile.valueOf() + TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); + contextVariables.datetimeLastProducedFile = new Date(contextVariables.datetimeLastProducedFile.valueOf() + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS); TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[INFO] start -> buildCandles -> advanceTime -> New processing time @ " + contextVariables.datetimeLastProducedFile.getUTCFullYear() + "/" + (contextVariables.datetimeLastProducedFile.getUTCMonth() + 1) + "/" + contextVariables.datetimeLastProducedFile.getUTCDate() + ".") diff --git a/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/MultiTimeFrameDaily.js b/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/MultiTimeFrameDaily.js index 681896424..d4815fe6b 100644 --- a/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/MultiTimeFrameDaily.js +++ b/Projects/Foundations/TS/Bot-Modules/Indicator-Bot/MultiTimeFrameDaily.js @@ -104,7 +104,7 @@ thisReport.beginingOfMarket.days + " " + thisReport.beginingOfMarket.hours + ":" + thisReport.beginingOfMarket.minutes + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS + SA.projects.foundations.globals.timeConstants.GMT_SECONDS ) } else { // This is the standard way. contextVariables.dateBeginOfMarket = new Date(thisReport.beginingOfMarket) @@ -198,7 +198,7 @@ contextVariables.dateBeginOfMarket.getUTCFullYear() + "-" + (contextVariables.dateBeginOfMarket.getUTCMonth() + 1) + "-" + contextVariables.dateBeginOfMarket.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS + SA.projects.foundations.globals.timeConstants.GMT_SECONDS ) TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, @@ -242,7 +242,7 @@ let botNeverRan = true; TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME = - new Date(contextVariables.lastFile.valueOf() - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) // Go back one day to start well when we advance time at the begining of the loop. + new Date(contextVariables.lastFile.valueOf() - SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) // Go back one day to start well when we advance time at the begining of the loop. let fromDate = new Date(TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME.valueOf()) let lastDate = TS.projects.foundations.utilities.dateTimeFunctions.removeTime(new Date()) @@ -251,9 +251,9 @@ function advanceTime() { TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME = new Date(TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME.valueOf() + - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) previousDay = new Date(TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME.valueOf() - - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[INFO] start -> processTimeFrames -> advanceTime -> TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME = " + @@ -541,7 +541,7 @@ function writeDataRange(pBegin, pEnd, productCodeName, callBack) { let dataRange = { begin: pBegin.valueOf(), - end: pEnd.valueOf() + TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + end: pEnd.valueOf() + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS }; let fileContent = JSON.stringify(dataRange) let fileName = '/Data.Range.json'; diff --git a/Projects/Foundations/TS/Bot-Modules/Learning-Bot/LearningSession.js b/Projects/Foundations/TS/Bot-Modules/Learning-Bot/LearningSession.js index 4112e69bf..ed0f52dcb 100644 --- a/Projects/Foundations/TS/Bot-Modules/Learning-Bot/LearningSession.js +++ b/Projects/Foundations/TS/Bot-Modules/Learning-Bot/LearningSession.js @@ -241,7 +241,7 @@ type: 'Time Range', config: { initialDatetime: (new Date()).valueOf(), - finalDatetime: (new Date()).valueOf() + TS.projects.foundations.globals.timeConstants.ONE_YEAR_IN_MILISECONDS + finalDatetime: (new Date()).valueOf() + SA.projects.foundations.globals.timeConstants.ONE_YEAR_IN_MILISECONDS } } } else { @@ -292,8 +292,8 @@ /* Session Type Forced Values */ let today = (new Date()).valueOf() - let aYearAgo = today - TS.projects.foundations.globals.timeConstants.ONE_YEAR_IN_MILISECONDS - let aYearFromNow = today + TS.projects.foundations.globals.timeConstants.ONE_YEAR_IN_MILISECONDS + let aYearAgo = today - SA.projects.foundations.globals.timeConstants.ONE_YEAR_IN_MILISECONDS + let aYearFromNow = today + SA.projects.foundations.globals.timeConstants.ONE_YEAR_IN_MILISECONDS switch (TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.type) { case 'Back Learning Session': { useDefaultDatetimes(aYearAgo, today) diff --git a/Projects/Foundations/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningEpisode.js b/Projects/Foundations/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningEpisode.js index 276a85fa2..6eba82d6e 100644 --- a/Projects/Foundations/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningEpisode.js +++ b/Projects/Foundations/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningEpisode.js @@ -101,7 +101,7 @@ exports.newFoundationsBotModulesLearningEpisode = function (processIndex) { learningEngine.learningCurrent.learningEpisode.learningEpisodeStatistics.days.value = learningEngine.learningCurrent.learningEpisode.learningEpisodeCounters.periods.value * sessionParameters.timeFrame.config.value / - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS } function cycleBasedStatistics() { diff --git a/Projects/Foundations/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningSimulation.js b/Projects/Foundations/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningSimulation.js index 7e2548f3f..53ee68f92 100644 --- a/Projects/Foundations/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningSimulation.js +++ b/Projects/Foundations/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningSimulation.js @@ -312,7 +312,7 @@ exports.newFoundationsBotModulesLearningSimulation = function (processIndex) { if (sessionParameters.heartbeats.config.date === true || sessionParameters.heartbeats.config.candleIndex === true) { /* We will produce a simulation level heartbeat in order to inform the user this is running. */ - heartBeatDate = new Date(Math.trunc(learningEngine.learningCurrent.learningEpisode.candle.begin.value / TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) * TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + heartBeatDate = new Date(Math.trunc(learningEngine.learningCurrent.learningEpisode.candle.begin.value / SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) * SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) let fromDate = new Date(sessionParameters.timeRange.config.initialDatetime) let lastDate = new Date(sessionParameters.timeRange.config.finalDatetime) @@ -502,7 +502,7 @@ exports.newFoundationsBotModulesLearningSimulation = function (processIndex) { the day, we will advance current process day one day. By doing so, during the next execution, the simulation will receive the candles and indicators files of the next day. */ - let candlesPerDay = TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS / sessionParameters.timeFrame.config.value + let candlesPerDay = SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS / sessionParameters.timeFrame.config.value if ( TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES && learningEngine.learningCurrent.learningEpisode.candle.index.value + 1 + 1 === candlesPerDay @@ -516,7 +516,7 @@ exports.newFoundationsBotModulesLearningSimulation = function (processIndex) { */ learningEngine.learningCurrent.learningEpisode.candle.index.value = 0 learningEngine.learningCurrent.learningEpisode.processDate.value = - learningEngine.learningCurrent.learningEpisode.processDate.value + TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + learningEngine.learningCurrent.learningEpisode.processDate.value + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS return false } diff --git a/Projects/Foundations/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js b/Projects/Foundations/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js index 716d10eff..34cbb378e 100644 --- a/Projects/Foundations/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js +++ b/Projects/Foundations/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js @@ -217,8 +217,8 @@ thisReport = statusDependencies.statusReports.get(reportKey) if (thisReport.file.beginingOfMarket !== undefined) { // This means this is not the first time this process has run. - beginingOfMarket = new Date(thisReport.file.beginingOfMarket.year + "-" + thisReport.file.beginingOfMarket.month + "-" + thisReport.file.beginingOfMarket.days + " " + thisReport.file.beginingOfMarket.hours + ":" + thisReport.file.beginingOfMarket.minutes + TS.projects.foundations.globals.timeConstants.GMT_SECONDS); - lastFile = new Date(thisReport.file.lastFile.year + "-" + thisReport.file.lastFile.month + "-" + thisReport.file.lastFile.days + " " + thisReport.file.lastFile.hours + ":" + thisReport.file.lastFile.minutes + TS.projects.foundations.globals.timeConstants.GMT_SECONDS); + beginingOfMarket = new Date(thisReport.file.beginingOfMarket.year + "-" + thisReport.file.beginingOfMarket.month + "-" + thisReport.file.beginingOfMarket.days + " " + thisReport.file.beginingOfMarket.hours + ":" + thisReport.file.beginingOfMarket.minutes + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); + lastFile = new Date(thisReport.file.lastFile.year + "-" + thisReport.file.lastFile.month + "-" + thisReport.file.lastFile.days + " " + thisReport.file.lastFile.hours + ":" + thisReport.file.lastFile.minutes + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); lastId = thisReport.file.lastId lastCandleOfTheDay = thisReport.file.lastCandleOfTheDay } else { // This means this is the first time this process has run. @@ -449,7 +449,7 @@ await exchange.fetchOHLCV(symbol, '1d', earliestMarketSince, searchSize, params) if (earlyOHLCVs.length === searchSize && previousMarketSince !== earlyOHLCVs[0][0]) { // If array is full, and the date returned isn't the same then we are still working in valid data, search further back - earliestMarketSince = (earlyOHLCVs[0][0] - (TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS * searchSize)) + earliestMarketSince = (earlyOHLCVs[0][0] - (SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS * searchSize)) previousMarketSince = earlyOHLCVs[0][0] } else if (earlyOHLCVs.length === searchSize && previousMarketSince === earlyOHLCVs[0][0]) { // If array is full, but the first OHLCV date is the same as last time then we've found our Market Start @@ -463,7 +463,7 @@ return earlyOHLCVs[0][0] } else if ((earlyOHLCVs.length === 0 && searchSize !== 1)) { // If array is empty, we've gone too far, half the search size and retry - earliestMarketSince = (earliestMarketSince + (TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS * searchSize)) + earliestMarketSince = (earliestMarketSince + (SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS * searchSize)) if (searchSize > 1) { searchSize = Math.floor(searchSize / 2) } @@ -504,7 +504,7 @@ await exchange.fetchOHLCV(symbol, '1m', since, limit, params) if (nextValidOHLCVs.length === 0) { - since = (since + (TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS * limit)) + since = (since + (SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS * limit)) } else { foundDate = true @@ -549,7 +549,7 @@ let OHLCV = OHLCVs[0] initialProcessTimestamp = OHLCV[0] // 'timestamp' - beginingOfMarket = new Date(Math.trunc(OHLCV[0] / TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) * TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) // 'timestamp' + beginingOfMarket = new Date(Math.trunc(OHLCV[0] / SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) * SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) // 'timestamp' fromDate = new Date(beginingOfMarket.valueOf()) firstTimeThisProcessRun = false } @@ -627,11 +627,11 @@ let startOfFetchTrades = since let endOfFetchTrades if (lastFile === undefined) { - endOfFetchTrades = (Math.trunc(since / TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) * TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + endOfFetchTrades = (Math.trunc(since / SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) * SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) } else { endOfFetchTrades = lastFile.valueOf() } - endOfFetchTrades += TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + endOfFetchTrades += SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS while (TS.projects.foundations.globals.taskVariables.IS_TASK_STOPPING !== true) { var trades = await exchange.fetchTrades(symbol, startOfFetchTrades, limit, params) if (trades.length > 0) { @@ -680,7 +680,7 @@ let heartBeatCounter = 0 let savingProcedureFinished = false let endOfTheOHLCVArrayReached = false - let currentDay = Math.trunc((initialProcessTimestamp - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) / TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + let currentDay = Math.trunc((initialProcessTimestamp - SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) / SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) let lastCandle = { begin: 0, @@ -742,8 +742,8 @@ hold at least the last know value. */ let candle = { - begin: currentDay * TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS * minuteOfTheDay, - end: currentDay * TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS * minuteOfTheDay + TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS - 1, + begin: currentDay * SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS * minuteOfTheDay, + end: currentDay * SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS * minuteOfTheDay + SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS - 1, open: lastCandle.close, close: lastCandle.close, min: lastCandle.close, @@ -751,8 +751,8 @@ } let volume = { - begin: currentDay * TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS * minuteOfTheDay, - end: currentDay * TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS * minuteOfTheDay + TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS - 1, + begin: currentDay * SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS * minuteOfTheDay, + end: currentDay * SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS * minuteOfTheDay + SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS - 1, buy: lastVolume.buy, sell: lastVolume.sell } @@ -796,7 +796,7 @@ timestamp in order to calculate OHLCVMinute. */ let OHLCV = { - timestamp: (new Date()).valueOf() + TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS, + timestamp: (new Date()).valueOf() + SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS, open: 0, hight: 0, low: 0, @@ -824,7 +824,7 @@ } } - let candleMinute = Math.trunc(candle.begin / TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) + let candleMinute = Math.trunc(candle.begin / SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) let OHLCVMinute /* Some exchanges return inconsistent data. It is not guaranteed @@ -833,7 +833,7 @@ between timestamps will be the same. To fix this, we will do this. */ - OHLCVMinute = Math.trunc(OHLCV.timestamp / TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) + OHLCVMinute = Math.trunc(OHLCV.timestamp / SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) /* If the minute of the record item received from the exchange is @@ -873,7 +873,7 @@ } /* Recalculate this to see if we need to break the loop*/ - OHLCVMinute = Math.trunc(OHLCV.timestamp / TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) + OHLCVMinute = Math.trunc(OHLCV.timestamp / SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS) } /* @@ -981,14 +981,14 @@ let fileName = 'Data.json' filesToCreate++ - fileStorage.createTextFile(getFilePath(day * TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS, CANDLES_FOLDER_NAME) + '/' + fileName, candlesFileContent + '\n', onFileCreated); + fileStorage.createTextFile(getFilePath(day * SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS, CANDLES_FOLDER_NAME) + '/' + fileName, candlesFileContent + '\n', onFileCreated); filesToCreate++ - fileStorage.createTextFile(getFilePath(day * TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS, VOLUMES_FOLDER_NAME) + '/' + fileName, volumesFileContent + '\n', onFileCreated); + fileStorage.createTextFile(getFilePath(day * SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS, VOLUMES_FOLDER_NAME) + '/' + fileName, volumesFileContent + '\n', onFileCreated); if (ohlcvsFileContent !== undefined) { filesToCreate++ - fileStorage.createTextFile(getFilePath(day * TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS, OHLCVS_FOLDER_NAME) + '/' + fileName, ohlcvsFileContent + '\n', onFileCreated); + fileStorage.createTextFile(getFilePath(day * SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS, OHLCVS_FOLDER_NAME) + '/' + fileName, ohlcvsFileContent + '\n', onFileCreated); mustLoadRawData = true } else { mustLoadRawData = false @@ -1010,11 +1010,11 @@ let dataLength = rawDataArray.length if (dataLength > 0) { // first get the start of the day after this day we are checking - let timestamp = (day * TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + let timestamp = (day * SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS if (rawDataArray[dataLength - 1][0] < timestamp) { // there is no data for the next day, so now trim this day's data to remove anything before it - timestamp -= TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + timestamp -= SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS let dataIndex = 0 while (dataIndex < dataLength - 1) { if (rawDataArray[dataIndex][0] < timestamp) { // this data is from a previous day @@ -1043,7 +1043,7 @@ return; } filesCreated++ - lastFile = new Date((currentDay * TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS)) + lastFile = new Date((currentDay * SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS)) if (filesCreated === filesToCreate) { controlLoop() } diff --git a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingEpisode.js b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingEpisode.js index 6c3b51cb2..0ff1c6762 100644 --- a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingEpisode.js +++ b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingEpisode.js @@ -113,7 +113,7 @@ exports.newFoundationsBotModulesTradingEpisode = function (processIndex) { tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeStatistics.days.value = tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeCounters.periods.value * sessionParameters.timeFrame.config.value / - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS } function cycleBasedStatistics() { diff --git a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOrders.js b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOrders.js index 91d1958d2..26b4207e5 100644 --- a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOrders.js +++ b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOrders.js @@ -1286,7 +1286,7 @@ exports.newFoundationsBotModulesTradingOrders = function (processIndex) { } function updateStatistics(tradingEngineOrder) { - tradingEngineOrder.orderStatistics.days.value = tradingEngineOrder.orderCounters.periods.value * sessionParameters.timeFrame.config.value / TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + tradingEngineOrder.orderStatistics.days.value = tradingEngineOrder.orderCounters.periods.value * sessionParameters.timeFrame.config.value / SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS tradingEngineOrder.orderStatistics.days.value = TS.projects.foundations.utilities.miscellaneousFunctions.truncateToThisPrecision(tradingEngineOrder.orderStatistics.days.value, 10) } diff --git a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingPosition.js b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingPosition.js index f2de2313c..c2aaa9302 100644 --- a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingPosition.js +++ b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingPosition.js @@ -513,7 +513,7 @@ exports.newFoundationsBotModulesTradingPosition = function (processIndex) { /* Days Calculation */ tradingEngine.tradingCurrent.position.positionStatistics.days.value = tradingEngine.tradingCurrent.position.positionCounters.periods.value * - sessionParameters.timeFrame.config.value / TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + sessionParameters.timeFrame.config.value / SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS tradingEngine.tradingCurrent.position.positionStatistics.days.value = TS.projects.foundations.utilities.miscellaneousFunctions.truncateToThisPrecision(tradingEngine.tradingCurrent.position.positionStatistics.days.value, 10) } diff --git a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js index bcc9a2a6a..bb3701eef 100644 --- a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js +++ b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js @@ -303,7 +303,7 @@ exports.newFoundationsBotModulesTradingSimulation = function (processIndex) { if (sessionParameters.heartbeats.config.date === true || sessionParameters.heartbeats.config.candleIndex === true) { /* We will produce a simulation level heartbeat in order to inform the user this is running. */ - heartBeatDate = new Date(Math.trunc(tradingEngine.tradingCurrent.tradingEpisode.candle.begin.value / TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) * TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + heartBeatDate = new Date(Math.trunc(tradingEngine.tradingCurrent.tradingEpisode.candle.begin.value / SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) * SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) let fromDate = new Date(sessionParameters.timeRange.config.initialDatetime) let lastDate = new Date(sessionParameters.timeRange.config.finalDatetime) @@ -493,7 +493,7 @@ exports.newFoundationsBotModulesTradingSimulation = function (processIndex) { the day, we will advance current process day one day. By doing so, during the next execution, the simulation will receive the candles and indicators files of the next day. */ - let candlesPerDay = TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS / sessionParameters.timeFrame.config.value + let candlesPerDay = SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS / sessionParameters.timeFrame.config.value if ( TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES && tradingEngine.tradingCurrent.tradingEpisode.candle.index.value + 1 + 1 === candlesPerDay @@ -507,7 +507,7 @@ exports.newFoundationsBotModulesTradingSimulation = function (processIndex) { */ tradingEngine.tradingCurrent.tradingEpisode.candle.index.value = 0 tradingEngine.tradingCurrent.tradingEpisode.processDate.value = - tradingEngine.tradingCurrent.tradingEpisode.processDate.value + TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + tradingEngine.tradingCurrent.tradingEpisode.processDate.value + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS return false } diff --git a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/TradingSession.js b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/TradingSession.js index 290876baf..404516556 100644 --- a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/TradingSession.js +++ b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/TradingSession.js @@ -249,7 +249,7 @@ type: 'Time Range', config: { initialDatetime: (new Date()).valueOf(), - finalDatetime: (new Date()).valueOf() + TS.projects.foundations.globals.timeConstants.ONE_YEAR_IN_MILISECONDS + finalDatetime: (new Date()).valueOf() + SA.projects.foundations.globals.timeConstants.ONE_YEAR_IN_MILISECONDS } } } else { @@ -300,8 +300,8 @@ /* Session Type Forced Values */ let today = (new Date()).valueOf() - let aYearAgo = today - TS.projects.foundations.globals.timeConstants.ONE_YEAR_IN_MILISECONDS - let aYearFromNow = today + TS.projects.foundations.globals.timeConstants.ONE_YEAR_IN_MILISECONDS + let aYearAgo = today - SA.projects.foundations.globals.timeConstants.ONE_YEAR_IN_MILISECONDS + let aYearFromNow = today + SA.projects.foundations.globals.timeConstants.ONE_YEAR_IN_MILISECONDS switch (TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.type) { case 'Backtesting Session': { useDefaultDatetimes(aYearAgo, today) diff --git a/Projects/Foundations/TS/Function-Libraries/DataDependenciesFunctions.js b/Projects/Foundations/TS/Function-Libraries/DataDependenciesFunctions.js index d80fb517a..937a8809f 100644 --- a/Projects/Foundations/TS/Function-Libraries/DataDependenciesFunctions.js +++ b/Projects/Foundations/TS/Function-Libraries/DataDependenciesFunctions.js @@ -315,7 +315,7 @@ exports.newFoundationsFunctionLibrariesDataDependenciesFunctions = function () { /* We will need to fetch the data of the current day and the previous day, in order for .previous properties in conditions and formulas to work well. */ - let previousDate = new Date(processDate.valueOf() - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + let previousDate = new Date(processDate.valueOf() - SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) let currentDate = new Date(processDate.valueOf()) let previousFile = await getDataFileFromDate(previousDate) diff --git a/Projects/Foundations/TS/Function-Libraries/FromOneMinToMultiTimeFrameFunctions.js b/Projects/Foundations/TS/Function-Libraries/FromOneMinToMultiTimeFrameFunctions.js index 7300d33b0..70f231667 100644 --- a/Projects/Foundations/TS/Function-Libraries/FromOneMinToMultiTimeFrameFunctions.js +++ b/Projects/Foundations/TS/Function-Libraries/FromOneMinToMultiTimeFrameFunctions.js @@ -215,15 +215,15 @@ exports.newFoundationsFunctionLibrariesFromOneMinToMultiTimeFrameFunctions = fun contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS) + SA.projects.foundations.globals.timeConstants.GMT_SECONDS) contextVariables.datetimeLastProducedFile = new Date( contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS) + SA.projects.foundations.globals.timeConstants.GMT_SECONDS) contextVariables.datetimeLastProducedFile = new Date( contextVariables.datetimeLastProducedFile.valueOf() - - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) // Go back one day to start well. + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) // Go back one day to start well. callbackFirstRun() return @@ -236,7 +236,7 @@ exports.newFoundationsFunctionLibrariesFromOneMinToMultiTimeFrameFunctions = fun For that reason we go back one day, the partial information is discarded and added again with whatever new info is available. */ - contextVariables.datetimeLastProducedFile = new Date(contextVariables.datetimeLastProducedFile.valueOf() - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + contextVariables.datetimeLastProducedFile = new Date(contextVariables.datetimeLastProducedFile.valueOf() - SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) callbackNotFirstRun() return @@ -249,15 +249,15 @@ exports.newFoundationsFunctionLibrariesFromOneMinToMultiTimeFrameFunctions = fun contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS) + SA.projects.foundations.globals.timeConstants.GMT_SECONDS) contextVariables.datetimeLastProducedFile = new Date( contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + (contextVariables.datetimeBeginingOfMarketFile.getUTCMonth() + 1) + "-" + contextVariables.datetimeBeginingOfMarketFile.getUTCDate() + " " + "00:00" + - TS.projects.foundations.globals.timeConstants.GMT_SECONDS) + SA.projects.foundations.globals.timeConstants.GMT_SECONDS) contextVariables.datetimeLastProducedFile = new Date( contextVariables.datetimeLastProducedFile.valueOf() - - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) // Go back one day to start well. + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) // Go back one day to start well. callbackFirstRun() return @@ -298,7 +298,7 @@ exports.newFoundationsFunctionLibrariesFromOneMinToMultiTimeFrameFunctions = fun from there into the future. */ contextVariables.datetimeLastProducedFile = new Date(contextVariables.datetimeLastProducedFile.valueOf() + - TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[INFO] advanceTime -> New processing time @ " + diff --git a/Projects/Foundations/TS/Function-Libraries/ProcessFilesFunctions.js b/Projects/Foundations/TS/Function-Libraries/ProcessFilesFunctions.js index b8ca6d72b..a818ee06a 100644 --- a/Projects/Foundations/TS/Function-Libraries/ProcessFilesFunctions.js +++ b/Projects/Foundations/TS/Function-Libraries/ProcessFilesFunctions.js @@ -100,7 +100,7 @@ exports.newFoundationsFunctionLibrariesProcessFilesFunctions = function () { } function startFromBegining() { - contextVariables.lastFile = new Date(contextVariables.dateBeginOfMarket.getUTCFullYear() + "-" + (contextVariables.dateBeginOfMarket.getUTCMonth() + 1) + "-" + contextVariables.dateBeginOfMarket.getUTCDate() + " " + "00:00" + TS.projects.foundations.globals.timeConstants.GMT_SECONDS) + contextVariables.lastFile = new Date(contextVariables.dateBeginOfMarket.getUTCFullYear() + "-" + (contextVariables.dateBeginOfMarket.getUTCMonth() + 1) + "-" + contextVariables.dateBeginOfMarket.getUTCDate() + " " + "00:00" + SA.projects.foundations.globals.timeConstants.GMT_SECONDS) TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[INFO] start -> getContextVariables -> startFromBegining -> contextVariables.lastFile = " + contextVariables.lastFile) @@ -147,7 +147,7 @@ exports.newFoundationsFunctionLibrariesProcessFilesFunctions = function () { async function writeDataRange(productCodeName) { let dataRange = { begin: contextVariables.dateBeginOfMarket.valueOf(), - end: processDate.valueOf() + TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + end: processDate.valueOf() + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS } let fileContent = JSON.stringify(dataRange) diff --git a/Projects/Foundations/TS/Function-Libraries/SingleMarketFunctions.js b/Projects/Foundations/TS/Function-Libraries/SingleMarketFunctions.js index b0904da95..bd89bf2a8 100644 --- a/Projects/Foundations/TS/Function-Libraries/SingleMarketFunctions.js +++ b/Projects/Foundations/TS/Function-Libraries/SingleMarketFunctions.js @@ -219,7 +219,7 @@ let system = { // These are the available system variables to be used in User Code and Formulas timeFrame: timeFrame, - ONE_DAY_IN_MILISECONDS: TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS + ONE_DAY_IN_MILISECONDS: SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS } let variable = {} // This is the structure where the user will define its own variables that will be shared across different code blocks and formulas. let results = [] @@ -312,8 +312,8 @@ let yesterday = {} let system = { // These are the available system variables to be used in User Code and Formulas timeFrame: timeFrame, - ONE_DAY_IN_MILISECONDS: TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS, - ONE_MIN_IN_MILISECONDS: TS.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS + ONE_DAY_IN_MILISECONDS: SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS, + ONE_MIN_IN_MILISECONDS: SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS } let variable = {} // This is the structure where the user will define its own variables that will be shared across different code blocks and formulas. let results = [] @@ -407,7 +407,7 @@ if (processingDailyFiles) { /* Initialization of Last Instance */ - lastInstantOfTheDay = currentDay.valueOf() + TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS - 1; + lastInstantOfTheDay = currentDay.valueOf() + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS - 1; if (interExecutionMemory[productName] === undefined) { /* The first time the intialization variables goes to the Inter Execution Memory. */ @@ -515,7 +515,7 @@ at the next day, in whole, even if it starts in the previous day. */ - let lastInstantOdDay = currentDay.valueOf() + TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS - 1; + let lastInstantOdDay = currentDay.valueOf() + SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS - 1; if (record.end < currentDay.valueOf() - 1) { continue; } if (record.end === lastInstantOdDay) { continue; } diff --git a/Projects/Foundations/TS/Utilities/DateTimeFunctions.js b/Projects/Foundations/TS/Utilities/DateTimeFunctions.js index f3c1aa6c2..19ca6d4b2 100644 --- a/Projects/Foundations/TS/Utilities/DateTimeFunctions.js +++ b/Projects/Foundations/TS/Utilities/DateTimeFunctions.js @@ -10,7 +10,7 @@ exports.newFoundationsUtilitiesDateTimeFunctions = function () { function removeTime(datetime) { let date = new Date(datetime) - return new Date(date.getUTCFullYear() + "-" + (date.getUTCMonth() + 1) + "-" + date.getUTCDate() + " " + "00:00" + TS.projects.foundations.globals.timeConstants.GMT_SECONDS); + return new Date(date.getUTCFullYear() + "-" + (date.getUTCMonth() + 1) + "-" + date.getUTCDate() + " " + "00:00" + SA.projects.foundations.globals.timeConstants.GMT_SECONDS); } function getPercentage(fromDate, currentDate, lastDate) { @@ -26,8 +26,8 @@ exports.newFoundationsUtilitiesDateTimeFunctions = function () { } function areTheseDatesEqual(date1, date2) { - let day1Days = Math.trunc(date1.valueOf() / TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) - let day2Days = Math.trunc(date2.valueOf() / TS.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + let day1Days = Math.trunc(date1.valueOf() / SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + let day2Days = Math.trunc(date2.valueOf() / SA.projects.foundations.globals.timeConstants.ONE_DAY_IN_MILISECONDS) if (day1Days === day2Days) { return true diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index 3eec6d184..341264f52 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -340,12 +340,6 @@ "functionName": "newFoundationsGlobalsStandardResponses", "fileName": "StandardResponses.js" }, - { - "name": "Time Constants", - "propertyName": "timeConstants", - "functionName": "newFoundationsGlobalsTimeConstants", - "fileName": "TimeConstants.js" - }, { "name": "Process Variables", "propertyName": "processVariables", @@ -883,6 +877,14 @@ ] }, "SA": { + "globals":[ + { + "name": "Time Constants", + "propertyName": "timeConstants", + "functionName": "newFoundationsGlobalsTimeConstants", + "fileName": "TimeConstants.js" + } + ], "utilities": [ { "name": "Plugins", diff --git a/Projects/Social-Trading/DK/modules/WebAppInterface.js b/Projects/Social-Trading/DK/modules/WebAppInterface.js index 135ae7dcf..8c154ef2e 100644 --- a/Projects/Social-Trading/DK/modules/WebAppInterface.js +++ b/Projects/Social-Trading/DK/modules/WebAppInterface.js @@ -47,7 +47,7 @@ exports.newSocialTradingModulesWebAppInterface = function newSocialTradingModule queryMessage.emitterUserProfileId = DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID messageHeader.queryMessage = JSON.stringify(queryMessage) - console.log((new Date()).toISOString(), '- Web App Interface', '- Query Message Received', JSON.stringify(queryMessage)) + // console.log((new Date()).toISOString(), '- Web App Interface', '- Query Message Received', JSON.stringify(queryMessage)) let response = { result: 'Ok', @@ -55,7 +55,7 @@ exports.newSocialTradingModulesWebAppInterface = function newSocialTradingModule data: await DK.running.webSocketsClient.sendMessage(JSON.stringify(messageHeader)) } - console.log((new Date()).toISOString(), '- Web App Interface', '- Query Respose Sent', JSON.stringify(response)) + // console.log((new Date()).toISOString(), '- Web App Interface', '- Query Respose Sent', JSON.stringify(response)) return response } diff --git a/Projects/Social-Trading/NT/Modules/ClientInterface.js b/Projects/Social-Trading/NT/Modules/ClientInterface.js index 497d3a817..cb01af216 100644 --- a/Projects/Social-Trading/NT/Modules/ClientInterface.js +++ b/Projects/Social-Trading/NT/Modules/ClientInterface.js @@ -130,6 +130,7 @@ exports.newSocialTradingModulesClientInterface = function newSocialTradingModule let event = NT.projects.socialTrading.modules.event.newSocialTradingModulesEvent() event.initialize(eventReceived) NT.projects.socialTrading.globals.memory.maps.EVENTS.set(eventReceived.eventId, event) + NT.projects.socialTrading.globals.memory.arrays.EVENTS.push(event) let response = { result: 'Ok', @@ -207,7 +208,7 @@ exports.newSocialTradingModulesClientInterface = function newSocialTradingModule let query = NT.projects.socialTrading.modules.query.newSocialTradingModulesQuery() query.initialize(queryReceived) - console.log((new Date()).toISOString(), '- Client Interface', '- Query Message Received', queryMessage) + // console.log((new Date()).toISOString(), '- Client Interface', '- Query Message Received', queryMessage) let response = { result: 'Ok', @@ -215,7 +216,7 @@ exports.newSocialTradingModulesClientInterface = function newSocialTradingModule data: query.execute() } - console.log((new Date()).toISOString(), '- Client Interface', '- Query Respose Sent', JSON.stringify(response)) + // console.log((new Date()).toISOString(), '- Client Interface', '- Query Respose Sent', JSON.stringify(response)) return response