Skip to content

Commit

Permalink
Patches for fromOneMinTo Market and Daily Indicator Processes
Browse files Browse the repository at this point in the history
  • Loading branch information
harrellbm committed Jun 18, 2023
1 parent 4f1791d commit 370e95e
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,20 @@ exports.newDataMiningBotModulesFromOneMinToMultiTimeFrameDaily = function (proce

filePath += '/' + fileName

fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated)
if (fileContent !== '[]') {

TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[INFO] start -> writeOutputFile -> creating file at filePath = " + filePath)
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated)

TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[INFO] start -> writeOutputFile -> creating file at filePath = " + filePath)
} else {
TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[INFO] start -> writeOutputFile -> No Data to save for File @ " +
TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "_" +
TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + ", " +
" filePath = " + filePath)
callBack()
}

function onFileCreated(err) {
if (err.result !== TS.projects.foundations.globals.standardResponses.DEFAULT_OK_RESPONSE.result) {
Expand All @@ -199,7 +209,7 @@ exports.newDataMiningBotModulesFromOneMinToMultiTimeFrameDaily = function (proce
}

TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[WARN] start -> writeOutputFile -> onFileCreated -> Finished with File @ " +
"[INFO] start -> writeOutputFile -> onFileCreated -> Finished with File @ " +
TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "_" +
TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + ", " +
" filePath = " + filePath + "/" + fileName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,20 @@ exports.newDataMiningBotModulesFromOneMinToMultiTimeFrameMarket = function (proc
TIME_FRAME_LABEL
filePath += '/' + fileName

fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated)
if (fileContent !== '[]') {

fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated)

TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[INFO] start -> writeOutputFile -> creating file at filePath = " + filePath)
TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[INFO] start -> writeOutputFile -> creating file at filePath = " + filePath)
} else {
TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[INFO] start -> writeOutputFile -> No Data to save for File @ " +
TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "_" +
TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + ", " +
" filePath = " + filePath)
callBack()
}

function onFileCreated(err) {
if (err.result !== TS.projects.foundations.globals.standardResponses.DEFAULT_OK_RESPONSE.result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ exports.newDataMiningBotModulesScanDatabase = function (processIndex) {
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 + 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);
beginingOfMarket = new Date(thisReport.file.beginingOfMarket);
lastFile = new Date(thisReport.file.lastFile);
defineSince()
secondCallBack(dbPath, dbTable, dbTimestamp, thisReport.file.lastRun, processAndSaveMessages)

Expand Down Expand Up @@ -792,20 +792,8 @@ exports.newDataMiningBotModulesScanDatabase = function (processIndex) {
try {
if (lastFile === undefined) { return }
thisReport.file = {
lastFile: {
year: lastFile.getUTCFullYear(),
month: (lastFile.getUTCMonth() + 1),
days: lastFile.getUTCDate(),
hours: lastFile.getUTCHours(),
minutes: lastFile.getUTCMinutes()
},
beginingOfMarket: {
year: beginingOfMarket.getUTCFullYear(),
month: (beginingOfMarket.getUTCMonth() + 1),
days: beginingOfMarket.getUTCDate(),
hours: beginingOfMarket.getUTCHours(),
minutes: beginingOfMarket.getUTCMinutes()
},
lastFile: lastFile.toUTCString(),
beginingOfMarket: beginingOfMarket.toUTCString(),
uiStartDate: uiStartDate.toUTCString(),
lastRun: (new Date()).toUTCString(),
mustLoadRawData: mustLoadRawData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,16 +480,53 @@ exports.newFoundationsFunctionLibrariesFromOneMinToMultiTimeFrameFunctions = fun
*/
let outputElement = {} // This will be the object that we will eventually save.
let outputElementAverage = {} // We will use this object to help us aggregate values by calculating an average.
/*
Check that the record properties for this element have a valid aggreagation method before we begin
*/
checkAggregationMethods()

function checkAggregationMethods() {
// Throw an error if a record property does not have a supported aggregation method. Excluding begin and end
for (let j = 0; j < node.outputDataset.referenceParent.parentNode.record.properties.length; j++) {
let property = node.outputDataset.referenceParent.parentNode.record.properties[j]
let name = property.config.codeName
let method = property.config.aggregationMethod
if (name == 'begin' || name == 'end') { continue }

if (method == 'First' ||
method == 'Last' ||
method == 'Min' ||
method == 'Max' ||
method == 'Sum' ||
method == 'Avg' ||
method == 'Concat') {
continue
} else {
let errMessage
if (method === undefined ) {
errMessage = "No aggregation method defined!\n" +
"Please add an aggregationMethod config property to the record property node of: " +
" this process.\n" +
property.config.codeName +
"Accepted aggregation methods are: First, Last, Min, Max, Sum, Avg, Concat"
} else {
errMessage = "unsupported aggregation method -> " + property.config.aggregationMethod +
" in record property: " + property.config.codeName
}
SA.logger.error(errMessage)
throw new Error(errMessage)
}
}
}

/*
Set the output element the default values for each of it's properties.
*/
for (let j = 0; j < node.outputDataset.referenceParent.parentNode.record.properties.length; j++) {
let property = node.outputDataset.referenceParent.parentNode.record.properties[j]

if (property.config.isString === true) {
let recordsValues = JSON.parse(JSON.stringify(dependencyDailyFile))
let stringRecordsValues = JSON.stringify(recordsValues)
outputElement[property.config.codeName] = stringRecordsValues // Default Value to String
outputElement[property.config.codeName] = "" // Default Value to String
}
else if (property.config.isDate === true) {
outputElement[property.config.codeName] = "" // Default Value
Expand Down

0 comments on commit 370e95e

Please sign in to comment.