bot.processNode cleaned

This commit is contained in:
Luis Fernando Molina committed 2020-11-28 15:47:40 +01:00
1 parent 513fb00abb
commit 8620b24f17
30 files changed
+104 -106

No files matched your search

@@ -1,4 +1,4 @@
exports.newAnnouncements = function newAnnouncements(bot, logger) {
exports.newAnnouncements = function (processIndex, bot, logger) {
const MODULE_NAME = 'Announcements'
@@ -1,4 +1,4 @@
exports.newExchangeAPI = function newExchangeAPI(bot, logger) {
exports.newExchangeAPI = function (processIndex, bot, logger) {
let MODULE_NAME = "Exchange API";
+1 -1
View File
@@ -1,4 +1,4 @@
exports.newSnapshots = function newSnapshots(bot, logger) {
exports.newSnapshots = function (processIndex, bot, logger) {
/*
This module encapsulates the snapshots functionality.
*/
@@ -1,4 +1,4 @@
exports.newTradingEpisode = function newTradingEpisode(bot, logger, tradingEngineModule) {
exports.newTradingEpisode = function (processIndex, bot, logger, tradingEngineModule) {
/*
This module packages all functions related to Episodes.
*/
@@ -1,4 +1,4 @@
exports.newTradingExecution = function newTradingExecution(bot, logger, tradingEngineModule) {
exports.newTradingExecution = function (processIndex, bot, logger, tradingEngineModule) {
/*
The Trading Execution modules manages the execution nodes and execution algoritms.
*/
@@ -17,7 +17,7 @@ exports.newTradingExecution = function newTradingExecution(bot, logger, tradingE
let sessionParameters
const TRADING_ORDERS_MODULE = require('./TradingOrders.js')
let tradingOrdersModule = TRADING_ORDERS_MODULE.newTradingOrders(bot, logger, tradingEngineModule)
let tradingOrdersModule = TRADING_ORDERS_MODULE.newTradingOrders(processIndex, bot, logger, tradingEngineModule)
return thisObject
@@ -1,4 +1,4 @@
exports.newTradingOrders = function newTradingOrders(bot, logger, tradingEngineModule) {
exports.newTradingOrders = function (processIndex, bot, logger, tradingEngineModule) {
/*
The Trading Orders modules manages the execution of orders against the exchanges.
*/
@@ -17,10 +17,10 @@ exports.newTradingOrders = function newTradingOrders(bot, logger, tradingEngineM
let sessionParameters
const EXCHANGE_API_MODULE = require('./ExchangeAPI.js')
let exchangeAPIModule = EXCHANGE_API_MODULE.newExchangeAPI(bot, logger)
let exchangeAPIModule = EXCHANGE_API_MODULE.newExchangeAPI(processIndex, bot, logger)
const ANNOUNCEMENTS_MODULE = require('./Announcements.js')
let announcementsModule = ANNOUNCEMENTS_MODULE.newAnnouncements(bot, logger)
let announcementsModule = ANNOUNCEMENTS_MODULE.newAnnouncements(processIndex, bot, logger)
return thisObject
@@ -40,7 +40,7 @@ exports.newTradingOutput = function (processIndex, bot, logger, tradingEngineMod
const TRADING_SIMULATION = require('./TradingSimulation.js')
let tradingSimulation = TRADING_SIMULATION.newTradingSimulation(processIndex, bot, logger, tradingEngineModule, UTILITIES)
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset')
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasetsMap = new Map()
if (bot.processingDailyFiles === true) {
@@ -1,4 +1,4 @@
exports.newTradingPosition = function newTradingPosition(bot, logger, tradingEngineModule) {
exports.newTradingPosition = function (processIndex, bot, logger, tradingEngineModule) {
/*
This module packages all functions related to Positions.
*/
@@ -555,7 +555,7 @@
let mainDependency = {}
/* The first phase here is about checking that we have everything we need at the definition level. */
let dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processDependencies, 'Data Dependency')
let dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency')
/*
We will filter ourt declared dependencies that are not present in the workspace.
This will allow the user to have less Data Mines loaded at the workspace
@@ -565,7 +565,7 @@
if (commons.validateDataDependencies(dataDependencies, callBackFunction) !== true) { return }
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset')
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
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. */
@@ -624,7 +624,7 @@
}
async function writeProcessFiles() {
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset')
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
await writeTimeFramesFiles(currentTimeFrame, currentTimeFrameLabel)
await writeDataRanges()
@@ -703,7 +703,7 @@
}
async function writeDailyStatusReport(currentTimeFrameLabel) {
let reportKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + bot.codeName + "-" + bot.processNode.referenceParent.config.codeName
let reportKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + bot.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName
let thisReport = statusDependencies.statusReports.get(reportKey)
thisReport.file.lastExecution = bot.currentDaytime
@@ -714,7 +714,7 @@
}
async function writeMarketStatusReport(currentTimeFrameLabel) {
let reportKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + bot.codeName + "-" + bot.processNode.referenceParent.config.codeName
let reportKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + bot.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName
let thisReport = statusDependencies.statusReports.get(reportKey);
thisReport.file.lastExecution = bot.processDatetime
@@ -1,4 +1,4 @@
exports.newTradingRecords = function newTradingRecords(bot, logger) {
exports.newTradingRecords = function (processIndex, bot, logger) {
/*
This module facilitates the appending of records to the output of the process.
*/
@@ -37,7 +37,7 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
we have a pointer to the node that have the information we need to extract.
Later, based on the product record definition we will extract each individual value.
*/
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset')
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
for (let i = 0; i < outputDatasets.length; i++) {
let outputDatasetNode = outputDatasets[i]
@@ -35,15 +35,15 @@ exports.newTradingSimulation = function (processIndex, bot, logger, tradingEngin
/* These are the Modules we will need to run the Simulation */
const TRADING_RECORDS_MODULE = require('./TradingRecords.js')
let tradingRecordsModule = TRADING_RECORDS_MODULE.newTradingRecords(bot, logger)
let tradingRecordsModule = TRADING_RECORDS_MODULE.newTradingRecords(processIndex, bot, logger)
tradingRecordsModule.initialize(outputDatasetsMap)
const TRADING_SYSTEM_MODULE = require('./TradingSystem.js')
let tradingSystemModule = TRADING_SYSTEM_MODULE.newTradingSystem(bot, logger, tradingEngineModule)
let tradingSystemModule = TRADING_SYSTEM_MODULE.newTradingSystem(processIndex, bot, logger, tradingEngineModule)
tradingSystemModule.initialize()
const TRADING_EPISODE_MODULE = require('./TradingEpisode.js')
let tradingEpisodeModule = TRADING_EPISODE_MODULE.newTradingEpisode(bot, logger, tradingEngineModule)
let tradingEpisodeModule = TRADING_EPISODE_MODULE.newTradingEpisode(processIndex, bot, logger, tradingEngineModule)
tradingEpisodeModule.initialize()
/* Setting up the candles array: The whole simulation is based on the array of candles at the time-frame defined at the session parameters. */
@@ -313,7 +313,7 @@ exports.newTradingSimulation = function (processIndex, bot, logger, tradingEngin
easy access to the current candle for instance, or the current bollinger band, meaning the one the Simulation is currently standing at.
For that reason we do the following processing, to have at the chart data structure the current objects of each indicator / time frame.
*/
let dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processDependencies, 'Data Dependency')
let dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency')
dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies)
/* Finding the Current Element on Market Files */
@@ -1,4 +1,4 @@
exports.newTradingStages = function newTradingStages(bot, logger, tradingEngineModule) {
exports.newTradingStages = function (processIndex, bot, logger, tradingEngineModule) {
/*
This module packages all functions related to Stages.
*/
@@ -21,22 +21,22 @@ exports.newTradingStages = function newTradingStages(bot, logger, tradingEngineM
}
const TRADING_STRATEGY_MODULE = require('./TradingStrategy.js')
let tradingStrategyModule = TRADING_STRATEGY_MODULE.newTradingStrategy(bot, logger, tradingEngineModule)
let tradingStrategyModule = TRADING_STRATEGY_MODULE.newTradingStrategy(processIndex, bot, logger, tradingEngineModule)
const TRADING_POSITION_MODULE = require('./TradingPosition.js')
let tradingPositionModule = TRADING_POSITION_MODULE.newTradingPosition(bot, logger, tradingEngineModule)
let tradingPositionModule = TRADING_POSITION_MODULE.newTradingPosition(processIndex, bot, logger, tradingEngineModule)
const TRADING_ENGINE_EXECUTION = require('./TradingExecution.js')
let tradingExecutionModule = TRADING_ENGINE_EXECUTION.newTradingExecution(bot, logger, tradingEngineModule)
let tradingExecutionModule = TRADING_ENGINE_EXECUTION.newTradingExecution(processIndex, bot, logger, tradingEngineModule)
const ANNOUNCEMENTS_MODULE = require('./Announcements.js')
let announcementsModule = ANNOUNCEMENTS_MODULE.newAnnouncements(bot, logger)
let announcementsModule = ANNOUNCEMENTS_MODULE.newAnnouncements(processIndex, bot, logger)
const SNAPSHOTS_MODULE = require('./Snapshots.js')
let snapshotsModule = SNAPSHOTS_MODULE.newSnapshots(bot, logger)
let snapshotsModule = SNAPSHOTS_MODULE.newSnapshots(processIndex, bot, logger)
const TRADING_EPISODE_MODULE = require('./TradingEpisode.js')
let tradingEpisodeModule = TRADING_EPISODE_MODULE.newTradingEpisode(bot, logger)
let tradingEpisodeModule = TRADING_EPISODE_MODULE.newTradingEpisode(processIndex, bot, logger)
let tradingEngine
let tradingSystem
@@ -907,7 +907,7 @@ exports.newTradingStages = function newTradingStages(bot, logger, tradingEngineM
case 'Base Asset': {
if (
(
tradingEngineStage.stageBaseAsset.sizeFilled.value
tradingEngineStage.stageBaseAsset.sizeFilled.value
)
* ROUNDING_ERROR_CORRECTION_FACTOR
>=
@@ -922,7 +922,7 @@ exports.newTradingStages = function newTradingStages(bot, logger, tradingEngineM
case 'Quoted Asset': {
if (
(
tradingEngineStage.stageQuotedAsset.sizeFilled.value
tradingEngineStage.stageQuotedAsset.sizeFilled.value
)
* ROUNDING_ERROR_CORRECTION_FACTOR
>=
@@ -1,4 +1,4 @@
exports.newTradingStrategy = function newTradingStrategy(bot, logger, tradingEngineModule) {
exports.newTradingStrategy = function (processIndex, bot, logger, tradingEngineModule) {
/*
This module packages all functions related to Strategies.
*/
@@ -1,4 +1,4 @@
exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineModule) {
exports.newTradingSystem = function (processIndex, bot, logger, tradingEngineModule) {
/*
The Trading System is the user defined set of rules compliant with the Trading Protocol that
defines the trading logic to be applied during each cycle of the Simulation.
@@ -20,7 +20,7 @@ exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineM
let dynamicIndicators
const TRADING_STAGES_MODULE = require('./TradingStages.js')
let tradingStagesModule = TRADING_STAGES_MODULE.newTradingStages(bot, logger, tradingEngineModule)
let tradingStagesModule = TRADING_STAGES_MODULE.newTradingStages(processIndex, bot, logger, tradingEngineModule)
return thisObject