Time Frames from global framework

This commit is contained in:
Luis Fernando Molina committed 2020-11-27 12:53:21 +01:00
1 parent 4b5c2abf3e
commit 2ded6a45b1
12 files changed
+69 -96

No files matched your search

+2
View File
@@ -1,6 +1,8 @@
INTER_PROCESS_FILES_PATH=../Inter-Process-Files
STORAGE_PATH=../Data-Storage
REQUIRED_PROJECTS_PATH=../Projects
PROJECTS_PATH=../Projects
USE_KEYVAULT=false
-30
View File
@@ -38,36 +38,6 @@ exports.newGlobals = function newGlobals() {
global.EXECUTION_DATETIME = new Date();
/* Time Frames Definitions. */
global.marketFilesPeriods =
'[' +
'[' + 24 * 60 * 60 * 1000 + ',' + '"24-hs"' + ']' + ',' +
'[' + 12 * 60 * 60 * 1000 + ',' + '"12-hs"' + ']' + ',' +
'[' + 8 * 60 * 60 * 1000 + ',' + '"08-hs"' + ']' + ',' +
'[' + 6 * 60 * 60 * 1000 + ',' + '"06-hs"' + ']' + ',' +
'[' + 4 * 60 * 60 * 1000 + ',' + '"04-hs"' + ']' + ',' +
'[' + 3 * 60 * 60 * 1000 + ',' + '"03-hs"' + ']' + ',' +
'[' + 2 * 60 * 60 * 1000 + ',' + '"02-hs"' + ']' + ',' +
'[' + 1 * 60 * 60 * 1000 + ',' + '"01-hs"' + ']' + ']';
global.marketFilesPeriods = JSON.parse(global.marketFilesPeriods);
global.dailyFilePeriods =
'[' +
'[' + 45 * 60 * 1000 + ',' + '"45-min"' + ']' + ',' +
'[' + 40 * 60 * 1000 + ',' + '"40-min"' + ']' + ',' +
'[' + 30 * 60 * 1000 + ',' + '"30-min"' + ']' + ',' +
'[' + 20 * 60 * 1000 + ',' + '"20-min"' + ']' + ',' +
'[' + 15 * 60 * 1000 + ',' + '"15-min"' + ']' + ',' +
'[' + 10 * 60 * 1000 + ',' + '"10-min"' + ']' + ',' +
'[' + 05 * 60 * 1000 + ',' + '"05-min"' + ']' + ',' +
'[' + 04 * 60 * 1000 + ',' + '"04-min"' + ']' + ',' +
'[' + 03 * 60 * 1000 + ',' + '"03-min"' + ']' + ',' +
'[' + 02 * 60 * 1000 + ',' + '"02-min"' + ']' + ',' +
'[' + 01 * 60 * 1000 + ',' + '"01-min"' + ']' + ']';
global.dailyFilePeriods = JSON.parse(global.dailyFilePeriods);
global.ROOT_DIR = './';
+6 -6
View File
@@ -410,18 +410,18 @@ exports.newLearningSession = function newLearningSession(bot, parentLogger) {
function getTimeFrameFromLabel(timeFrameLabel) {
for (let i = 0; i < global.marketFilesPeriods.length; i++) {
let value = global.marketFilesPeriods[i][0]
let label = global.marketFilesPeriods[i][1]
for (let i = 0; i < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; i++) {
let value = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[i][0]
let label = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[i][1]
if (timeFrameLabel === label) {
return value
}
}
for (let i = 0; i < global.dailyFilePeriods.length; i++) {
let value = global.dailyFilePeriods[i][0]
let label = global.dailyFilePeriods[i][1]
for (let i = 0; i < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; i++) {
let value = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[i][0]
let label = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[i][1]
if (timeFrameLabel === label) {
return value
@@ -30,7 +30,7 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, tradingEngineM
async function start(chart, timeFrame, timeFrameLabel, tradingProcessDate) {
try {
if (timeFrame > global.dailyFilePeriods[0][0]) {
if (timeFrame > TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[0][0]) {
bot.processingDailyFiles = false
} else {
bot.processingDailyFiles = true
@@ -365,15 +365,15 @@
We will iterate through all posible timeFrames.
*/
for (let n = 0; n < global.marketFilesPeriods.length; n++) {
const timeFrame = global.marketFilesPeriods[n][0];
const timeFrameLabel = global.marketFilesPeriods[n][1];
for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; n++) {
const timeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0];
const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1];
dataFiles = new Map();
if (bot.TRADING_SESSION.tradingParameters.timeFrame.config.label === timeFrameLabel) {
currentTimeFrame = global.marketFilesPeriods[n][0];
currentTimeFrameLabel = global.marketFilesPeriods[n][1];
currentTimeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0];
currentTimeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1];
}
for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.nodeArray.length; dependencyIndex++) {
let dependency = dataDependenciesModule.nodeArray[dependencyIndex];
@@ -439,7 +439,7 @@
}
}
let mapKey = global.marketFilesPeriods[n][1];
let mapKey = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1];
multiPeriodDataFiles.set(mapKey, dataFiles)
}
return true
@@ -453,9 +453,9 @@
/*
We will iterate through all posible timeFrames.
*/
for (let n = 0; n < global.dailyFilePeriods.length; n++) {
const timeFrame = global.dailyFilePeriods[n][0];
const timeFrameLabel = global.dailyFilePeriods[n][1];
for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; n++) {
const timeFrame = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][0];
const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1];
if (processConfig.framework.validtimeFrames !== undefined) {
let validPeriod = false;
@@ -469,8 +469,8 @@
}
if (bot.TRADING_SESSION.tradingParameters.timeFrame.config.label === timeFrameLabel) {
currentTimeFrame = global.dailyFilePeriods[n][0];
currentTimeFrameLabel = global.dailyFilePeriods[n][1];
currentTimeFrame = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][0];
currentTimeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1];
}
dataFiles = new Map();
@@ -516,7 +516,7 @@
dataFiles.set(dependency.id, dataFile);
}
let mapKey = global.dailyFilePeriods[n][1];
let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1];
multiPeriodDataFiles.set(mapKey, dataFiles)
}
return true
@@ -569,8 +569,8 @@
if (commons.validateOutputDatasets(outputDatasets, callBackFunction) !== true) { return }
/* The second phase is about transforming the inputs into a format that can be used to apply the user defined code. */
for (let j = 0; j < global.marketFilesPeriods.length; j++) {
let timeFrameLabel = marketFilesPeriods[j][1]
for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; j++) {
let timeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[j][1]
let dataFiles = multiPeriodDataFiles.get(timeFrameLabel)
let products = {}
@@ -582,8 +582,8 @@
}
}
for (let j = 0; j < global.dailyFilePeriods.length; j++) {
let timeFrameLabel = global.dailyFilePeriods[j][1]
for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; j++) {
let timeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[j][1]
let dataFiles = multiPeriodDataFiles.get(timeFrameLabel)
let products = {}
@@ -629,7 +629,7 @@
await writeTimeFramesFiles(currentTimeFrame, currentTimeFrameLabel)
await writeDataRanges()
if (currentTimeFrame > global.dailyFilePeriods[0][0]) {
if (currentTimeFrame > TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[0][0]) {
await writeMarketStatusReport(currentTimeFrameLabel)
} else {
await writeDailyStatusReport(currentTimeFrameLabel)
@@ -318,8 +318,8 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
/* Finding the Current Element on Market Files */
if (bot.processingDailyFiles) {
for (let j = 0; j < global.dailyFilePeriods.length; j++) {
let mapKey = dailyFilePeriods[j][1]
for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; j++) {
let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[j][1]
let propertyName = 'at' + mapKey.replace('-', '')
let thisChart = chart[propertyName]
@@ -339,8 +339,8 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
}
/* Finding the Current Element on Market Files */
for (let j = 0; j < global.marketFilesPeriods.length; j++) {
let mapKey = marketFilesPeriods[j][1]
for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; j++) {
let mapKey = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[j][1]
let propertyName = 'at' + mapKey.replace('-', '')
let thisChart = chart[propertyName]
+6 -6
View File
@@ -199,7 +199,7 @@
*/
bootstrappingTheProcess = true
for (let i = 0; i < global.dailyFilePeriods.length; i++) {
for (let i = 0; i < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; i++) {
let emptyObject = {};
interExecutionMemoryArray.push(emptyObject)
}
@@ -275,8 +275,8 @@
function timeFramesLoopBody() {
const timeFrame = global.dailyFilePeriods[n][0]
const timeFrameLabel = global.dailyFilePeriods[n][1]
const timeFrame = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][0]
const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1]
/* Check Time Frames Filter */
if (bot.dailyTimeFrames !== undefined) {
@@ -448,7 +448,7 @@
function timeFramesControlLoop() {
n++
if (n < global.dailyFilePeriods.length) {
if (n < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length) {
timeFramesLoopBody()
} else {
n = 0;
@@ -516,8 +516,8 @@
function writeTimeFramesFile(productCodeName, callBack) {
let timeFramesArray = []
for (let n = 0; n < global.dailyFilePeriods.length; n++) {
let timeFrameLabel = global.dailyFilePeriods[n][1]
for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; n++) {
let timeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1]
/* Check Time Frames Filter */
if (bot.dailyTimeFrames !== undefined) {
+5 -5
View File
@@ -56,8 +56,8 @@
}
function timeFramesLoopBody() {
const timeFrame = global.marketFilesPeriods[n][0]
const timeFrameLabel = global.marketFilesPeriods[n][1]
const timeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0]
const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1]
/* Check Time Frames Filter */
if (bot.marketTimeFrames !== undefined) {
@@ -129,7 +129,7 @@
function timeFramesControlLoop() {
n++;
if (n < global.marketFilesPeriods.length) {
if (n < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length) {
timeFramesLoopBody()
} else {
writeTimeFramesFiles(onTimeFrameFilesWritten)
@@ -163,8 +163,8 @@
function writeTimeFramesFile(productCodeName, callBack) {
let timeFramesArray = []
for (let n = 0; n < global.marketFilesPeriods.length; n++) {
let timeFrameLabel = global.marketFilesPeriods[n][1]
for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; n++) {
let timeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1]
/* Check Time Frames Filter */
if (bot.marketTimeFrames !== undefined) {
@@ -365,15 +365,15 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES)
We will iterate through all posible timeFrames.
*/
for (let n = 0; n < global.marketFilesPeriods.length; n++) {
const timeFrame = global.marketFilesPeriods[n][0];
const timeFrameLabel = global.marketFilesPeriods[n][1];
for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; n++) {
const timeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0];
const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1];
dataFiles = new Map();
if (bot.TRADING_SESSION.tradingParameters.timeFrame.config.label === timeFrameLabel) {
currentTimeFrame = global.marketFilesPeriods[n][0];
currentTimeFrameLabel = global.marketFilesPeriods[n][1];
currentTimeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0];
currentTimeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1];
}
for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.nodeArray.length; dependencyIndex++) {
let dependency = dataDependenciesModule.nodeArray[dependencyIndex];
@@ -439,7 +439,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES)
}
}
let mapKey = global.marketFilesPeriods[n][1];
let mapKey = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1];
multiPeriodDataFiles.set(mapKey, dataFiles)
}
return true
@@ -453,9 +453,9 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES)
/*
We will iterate through all posible timeFrames.
*/
for (let n = 0; n < global.dailyFilePeriods.length; n++) {
const timeFrame = global.dailyFilePeriods[n][0];
const timeFrameLabel = global.dailyFilePeriods[n][1];
for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; n++) {
const timeFrame = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][0];
const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1];
if (processConfig.framework.validtimeFrames !== undefined) {
let validPeriod = false;
@@ -469,8 +469,8 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES)
}
if (bot.TRADING_SESSION.tradingParameters.timeFrame.config.label === timeFrameLabel) {
currentTimeFrame = global.dailyFilePeriods[n][0];
currentTimeFrameLabel = global.dailyFilePeriods[n][1];
currentTimeFrame = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][0];
currentTimeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1];
}
dataFiles = new Map();
@@ -516,7 +516,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES)
dataFiles.set(dependency.id, dataFile);
}
let mapKey = global.dailyFilePeriods[n][1];
let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1];
multiPeriodDataFiles.set(mapKey, dataFiles)
}
return true
@@ -569,8 +569,8 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES)
if (commons.validateOutputDatasets(outputDatasets, callBackFunction) !== true) { return }
/* The second phase is about transforming the inputs into a format that can be used to apply the user defined code. */
for (let j = 0; j < global.marketFilesPeriods.length; j++) {
let timeFrameLabel = marketFilesPeriods[j][1]
for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; j++) {
let timeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[j][1]
let dataFiles = multiPeriodDataFiles.get(timeFrameLabel)
let products = {}
@@ -582,8 +582,8 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES)
}
}
for (let j = 0; j < global.dailyFilePeriods.length; j++) {
let timeFrameLabel = global.dailyFilePeriods[j][1]
for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; j++) {
let timeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[j][1]
let dataFiles = multiPeriodDataFiles.get(timeFrameLabel)
let products = {}
@@ -629,7 +629,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES)
await writeTimeFramesFiles(currentTimeFrame, currentTimeFrameLabel)
await writeDataRanges()
if (currentTimeFrame > global.dailyFilePeriods[0][0]) {
if (currentTimeFrame > TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[0][0]) {
await writeMarketStatusReport(currentTimeFrameLabel)
} else {
await writeDailyStatusReport(currentTimeFrameLabel)
+4 -4
View File
@@ -104,7 +104,7 @@ function setupUpTS() {
if (projectDefinition.TS.utilities !== undefined) {
for (let j = 0; j < projectDefinition.TS.utilities.length; j++) {
let utilityDefinition = projectDefinition.TS.utilities[j]
let path = process.env.PROJECTS_PATH + '/' + projectDefinition.name + '/' + 'TS' + '/' + 'Utilities' + '/' + utilityDefinition.fileName
let path = process.env.REQUIRED_PROJECTS_PATH + '/' + projectDefinition.name + '/' + 'TS' + '/' + 'Utilities' + '/' + utilityDefinition.fileName
let requiredObject = require(path)
let requiredFunction = requiredObject[utilityDefinition.functionName]
@@ -116,7 +116,7 @@ function setupUpTS() {
if (projectDefinition.TS.globals !== undefined) {
for (let j = 0; j < projectDefinition.TS.globals.length; j++) {
let globalDefinition = projectDefinition.TS.globals[j]
let path = process.env.PROJECTS_PATH + '/' + projectDefinition.name + '/' + 'TS' + '/' + 'Globals' + '/' + globalDefinition.fileName
let path = process.env.REQUIRED_PROJECTS_PATH + '/' + projectDefinition.name + '/' + 'TS' + '/' + 'Globals' + '/' + globalDefinition.fileName
let requiredObject = require(path)
let requiredFunction = requiredObject[globalDefinition.functionName]
@@ -128,7 +128,7 @@ function setupUpTS() {
if (projectDefinition.TS.functionLibraries !== undefined) {
for (let j = 0; j < projectDefinition.TS.functionLibraries.length; j++) {
let functionLibraryDefinition = projectDefinition.TS.functionLibraries[j]
let path = process.env.PROJECTS_PATH + '/' + projectDefinition.name + '/' + 'TS' + '/' + 'Function-Libraries' + '/' + functionLibraryDefinition.fileName
let path = process.env.REQUIRED_PROJECTS_PATH + '/' + projectDefinition.name + '/' + 'TS' + '/' + 'Function-Libraries' + '/' + functionLibraryDefinition.fileName
let requiredObject = require(path)
let requiredFunction = requiredObject[functionLibraryDefinition.functionName]
@@ -140,7 +140,7 @@ function setupUpTS() {
if (projectDefinition.TS.botClasses !== undefined) {
for (let j = 0; j < projectDefinition.TS.botClasses.length; j++) {
let botClassDefinition = projectDefinition.TS.botClasses[j]
let path = process.env.PROJECTS_PATH + '/' + projectDefinition.name + '/' + 'TS' + '/' + 'Bot-Classes' + '/' + botClassDefinition.fileName
let path = process.env.REQUIRED_PROJECTS_PATH + '/' + projectDefinition.name + '/' + 'TS' + '/' + 'Bot-Classes' + '/' + botClassDefinition.fileName
let requiredObject = require(path)
let requiredFunction = requiredObject[botClassDefinition.functionName]
+6 -6
View File
@@ -410,18 +410,18 @@
function getTimeFrameFromLabel(timeFrameLabel) {
for (let i = 0; i < global.marketFilesPeriods.length; i++) {
let value = global.marketFilesPeriods[i][0]
let label = global.marketFilesPeriods[i][1]
for (let i = 0; i < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; i++) {
let value = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[i][0]
let label = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[i][1]
if (timeFrameLabel === label) {
return value
}
}
for (let i = 0; i < global.dailyFilePeriods.length; i++) {
let value = global.dailyFilePeriods[i][0]
let label = global.dailyFilePeriods[i][1]
for (let i = 0; i < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; i++) {
let value = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[i][0]
let label = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[i][1]
if (timeFrameLabel === label) {
return value