Inter Process Memory Implementation at Indicators Variables
This commit is contained in:
1 parent
e1823f7f11
commit
28f5f1793c
2 files changed
+64
-3
No files matched your search
+52
-2
@@ -258,7 +258,18 @@
|
||||
return results
|
||||
}
|
||||
|
||||
function dataBuildingProcedure(products, mainDependency, recordDefinition, dataBuildingProcedure, variableName, timePeriod, resultsWithIrregularPeriods) {
|
||||
function dataBuildingProcedure(
|
||||
products,
|
||||
mainDependency,
|
||||
recordDefinition,
|
||||
dataBuildingProcedure,
|
||||
variableName,
|
||||
timePeriod,
|
||||
resultsWithIrregularPeriods,
|
||||
interExecutionMemory,
|
||||
processingDailyFiles,
|
||||
currentDay
|
||||
) {
|
||||
|
||||
/*
|
||||
This function has as an input the products object, with all the information
|
||||
@@ -267,6 +278,8 @@
|
||||
a new set of information.
|
||||
*/
|
||||
|
||||
let lastInstantOfTheDay
|
||||
let yesterday = {}
|
||||
let system = { // These are the available system variables to be used in User Code and Formulas
|
||||
timePeriod: timePeriod,
|
||||
ONE_DAY_IN_MILISECONDS: ONE_DAY_IN_MILISECONDS
|
||||
@@ -287,9 +300,24 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (processingDailyFiles) {
|
||||
/* Initialization of Last Instance */
|
||||
lastInstantOfTheDay = currentDay.valueOf() + ONE_DAY_IN_MILISECONDS - 1;
|
||||
|
||||
if (interExecutionMemory.variable === undefined) {
|
||||
/* The first time the intialization variables goes to the Inter Execution Memory. */
|
||||
interExecutionMemory.variable = JSON.parse(JSON.stringify(variable))
|
||||
}
|
||||
else {
|
||||
/* We override the initialization, since the valid stuff is already at the Inter Execution Memory */
|
||||
variable = JSON.parse(JSON.stringify(interExecutionMemory.variable))
|
||||
}
|
||||
}
|
||||
|
||||
/* This is Initialization Code */
|
||||
if (dataBuildingProcedure.loop !== undefined) {
|
||||
if (dataBuildingProcedure.loop.code !== undefined) {
|
||||
let lastRecord
|
||||
for (let index = 0; index < mainDependency.records.length; index++) {
|
||||
|
||||
let record = {
|
||||
@@ -297,10 +325,16 @@
|
||||
current: mainDependency.records[index],
|
||||
next: mainDependency.records[index + 1]
|
||||
}
|
||||
|
||||
lastRecord = record
|
||||
let product = {}
|
||||
product[variableName] = {}
|
||||
|
||||
/* Here is how we know if we are processing Yesterday. */
|
||||
let positionedAtYesterday = false
|
||||
if (processingDailyFiles) {
|
||||
positionedAtYesterday = (record.current.end < currentDay.valueOf())
|
||||
}
|
||||
|
||||
/* This is Loop Code */
|
||||
try {
|
||||
eval(dataBuildingProcedure.loop.code.code)
|
||||
@@ -337,6 +371,22 @@
|
||||
/* Adding the new element to the resulting array */
|
||||
results.push(product[variableName]);
|
||||
}
|
||||
|
||||
/* While we are positioned at Yesterday, we keey updating this data structure. */
|
||||
if (processingDailyFiles) {
|
||||
if (positionedAtYesterday) {
|
||||
yesterday.variable = JSON.parse(JSON.stringify(variable))
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
Before returning we need to see if we have to record some of our counters at the interExecutionMemory.
|
||||
To do that, the condition to be met is that this execution must include all candles of the current day.
|
||||
*/
|
||||
if (processingDailyFiles) {
|
||||
if (lastRecord.current.end === lastInstantOfTheDay) {
|
||||
interExecutionMemory.variable = JSON.parse(JSON.stringify(yesterday.variable))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -94,7 +94,18 @@
|
||||
}
|
||||
|
||||
/* Build the data */
|
||||
jsonData = commons.dataBuildingProcedure(products, mainDependency, recordDefinition, outputDatasetNode.referenceParent.parentNode.dataBuilding, singularVariableName, timePeriod, resultsWithIrregularPeriods)
|
||||
jsonData = commons.dataBuildingProcedure(
|
||||
products,
|
||||
mainDependency,
|
||||
recordDefinition,
|
||||
outputDatasetNode.referenceParent.parentNode.dataBuilding,
|
||||
singularVariableName,
|
||||
timePeriod,
|
||||
resultsWithIrregularPeriods,
|
||||
interExecutionMemory,
|
||||
processingDailyFiles,
|
||||
currentDay
|
||||
)
|
||||
|
||||
/* Add the calculated properties */
|
||||
if (outputDatasetNode.referenceParent.parentNode.calculations !== undefined) {
|
||||
|
||||
Reference in new issue
Block a user