processIndex everywhere

This commit is contained in:
Luis Fernando Molina committed 2020-11-28 12:30:06 +01:00
1 parent 72a79ec5cf
commit e10465b049
25 files changed
+50 -50

No files matched your search

@@ -1,4 +1,4 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) {
exports.newUserBot = function (processIndex, bot, logger, COMMONS, UTILITIES, FILE_STORAGE) {
const FULL_LOG = true;
const INTENSIVE_LOG = false;
@@ -1,4 +1,4 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) {
exports.newUserBot = function (processIndex, bot, logger, COMMONS, UTILITIES, FILE_STORAGE) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
@@ -1,4 +1,4 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) {
exports.newUserBot = function (processIndex, bot, logger, COMMONS, UTILITIES, FILE_STORAGE) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
@@ -1,4 +1,4 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) {
exports.newUserBot = function (processIndex, bot, logger, COMMONS, UTILITIES, FILE_STORAGE) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
@@ -1,5 +1,5 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE, STATUS_REPORT, EXCHANGE_API) {
exports.newUserBot = function (processIndex, bot, logger, COMMONS, UTILITIES, FILE_STORAGE, STATUS_REPORT, EXCHANGE_API) {
const FULL_LOG = true;
const GMT_SECONDS = ':00.000 GMT+0000';
@@ -1,5 +1,5 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE, STATUS_REPORT, EXCHANGE_API) {
exports.newUserBot = function (processIndex, bot, logger, COMMONS, UTILITIES, FILE_STORAGE, STATUS_REPORT, EXCHANGE_API) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
@@ -1,5 +1,5 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE, STATUS_REPORT, EXCHANGE_API) {
exports.newUserBot = function (processIndex, bot, logger, COMMONS, UTILITIES, FILE_STORAGE, STATUS_REPORT, EXCHANGE_API) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
+2 -2
View File
@@ -1,4 +1,4 @@
exports.newDataDependencies = function newDataDependencies(BOT, logger, DATA_SET) {
exports.newDataDependencies = function (processIndex, BOT, logger, DATA_SET) {
const MODULE_NAME = "Data Dependencies";
@@ -75,7 +75,7 @@
let newNodeArray = []
for (let i = 0; i < thisObject.nodeArray.length; i++) {
let dataSetModule = DATA_SET.newDataSet(BOT, logger);
let dataSetModule = DATA_SET.newDataSet(processIndex, BOT, logger);
dataSetModule.initialize(thisObject.nodeArray[i], onInitilized);
function onInitilized(err, wasInitialized) {
+1 -1
View File
@@ -1,4 +1,4 @@
exports.newDataSet = function newDataSet(BOT, logger) {
exports.newDataSet = function (processIndex, BOT, logger) {
const MODULE_NAME = "Dataset";
+1 -1
View File
@@ -1,4 +1,4 @@
exports.newDebugLog = function newDebugLog() {
exports.newDebugLog = function (processIndex) {
const MODULE_NAME = "DebugLog";
+7 -7
View File
@@ -106,7 +106,7 @@
if (logger !== undefined) {
logger.finalize()
}
logger = DEBUG_MODULE.newDebugLog();
logger = DEBUG_MODULE.newDebugLog(processIndex);
TS.projects.superalgos.globals.taskVariables.LOGGER_MAP.set(MODULE_NAME + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].id, logger)
logger.bot = bot;
logger.initialize();
@@ -146,7 +146,7 @@
function initializeProcessExecutionEvents() {
try {
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(bot, logger)
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(processIndex, bot, logger)
processExecutionEvents.initialize(processConfig, onInizialized);
function onInizialized(err) {
@@ -247,7 +247,7 @@
function initializeStatusDependencies() {
try {
statusDependencies = STATUS_DEPENDENCIES.newStatusDependencies(bot, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT);
statusDependencies = STATUS_DEPENDENCIES.newStatusDependencies(processIndex, bot, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT);
statusDependencies.initialize(onInizialized);
function onInizialized(err) {
@@ -295,7 +295,7 @@
function initializeDataDependencies() {
try {
dataDependencies = DATA_DEPENDENCIES.newDataDependencies(bot, logger, DATA_SET);
dataDependencies = DATA_DEPENDENCIES.newDataDependencies(processIndex, bot, logger, DATA_SET);
dataDependencies.initialize(onInizialized);
function onInizialized(err) {
@@ -310,12 +310,12 @@
switch (processConfig.framework.name) {
case 'Multi-Period-Market': {
processFramework = MULTI_PERIOD_MARKET.newMultiPeriodMarket(bot, logger, UTILITIES, FILE_STORAGE);
processFramework = MULTI_PERIOD_MARKET.newMultiPeriodMarket(processIndex, bot, logger, UTILITIES, FILE_STORAGE);
intitializeProcessFramework();
break;
}
case 'Multi-Period-Daily': {
processFramework = MULTI_PERIOD_DAILY.newMultiPeriodDaily(bot, logger, UTILITIES, FILE_STORAGE);
processFramework = MULTI_PERIOD_DAILY.newMultiPeriodDaily(processIndex, bot, logger, UTILITIES, FILE_STORAGE);
intitializeProcessFramework();
break;
}
@@ -367,7 +367,7 @@
function initializeUserBot() {
try {
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, FILE_STORAGE);
usertBot = USER_BOT_MODULE.newUserBot(processIndex, bot, logger, COMMONS_MODULE, UTILITIES, FILE_STORAGE);
usertBot.initialize(statusDependencies, onInizialized);
function onInizialized(err) {
+1 -1
View File
@@ -1,4 +1,4 @@
exports.newIndicatorOutput = function newIndicatorOutput(bot, logger, UTILITIES, FILE_STORAGE) {
exports.newIndicatorOutput = function (processIndex, bot, logger, UTILITIES, FILE_STORAGE) {
const MODULE_NAME = "Indicator Bot";
let thisObject = {
@@ -1,4 +1,4 @@
exports.newTradingOutput = function newTradingOutput(bot, logger, tradingEngineModule, UTILITIES, FILE_STORAGE) {
exports.newTradingOutput = function (processIndex, bot, logger, tradingEngineModule, UTILITIES, FILE_STORAGE) {
/*
This module will load if necesary all the data outputs so that they can be appended with new
records if needed. After running the simulation, it will save all the data outputs.
@@ -38,7 +38,7 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, tradingEngineM
/* Preparing everything for the Simulation */
const TRADING_SIMULATION = require('./TradingSimulation.js')
let tradingSimulation = TRADING_SIMULATION.newTradingSimulation(bot, logger, tradingEngineModule, UTILITIES)
let tradingSimulation = TRADING_SIMULATION.newTradingSimulation(processIndex, bot, logger, tradingEngineModule, UTILITIES)
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset')
let outputDatasetsMap = new Map()
@@ -1,4 +1,4 @@
exports.newTradingProcess = function newTradingProcess(bot, logger, UTILITIES) {
exports.newTradingProcess = function (processIndex, bot, logger, UTILITIES) {
/*
This Module will load all the process data dependencies from files and send them downstream.
After execution, will save the time range and status report of the process.
@@ -27,7 +27,7 @@
let tradingEngineModule = TRADING_ENGINE_MODULE.newTradingEngine(bot, logger)
let TRADING_OUTPUT_MODULE = require("./TradingOutput")
let tradingOutputModule = TRADING_OUTPUT_MODULE.newTradingOutput(bot, logger, tradingEngineModule, UTILITIES, FILE_STORAGE)
let tradingOutputModule = TRADING_OUTPUT_MODULE.newTradingOutput(processIndex, bot, logger, tradingEngineModule, UTILITIES, FILE_STORAGE)
let processConfig;
@@ -1,4 +1,4 @@
exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradingEngineModule, UTILITIES) {
exports.newTradingSimulation = function (processIndex, bot, logger, tradingEngineModule, UTILITIES) {
/*
This Module represents the trading simulacion. Escentially a loop through a set of candles and
the execution at each loop cycle of the Trading System Protocol.
+2 -2
View File
@@ -1,4 +1,4 @@
exports.newMultiPeriodDaily = function newMultiPeriodDaily(bot, logger, UTILITIES, FILE_STORAGE) {
exports.newMultiPeriodDaily = function (processIndex, bot, logger, UTILITIES, FILE_STORAGE) {
const MODULE_NAME = "Multi Period Daily";
const GMT_SECONDS = ':00.000 GMT+0000';
@@ -33,7 +33,7 @@
let INDICATOR_OUTPUT_MODULE = require("./IndicatorOutput")
indicatorOutputModule = INDICATOR_OUTPUT_MODULE.newIndicatorOutput(bot, logger, UTILITIES, FILE_STORAGE)
indicatorOutputModule = INDICATOR_OUTPUT_MODULE.newIndicatorOutput(processIndex, bot, logger, UTILITIES, FILE_STORAGE)
indicatorOutputModule.initialize(callBackFunction)
}
+2 -2
View File
@@ -1,4 +1,4 @@
exports.newMultiPeriodMarket = function newMultiPeriodMarket(bot, logger, UTILITIES, FILE_STORAGE) {
exports.newMultiPeriodMarket = function (processIndex, bot, logger, UTILITIES, FILE_STORAGE) {
const MODULE_NAME = "Multi Period Market";
thisObject = {
initialize: initialize,
@@ -27,7 +27,7 @@
let INDICATOR_OUTPUT_MODULE = require("./IndicatorOutput")
indicatorOutputModule = INDICATOR_OUTPUT_MODULE.newIndicatorOutput(bot, logger, UTILITIES, FILE_STORAGE)
indicatorOutputModule = INDICATOR_OUTPUT_MODULE.newIndicatorOutput(processIndex, bot, logger, UTILITIES, FILE_STORAGE)
indicatorOutputModule.initialize(callBackFunction)
}
+1 -1
View File
@@ -1,4 +1,4 @@
exports.newProcessExecutionEvents = function newProcessExecutionEvents(BOT, logger) {
exports.newProcessExecutionEvents = function (processIndex, BOT, logger) {
/*
Here we manage the process execution events. This allow us to emit events
when the process starts and finishes. Also to wait for a dependent event
+1 -1
View File
@@ -28,7 +28,7 @@
We will use a logger for what happens before and after the bot main loop. We will add the process
id to its key so that it is unique and it can later be finalized.
*/
let logger = DEBUG_MODULE.newDebugLog()
let logger = DEBUG_MODULE.newDebugLog(processIndex)
TS.projects.superalgos.globals.taskVariables.LOGGER_MAP.set('Pre-Bot-Main-Loop' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].id, logger)
logger.bot = botConfig;
@@ -63,7 +63,7 @@ exports.newLearningBot = function newLearningBot(processIndex, bot, parentLogger
if (logger !== undefined) {
logger.finalize()
}
logger = DEBUG_MODULE.newDebugLog();
logger = DEBUG_MODULE.newDebugLog(processIndex);
TS.projects.superalgos.globals.taskVariables.LOGGER_MAP.set(MODULE_NAME + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].id, logger)
logger.bot = bot;
logger.initialize();
@@ -99,9 +99,9 @@ exports.newLearningBot = function newLearningBot(processIndex, bot, parentLogger
if (bot.SESSION_STATUS === 'Running' && bot.STOP_SESSION === true) {
bot.SESSION_STATUS = 'Stopped'
}
}
TS.projects.superalgos.functionLibraries.sessionFunctions.emitSessionStatus (bot.SESSION_STATUS, bot.sessionKey)
TS.projects.superalgos.functionLibraries.sessionFunctions.emitSessionStatus(bot.SESSION_STATUS, bot.sessionKey)
/* Checking if we should process this loop or not.*/
if (bot.STOP_SESSION === true) {
@@ -128,7 +128,7 @@ exports.newLearningBot = function newLearningBot(processIndex, bot, parentLogger
function initializeProcessExecutionEvents() {
try {
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(bot, logger)
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(processIndex, bot, logger)
processExecutionEvents.initialize(processConfig, onInizialized);
function onInizialized(err) {
@@ -229,7 +229,7 @@ exports.newLearningBot = function newLearningBot(processIndex, bot, parentLogger
function initializeStatusDependencies() {
try {
statusDependencies = STATUS_DEPENDENCIES.newStatusDependencies(bot, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT);
statusDependencies = STATUS_DEPENDENCIES.newStatusDependencies(processIndex, bot, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT);
statusDependencies.initialize(onInizialized);
function onInizialized(err) {
@@ -277,7 +277,7 @@ exports.newLearningBot = function newLearningBot(processIndex, bot, parentLogger
function initializeDataDependencies() {
try {
dataDependencies = DATA_DEPENDENCIES.newDataDependencies(bot, logger, DATA_SET);
dataDependencies = DATA_DEPENDENCIES.newDataDependencies(processIndex, bot, logger, DATA_SET);
dataDependencies.initialize(onInizialized);
function onInizialized(err) {
@@ -1,4 +1,4 @@
exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) {
exports.newLearningProcess = function (processIndex, bot, logger, UTILITIES) {
/*
This Module will load all the process data dependencies from files and send them downstream.
After execution, will save the time range and status report of the process.
@@ -27,7 +27,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES)
let markovDecisionProcessModule = MARKOV_DECISION_PROCESS_MODULE.newMarkovDecisionProcess(bot, logger)
let ALGORITHM_MODULE = require("./Algorithm")
let algorithmModule = ALGORITHM_MODULE.newTradingOutput(bot, logger, markovDecisionProcessModule, UTILITIES, FILE_STORAGE)
let algorithmModule = ALGORITHM_MODULE.newTradingOutput(processIndex, bot, logger, markovDecisionProcessModule, UTILITIES, FILE_STORAGE)
let processConfig;
+4 -4
View File
@@ -113,7 +113,7 @@
if (logger !== undefined) {
logger.finalize()
}
logger = DEBUG_MODULE.newDebugLog();
logger = DEBUG_MODULE.newDebugLog(processIndex);
TS.projects.superalgos.globals.taskVariables.LOGGER_MAP.set(MODULE_NAME + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].id, logger)
logger.bot = bot;
logger.initialize();
@@ -150,7 +150,7 @@
function initializeProcessExecutionEvents() {
try {
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(bot, logger)
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(processIndex, bot, logger)
processExecutionEvents.initialize(processConfig, onInizialized);
function onInizialized(err) {
@@ -252,7 +252,7 @@
function initializeStatusDependencies() {
try {
statusDependencies = STATUS_DEPENDENCIES.newStatusDependencies(bot, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT);
statusDependencies = STATUS_DEPENDENCIES.newStatusDependencies(processIndex, bot, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT);
statusDependencies.initialize(onInizialized);
function onInizialized(err) {
@@ -300,7 +300,7 @@
function initializeUserBot() {
try {
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, FILE_STORAGE, STATUS_REPORT, exchangeAPI);
usertBot = USER_BOT_MODULE.newUserBot(processIndex, bot, logger, COMMONS_MODULE, UTILITIES, FILE_STORAGE, STATUS_REPORT, exchangeAPI);
usertBot.initialize(statusDependencies, onInizialized);
function onInizialized(err) {
+2 -2
View File
@@ -1,4 +1,4 @@
exports.newStatusDependencies = function newStatusDependencies(BOT, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT) {
exports.newStatusDependencies = function (processIndex, BOT, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT) {
const MODULE_NAME = "Status Dependencies";
@@ -48,7 +48,7 @@
for (let i = 0; i < dependenciesToProcess.length; i++) {
let statusReportModule = STATUS_REPORT.newStatusReport(BOT, logger, UTILITIES, PROCESS_OUTPUT);
let statusReportModule = STATUS_REPORT.newStatusReport(processIndex, BOT, logger, UTILITIES, PROCESS_OUTPUT);
logger.write(MODULE_NAME, "[INFO] initialize -> onInitilized -> Initializing Status Report # " + (i + 1));
let statusDependency = dependenciesToProcess[i]
+1 -1
View File
@@ -1,4 +1,4 @@
exports.newStatusReport = function newStatusReport(BOT, logger, UTILITIES, PROCESS_OUTPUT) {
exports.newStatusReport = function (processIndex, BOT, logger, UTILITIES, PROCESS_OUTPUT) {
/*
+5 -5
View File
@@ -63,7 +63,7 @@
if (logger !== undefined) {
logger.finalize()
}
logger = DEBUG_MODULE.newDebugLog();
logger = DEBUG_MODULE.newDebugLog(processIndex);
TS.projects.superalgos.globals.taskVariables.LOGGER_MAP.set(MODULE_NAME + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].id, logger)
logger.bot = bot;
logger.initialize();
@@ -128,7 +128,7 @@
function initializeProcessExecutionEvents() {
try {
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(bot, logger)
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(processIndex, bot, logger)
processExecutionEvents.initialize(processConfig, onInizialized);
function onInizialized(err) {
@@ -229,7 +229,7 @@
function initializeStatusDependencies() {
try {
statusDependencies = STATUS_DEPENDENCIES.newStatusDependencies(bot, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT);
statusDependencies = STATUS_DEPENDENCIES.newStatusDependencies(processIndex, bot, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT);
statusDependencies.initialize(onInizialized);
function onInizialized(err) {
@@ -277,7 +277,7 @@
function initializeDataDependencies() {
try {
dataDependencies = DATA_DEPENDENCIES.newDataDependencies(bot, logger, DATA_SET);
dataDependencies = DATA_DEPENDENCIES.newDataDependencies(processIndex, bot, logger, DATA_SET);
dataDependencies.initialize(onInizialized);
function onInizialized(err) {
@@ -287,7 +287,7 @@
logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeDataDependencies -> onInizialized -> Execution finished well.")
switch (processConfig.framework.name) {
case 'Low-Frequency-Trading-Process': {
processFramework = TRADING_PROCESS_MODULE.newTradingProcess(bot, logger, UTILITIES);
processFramework = TRADING_PROCESS_MODULE.newTradingProcess(processIndex, bot, logger, UTILITIES);
intitializeProcessFramework();
break;
}