Network Node saving events and pushing them to storage
This commit is contained in:
1 parent
c1ea907ba7
commit
d2f815d256
29 files changed
+235
-114
No files matched your search
@@ -2,6 +2,7 @@ Data-Storage
|
||||
Log-Files
|
||||
My-Workspaces
|
||||
My-Social-Trading-Data
|
||||
My-Network-Nodes-Data
|
||||
debug.log
|
||||
.DS_Store
|
||||
*.db
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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')
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -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')
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
File renamed without changes.
@@ -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
|
||||
|
||||
+2
-2
@@ -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
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -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);
|
||||
|
||||
+11
-11
@@ -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);
|
||||
|
||||
+10
-10
@@ -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() + ".")
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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)
|
||||
|
||||
+1
-1
@@ -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() {
|
||||
|
||||
+3
-3
@@ -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
|
||||
}
|
||||
|
||||
|
||||
+24
-24
@@ -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()
|
||||
}
|
||||
|
||||
+1
-1
@@ -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() {
|
||||
|
||||
+1
-1
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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)
|
||||
}
|
||||
|
||||
+3
-3
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 @ " +
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user