bot parameter removed from all files

This commit is contained in:
Luis Fernando Molina committed 2020-11-30 19:39:38 +01:00
1 parent 042241de0f
commit 28f4c56d56
49 files changed
+108 -128

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
exports.newCommons = function newCommons(bot, logger, UTILITIES, FILE_STORAGE) {
exports.newCommons = function newCommons(logger, UTILITIES, FILE_STORAGE) {
const MODULE_NAME = "Commons";
+2 -4
View File
@@ -1,9 +1,7 @@
exports.newDataDependencies = function (processIndex, BOT, logger, DATA_SET) {
exports.newDataDependencies = function (processIndex, logger, DATA_SET) {
const MODULE_NAME = "Data Dependencies";
let bot = BOT
let thisObject = {
nodeArray: undefined,
dataSetsModulesArray: [],
@@ -75,7 +73,7 @@
let newNodeArray = []
for (let i = 0; i < thisObject.nodeArray.length; i++) {
let dataSetModule = DATA_SET.newDataSet(processIndex, BOT, logger);
let dataSetModule = DATA_SET.newDataSet(processIndex, logger);
dataSetModule.initialize(thisObject.nodeArray[i], onInitilized);
function onInitilized(err, wasInitialized) {
+1 -3
View File
@@ -1,9 +1,7 @@
exports.newDataSet = function (processIndex, BOT, logger) {
exports.newDataSet = function (processIndex, logger) {
const MODULE_NAME = "Dataset";
let bot = BOT;
let thisObject = {
node: undefined,
networkNode: undefined,
-3
View File
@@ -12,7 +12,6 @@ exports.newDebugLog = function (processIndex) {
let messageId = 0;
let thisObject = {
bot: undefined,
write: write,
newMainLoop: newMainLoop,
newInternalLoop: newInternalLoop,
@@ -171,8 +170,6 @@ exports.newDebugLog = function (processIndex) {
try {
if (disableLogging === true) { return; }
if (thisObject.bot === undefined) { return; }
if (pModule === "") { // For debugging purposes
console.log(pMessage)
}
+8 -9
View File
@@ -1,4 +1,4 @@
exports.newIndicatorBot = function newIndicatorBot(processIndex, bot, parentLogger) {
exports.newIndicatorBot = function newIndicatorBot(processIndex, parentLogger) {
const MODULE_NAME = "Indicator Bot";
@@ -28,7 +28,7 @@
try {
processConfig = pProcessConfig;
if (bot.repo === undefined) {
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.repo === undefined) {
/* The code of the bot is defined at the UI. No need to load a file with the code. */
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE);
return
@@ -99,7 +99,6 @@
}
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();
TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).MAIN_LOOP_COUNTER++;
@@ -135,7 +134,7 @@
function initializeProcessExecutionEvents() {
try {
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(processIndex, bot, logger)
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(processIndex, logger)
processExecutionEvents.initialize(processConfig, onInizialized);
function onInizialized(err) {
@@ -236,7 +235,7 @@
function initializeStatusDependencies() {
try {
statusDependencies = STATUS_DEPENDENCIES.newStatusDependencies(processIndex, bot, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT);
statusDependencies = STATUS_DEPENDENCIES.newStatusDependencies(processIndex, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT);
statusDependencies.initialize(onInizialized);
function onInizialized(err) {
@@ -284,7 +283,7 @@
function initializeDataDependencies() {
try {
dataDependencies = DATA_DEPENDENCIES.newDataDependencies(processIndex, bot, logger, DATA_SET);
dataDependencies = DATA_DEPENDENCIES.newDataDependencies(processIndex, logger, DATA_SET);
dataDependencies.initialize(onInizialized);
function onInizialized(err) {
@@ -299,12 +298,12 @@
switch (processConfig.framework.name) {
case 'Multi-Period-Market': {
processFramework = MULTI_PERIOD_MARKET.newMultiPeriodMarket(processIndex, bot, logger, UTILITIES, FILE_STORAGE);
processFramework = MULTI_PERIOD_MARKET.newMultiPeriodMarket(processIndex, logger, UTILITIES, FILE_STORAGE);
intitializeProcessFramework();
break;
}
case 'Multi-Period-Daily': {
processFramework = MULTI_PERIOD_DAILY.newMultiPeriodDaily(processIndex, bot, logger, UTILITIES, FILE_STORAGE);
processFramework = MULTI_PERIOD_DAILY.newMultiPeriodDaily(processIndex, logger, UTILITIES, FILE_STORAGE);
intitializeProcessFramework();
break;
}
@@ -356,7 +355,7 @@
function initializeUserBot() {
try {
usertBot = USER_BOT_MODULE.newUserBot(processIndex, bot, logger, COMMONS_MODULE, UTILITIES, FILE_STORAGE);
usertBot = USER_BOT_MODULE.newUserBot(processIndex, logger, COMMONS_MODULE, UTILITIES, FILE_STORAGE);
usertBot.initialize(statusDependencies, onInizialized);
function onInizialized(err) {
+2 -2
View File
@@ -1,4 +1,4 @@
exports.newIndicatorOutput = function (processIndex, bot, logger, UTILITIES, FILE_STORAGE) {
exports.newIndicatorOutput = function (processIndex, logger, UTILITIES, FILE_STORAGE) {
const MODULE_NAME = "Indicator Bot";
let thisObject = {
@@ -11,7 +11,7 @@
let fileStorage = FILE_STORAGE.newFileStorage(logger);
const COMMONS = require('./Commons.js');
let commons = COMMONS.newCommons(bot, logger, UTILITIES, FILE_STORAGE);
let commons = COMMONS.newCommons(logger, UTILITIES, FILE_STORAGE);
return thisObject;
+1 -1
View File
@@ -1,4 +1,4 @@
exports.newLearningSession = function (processIndex, bot, parentLogger) {
exports.newLearningSession = function (processIndex, parentLogger) {
const MODULE_NAME = "Learning Session"
@@ -1,4 +1,4 @@
exports.newAnnouncements = function (processIndex, bot, logger) {
exports.newAnnouncements = function (processIndex, logger) {
const MODULE_NAME = 'Announcements'
@@ -1,4 +1,4 @@
exports.newExchangeAPI = function (processIndex, bot, logger) {
exports.newExchangeAPI = function (processIndex, logger) {
let MODULE_NAME = "Exchange API";
@@ -1,4 +1,4 @@
exports.newOrdersCalculations = function (processIndex, bot, logger) {
exports.newOrdersCalculations = function (processIndex, logger) {
/*
When we are live trading, we need to syncronize with the exchange.
*/
@@ -1,4 +1,4 @@
exports.newOrdersSimulations = function (processIndex, bot, logger) {
exports.newOrdersSimulations = function (processIndex, logger) {
/*
When we are backtesting or paper trading, we need to simulate what would have happened at the exchange.
*/
+1 -1
View File
@@ -1,4 +1,4 @@
exports.newSnapshots = function (processIndex, bot, logger) {
exports.newSnapshots = function (processIndex, logger) {
/*
This module encapsulates the snapshots functionality.
*/
@@ -1,4 +1,4 @@
exports.newTradingEngine = function (processIndex, bot, logger) {
exports.newTradingEngine = function (processIndex, logger) {
/*
We call the Trading Engine to the data structure that is needed in order to exevute the
trading protocol with the specific rules defined at the Trading System.
@@ -1,4 +1,4 @@
exports.newTradingEpisode = function (processIndex, bot, logger, tradingEngineModule) {
exports.newTradingEpisode = function (processIndex, logger, tradingEngineModule) {
/*
This module packages all functions related to Episodes.
*/
@@ -1,4 +1,4 @@
exports.newTradingExecution = function (processIndex, bot, logger, tradingEngineModule) {
exports.newTradingExecution = function (processIndex, logger, tradingEngineModule) {
/*
The Trading Execution modules manages the execution nodes and execution algoritms.
*/
@@ -17,7 +17,7 @@ exports.newTradingExecution = function (processIndex, bot, logger, tradingEngine
let sessionParameters
const TRADING_ORDERS_MODULE = require('./TradingOrders.js')
let tradingOrdersModule = TRADING_ORDERS_MODULE.newTradingOrders(processIndex, bot, logger, tradingEngineModule)
let tradingOrdersModule = TRADING_ORDERS_MODULE.newTradingOrders(processIndex, logger, tradingEngineModule)
return thisObject
@@ -1,4 +1,4 @@
exports.newTradingOrders = function (processIndex, bot, logger, tradingEngineModule) {
exports.newTradingOrders = function (processIndex, logger, tradingEngineModule) {
/*
The Trading Orders modules manages the execution of orders against the exchanges.
*/
@@ -17,10 +17,10 @@ exports.newTradingOrders = function (processIndex, bot, logger, tradingEngineMod
let sessionParameters
const EXCHANGE_API_MODULE = require('./ExchangeAPI.js')
let exchangeAPIModule = EXCHANGE_API_MODULE.newExchangeAPI(processIndex, bot, logger)
let exchangeAPIModule = EXCHANGE_API_MODULE.newExchangeAPI(processIndex, logger)
const ANNOUNCEMENTS_MODULE = require('./Announcements.js')
let announcementsModule = ANNOUNCEMENTS_MODULE.newAnnouncements(processIndex, bot, logger)
let announcementsModule = ANNOUNCEMENTS_MODULE.newAnnouncements(processIndex, logger)
return thisObject
@@ -572,7 +572,7 @@ exports.newTradingOrders = function (processIndex, bot, logger, tradingEngineMod
tradingEngineOrder.status.value = 'Closed'
/*
We must be carefull here not to overide an already defined exitType. It can happen
for instance that the order was cancellerd from the bot, but veryfing the cancellation
for instance that the order was cancellerd from the but veryfing the cancellation
was not possible because of a connection to the exchange problem. In that case
the exit type was defined but the order was kept open until the verification could be done.
*/
@@ -658,7 +658,7 @@ exports.newTradingOrders = function (processIndex, bot, logger, tradingEngineMod
let previousQuotedAssetFeesPaid = tradingEngineOrder.orderQuotedAsset.feesPaid.value
const ORDERS_SIMULATIONS_MODULE = require('./OrdersSimulations.js')
let ordersSimulationsModule = ORDERS_SIMULATIONS_MODULE.newOrdersSimulations(processIndex, bot, logger)
let ordersSimulationsModule = ORDERS_SIMULATIONS_MODULE.newOrdersSimulations(processIndex, logger)
ordersSimulationsModule.initialize()
ordersSimulationsModule.actualSizeSimulation(tradingEngineStage, tradingSystemOrder, tradingEngineOrder, applyFeePercentage)
@@ -690,7 +690,7 @@ exports.newTradingOrders = function (processIndex, bot, logger, tradingEngineMod
let previousQuotedAssetFeesPaid = tradingEngineOrder.orderQuotedAsset.feesPaid.value
const ORDERS_CALCULATIONS_MODULE = require('./OrdersCalculations.js')
let ordersCalculationsModule = ORDERS_CALCULATIONS_MODULE.newOrdersCalculations(processIndex, bot, logger)
let ordersCalculationsModule = ORDERS_CALCULATIONS_MODULE.newOrdersCalculations(processIndex, logger)
ordersCalculationsModule.initialize()
await ordersCalculationsModule.actualSizeCalculation(tradingEngineStage, tradingSystemOrder, tradingEngineOrder, order, applyFeePercentage)
@@ -1,4 +1,4 @@
exports.newTradingOutput = function (processIndex, bot, logger, tradingEngineModule, UTILITIES, FILE_STORAGE) {
exports.newTradingOutput = function (processIndex, 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 (processIndex, bot, logger, tradingEngineMod
/* Preparing everything for the Simulation */
const TRADING_SIMULATION = require('./TradingSimulation.js')
let tradingSimulation = TRADING_SIMULATION.newTradingSimulation(processIndex, bot, logger, tradingEngineModule, UTILITIES)
let tradingSimulation = TRADING_SIMULATION.newTradingSimulation(processIndex, logger, tradingEngineModule, UTILITIES)
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()
@@ -1,4 +1,4 @@
exports.newTradingPosition = function (processIndex, bot, logger, tradingEngineModule) {
exports.newTradingPosition = function (processIndex, logger, tradingEngineModule) {
/*
This module packages all functions related to Positions.
*/
@@ -1,4 +1,4 @@
exports.newTradingProcess = function (processIndex, bot, logger, UTILITIES) {
exports.newTradingProcess = function (processIndex, 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.
@@ -24,10 +24,10 @@
let fileStorage = FILE_STORAGE.newFileStorage(logger);
const TRADING_ENGINE_MODULE = require('./TradingEngine.js')
let tradingEngineModule = TRADING_ENGINE_MODULE.newTradingEngine(processIndex, bot, logger)
let tradingEngineModule = TRADING_ENGINE_MODULE.newTradingEngine(processIndex, logger)
let TRADING_OUTPUT_MODULE = require("./TradingOutput")
let tradingOutputModule = TRADING_OUTPUT_MODULE.newTradingOutput(processIndex, bot, logger, tradingEngineModule, UTILITIES, FILE_STORAGE)
let tradingOutputModule = TRADING_OUTPUT_MODULE.newTradingOutput(processIndex, logger, tradingEngineModule, UTILITIES, FILE_STORAGE)
let processConfig;
@@ -550,7 +550,7 @@
function buildCharts(chart) {
const COMMONS = require('../Commons.js')
let commons = COMMONS.newCommons(bot, logger, UTILITIES, FILE_STORAGE)
let commons = COMMONS.newCommons(logger, UTILITIES, FILE_STORAGE)
let mainDependency = {}
@@ -1,4 +1,4 @@
exports.newTradingRecords = function (processIndex, bot, logger) {
exports.newTradingRecords = function (processIndex, logger) {
/*
This module facilitates the appending of records to the output of the process.
*/
@@ -1,4 +1,4 @@
exports.newTradingSimulation = function (processIndex, bot, logger, tradingEngineModule, UTILITIES) {
exports.newTradingSimulation = function (processIndex, 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.
@@ -11,7 +11,7 @@ exports.newTradingSimulation = function (processIndex, bot, logger, tradingEngin
runSimulation: runSimulation
}
let utilities = UTILITIES.newCloudUtilities(bot, logger)
let utilities = UTILITIES.newCloudUtilities(logger)
return thisObject
@@ -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(processIndex, bot, logger)
let tradingRecordsModule = TRADING_RECORDS_MODULE.newTradingRecords(processIndex, logger)
tradingRecordsModule.initialize(outputDatasetsMap)
const TRADING_SYSTEM_MODULE = require('./TradingSystem.js')
let tradingSystemModule = TRADING_SYSTEM_MODULE.newTradingSystem(processIndex, bot, logger, tradingEngineModule)
let tradingSystemModule = TRADING_SYSTEM_MODULE.newTradingSystem(processIndex, logger, tradingEngineModule)
tradingSystemModule.initialize()
const TRADING_EPISODE_MODULE = require('./TradingEpisode.js')
let tradingEpisodeModule = TRADING_EPISODE_MODULE.newTradingEpisode(processIndex, bot, logger, tradingEngineModule)
let tradingEpisodeModule = TRADING_EPISODE_MODULE.newTradingEpisode(processIndex, 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. */
@@ -1,4 +1,4 @@
exports.newTradingStages = function (processIndex, bot, logger, tradingEngineModule) {
exports.newTradingStages = function (processIndex, logger, tradingEngineModule) {
/*
This module packages all functions related to Stages.
*/
@@ -21,22 +21,22 @@ exports.newTradingStages = function (processIndex, bot, logger, tradingEngineMod
}
const TRADING_STRATEGY_MODULE = require('./TradingStrategy.js')
let tradingStrategyModule = TRADING_STRATEGY_MODULE.newTradingStrategy(processIndex, bot, logger, tradingEngineModule)
let tradingStrategyModule = TRADING_STRATEGY_MODULE.newTradingStrategy(processIndex, logger, tradingEngineModule)
const TRADING_POSITION_MODULE = require('./TradingPosition.js')
let tradingPositionModule = TRADING_POSITION_MODULE.newTradingPosition(processIndex, bot, logger, tradingEngineModule)
let tradingPositionModule = TRADING_POSITION_MODULE.newTradingPosition(processIndex, logger, tradingEngineModule)
const TRADING_ENGINE_EXECUTION = require('./TradingExecution.js')
let tradingExecutionModule = TRADING_ENGINE_EXECUTION.newTradingExecution(processIndex, bot, logger, tradingEngineModule)
let tradingExecutionModule = TRADING_ENGINE_EXECUTION.newTradingExecution(processIndex, logger, tradingEngineModule)
const ANNOUNCEMENTS_MODULE = require('./Announcements.js')
let announcementsModule = ANNOUNCEMENTS_MODULE.newAnnouncements(processIndex, bot, logger)
let announcementsModule = ANNOUNCEMENTS_MODULE.newAnnouncements(processIndex, logger)
const SNAPSHOTS_MODULE = require('./Snapshots.js')
let snapshotsModule = SNAPSHOTS_MODULE.newSnapshots(processIndex, bot, logger)
let snapshotsModule = SNAPSHOTS_MODULE.newSnapshots(processIndex, logger)
const TRADING_EPISODE_MODULE = require('./TradingEpisode.js')
let tradingEpisodeModule = TRADING_EPISODE_MODULE.newTradingEpisode(processIndex, bot, logger)
let tradingEpisodeModule = TRADING_EPISODE_MODULE.newTradingEpisode(processIndex, logger)
let tradingEngine
let tradingSystem
@@ -1,4 +1,4 @@
exports.newTradingStrategy = function (processIndex, bot, logger, tradingEngineModule) {
exports.newTradingStrategy = function (processIndex, logger, tradingEngineModule) {
/*
This module packages all functions related to Strategies.
*/
@@ -1,4 +1,4 @@
exports.newTradingSystem = function (processIndex, bot, logger, tradingEngineModule) {
exports.newTradingSystem = function (processIndex, 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 (processIndex, bot, logger, tradingEngineMod
let dynamicIndicators
const TRADING_STAGES_MODULE = require('./TradingStages.js')
let tradingStagesModule = TRADING_STAGES_MODULE.newTradingStages(processIndex, bot, logger, tradingEngineModule)
let tradingStagesModule = TRADING_STAGES_MODULE.newTradingStages(processIndex, logger, tradingEngineModule)
return thisObject
+2 -2
View File
@@ -1,4 +1,4 @@
exports.newMultiPeriodDaily = function (processIndex, bot, logger, UTILITIES, FILE_STORAGE) {
exports.newMultiPeriodDaily = function (processIndex, 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(processIndex, bot, logger, UTILITIES, FILE_STORAGE)
indicatorOutputModule = INDICATOR_OUTPUT_MODULE.newIndicatorOutput(processIndex, logger, UTILITIES, FILE_STORAGE)
indicatorOutputModule.initialize(callBackFunction)
}
+2 -2
View File
@@ -1,4 +1,4 @@
exports.newMultiPeriodMarket = function (processIndex, bot, logger, UTILITIES, FILE_STORAGE) {
exports.newMultiPeriodMarket = function (processIndex, 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(processIndex, bot, logger, UTILITIES, FILE_STORAGE)
indicatorOutputModule = INDICATOR_OUTPUT_MODULE.newIndicatorOutput(processIndex, logger, UTILITIES, FILE_STORAGE)
indicatorOutputModule.initialize(callBackFunction)
}
+1 -3
View File
@@ -1,4 +1,4 @@
exports.newProcessExecutionEvents = function (processIndex, BOT, logger) {
exports.newProcessExecutionEvents = function (processIndex, 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
@@ -7,8 +7,6 @@
const MODULE_NAME = "Process Execution Events";
logger.fileName = MODULE_NAME
let bot = BOT;
let thisObject = {
networkNode: undefined,
initialize: initialize,
+4 -5
View File
@@ -30,7 +30,6 @@
*/
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;
/*
There are a few variables with the scope of the process instance. We will store it here so that it can be
@@ -94,7 +93,7 @@
try {
TS.projects.superalgos.globals.processVariables.TOTAL_PROCESS_INSTANCES_CREATED++
botInstance = SENSOR_BOT.newSensorBot(processIndex, botConfig, logger);
botInstance = SENSOR_BOT.newSensorBot(processIndex, logger);
botInstance.initialize(processConfig, onInitializeReady);
}
catch (err) {
@@ -107,7 +106,7 @@
try {
TS.projects.superalgos.globals.processVariables.TOTAL_PROCESS_INSTANCES_CREATED++
botInstance = INDICATOR_BOT_MODULE.newIndicatorBot(processIndex, botConfig, logger);
botInstance = INDICATOR_BOT_MODULE.newIndicatorBot(processIndex, logger);
botInstance.initialize(processConfig, onInitializeReady);
}
@@ -121,7 +120,7 @@
try {
TS.projects.superalgos.globals.processVariables.TOTAL_PROCESS_INSTANCES_CREATED++
botInstance = TRADING_BOT_MODULE.newTradingBot(processIndex, botConfig, logger);
botInstance = TRADING_BOT_MODULE.newTradingBot(processIndex, logger);
botInstance.initialize(processConfig, onInitializeReady);
}
catch (err) {
@@ -134,7 +133,7 @@
try {
TS.projects.superalgos.globals.processVariables.TOTAL_PROCESS_INSTANCES_CREATED++
botInstance = TRADING_BOT_MODULE.newLearningBot(processIndex, botConfig, logger);
botInstance = TRADING_BOT_MODULE.newLearningBot(processIndex, logger);
botInstance.initialize(processConfig, onInitializeReady);
}
catch (err) {
+1 -3
View File
@@ -1,4 +1,4 @@
exports.newProcessOutput = function (processIndex, BOT, logger) {
exports.newProcessOutput = function (processIndex, logger) {
/*
Here we emit the events that signals that a Dataset was updated.
@@ -6,8 +6,6 @@
const MODULE_NAME = "Process Output";
let bot = BOT;
let thisObject = {
raiseEvents: raiseEvents,
asyncRaiseEvents: asyncRaiseEvents
@@ -1,4 +1,4 @@
exports.newLearningBot = function (processIndex, bot, parentLogger) {
exports.newLearningBot = function (processIndex, parentLogger) {
const MODULE_NAME = "Learning Bot";
const FULL_LOG = true;
@@ -8,7 +8,7 @@ exports.newLearningBot = function (processIndex, bot, parentLogger) {
const SESSION = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'TradingSession');
let fileStorage = FILE_STORAGE.newFileStorage(parentLogger);
let session = SESSION.newLearningSession(processIndex, bot, parentLogger)
let session = SESSION.newLearningSession(processIndex, parentLogger)
const DEBUG_MODULE = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'DebugLog');
let logger; // We need this here in order for the loopHealth function to work and be able to rescue the loop when it gets in trouble.
@@ -1,4 +1,4 @@
exports.newLearningProcess = function (processIndex, bot, logger, UTILITIES) {
exports.newLearningProcess = function (processIndex, logger, UTILITIES) {
thisObject = {
@@ -1,4 +1,4 @@
exports.newMarkovDecisionProcess = function newMarkovDecisionProcess(bot, logger) {
exports.newMarkovDecisionProcess = function newMarkovDecisionProcess(logger) {
const MODULE_NAME = 'Markov Decision Process'
let thisObject = {
+5 -7
View File
@@ -1,7 +1,6 @@
exports.newSensorBot = function newSensorBot(processIndex, bot, parentLogger) {
exports.newSensorBot = function newSensorBot(processIndex, parentLogger) {
const MODULE_NAME = "Sensor Bot";
const FULL_LOG = true;
let USER_BOT_MODULE;
let COMMONS_MODULE;
@@ -28,7 +27,7 @@
try {
processConfig = pProcessConfig;
if (bot.repo === undefined) {
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.repo === undefined) {
/* The code of the bot is defined at the UI. No need to load a file with the code. */
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE);
return
@@ -105,7 +104,6 @@
}
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();
TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).MAIN_LOOP_COUNTER++;
@@ -138,7 +136,7 @@
function initializeProcessExecutionEvents() {
try {
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(processIndex, bot, logger)
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(processIndex, logger)
processExecutionEvents.initialize(processConfig, onInizialized);
function onInizialized(err) {
@@ -240,7 +238,7 @@
function initializeStatusDependencies() {
try {
statusDependencies = STATUS_DEPENDENCIES.newStatusDependencies(processIndex, bot, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT);
statusDependencies = STATUS_DEPENDENCIES.newStatusDependencies(processIndex, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT);
statusDependencies.initialize(onInizialized);
function onInizialized(err) {
@@ -288,7 +286,7 @@
function initializeUserBot() {
try {
usertBot = USER_BOT_MODULE.newUserBot(processIndex, bot, logger, COMMONS_MODULE, UTILITIES, FILE_STORAGE, STATUS_REPORT, exchangeAPI);
usertBot = USER_BOT_MODULE.newUserBot(processIndex, 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.newSocialBots = function (processIndex, bot, logger) {
exports.newSocialBots = function (processIndex, logger) {
const MODULE_NAME = 'Social Bots'
@@ -19,7 +19,7 @@ exports.newSocialBots = function (processIndex, bot, logger) {
let socialBot = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.bots[i]
if (socialBot.type === "Telegram Bot") {
let config = socialBot.config
socialBot.botInstance = TELEGRAM_BOT_MODULE.newTelegramBot(bot, logger)
socialBot.botInstance = TELEGRAM_BOT_MODULE.newTelegramBot(logger)
socialBot.botInstance.initialize(config.botToken, config.chatId)
}
}
+2 -4
View File
@@ -1,9 +1,7 @@
exports.newStatusDependencies = function (processIndex, BOT, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT) {
exports.newStatusDependencies = function (processIndex, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT) {
const MODULE_NAME = "Status Dependencies";
let bot = BOT
let thisObject = {
nodeArray: undefined,
statusReports: new Map(),
@@ -48,7 +46,7 @@
for (let i = 0; i < dependenciesToProcess.length; i++) {
let statusReportModule = STATUS_REPORT.newStatusReport(processIndex, BOT, logger, UTILITIES, PROCESS_OUTPUT);
let statusReportModule = STATUS_REPORT.newStatusReport(processIndex, logger, UTILITIES, PROCESS_OUTPUT);
logger.write(MODULE_NAME, "[INFO] initialize -> onInitilized -> Initializing Status Report # " + (i + 1));
let statusDependency = dependenciesToProcess[i]
+4 -6
View File
@@ -1,4 +1,4 @@
exports.newStatusReport = function (processIndex, BOT, logger, UTILITIES, PROCESS_OUTPUT) {
exports.newStatusReport = function (processIndex, logger, UTILITIES, PROCESS_OUTPUT) {
/*
@@ -10,8 +10,6 @@
const MODULE_NAME = "Status Report";
let bot = BOT;
let thisObject = {
networkNode: undefined,
mainUtility: undefined,
@@ -267,7 +265,7 @@
If we are funning Trading Engines, we can not allow ourselves to use a Status Report that is not the latest one, because it might contain
transactioinal information related to the context of the operations the trading engine is doing.
On the contraty, if we are running a Sensor bot or an Indicator bot, we might, if necesary, use a previous version of a Status Report since
On the contraty, if we are running a Sensor bot or an Indicator we might, if necesary, use a previous version of a Status Report since
there will be no big impact, just some reprocessing.
*/
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE !== undefined) {
@@ -368,7 +366,7 @@
/* All good, lets emit the event that means data has been updated. */
let processOutput = PROCESS_OUTPUT.newProcessOutput(processIndex, bot, logger)
let processOutput = PROCESS_OUTPUT.newProcessOutput(processIndex, logger)
processOutput.raiseEvents(thisObject.file.lastFile, thisObject.file.timeFrames, callBackFunction);
return
}
@@ -395,7 +393,7 @@
}
/* All good, lets emit the event that means data has been updated. */
let processOutput = PROCESS_OUTPUT.newProcessOutput(processIndex, bot, logger)
let processOutput = PROCESS_OUTPUT.newProcessOutput(processIndex, logger)
processOutput.asyncRaiseEvents(thisObject.file.lastFile, thisObject.file.timeFrames)
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
exports.newTelegramBot = function newTelegramBot(bot, logger) {
exports.newTelegramBot = function newTelegramBot(logger) {
const MODULE_NAME = 'Telegram Bot'
+7 -8
View File
@@ -1,4 +1,4 @@
exports.newTradingBot = function newTradingBot(processIndex, bot, parentLogger) {
exports.newTradingBot = function newTradingBot(processIndex, parentLogger) {
const MODULE_NAME = "Trading Bot";
const FULL_LOG = true;
@@ -8,7 +8,7 @@
const SESSION = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'TradingSession');
let fileStorage = FILE_STORAGE.newFileStorage(parentLogger);
let session = SESSION.newTradingSession(processIndex, bot, parentLogger)
let session = SESSION.newTradingSession(processIndex, parentLogger)
const DEBUG_MODULE = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'DebugLog');
let logger; // We need this here in order for the loopHealth function to work and be able to rescue the loop when it gets in trouble.
@@ -28,7 +28,7 @@
/* This function is exactly the same in the 3 modules representing the 2 different bot types loops. */
try {
processConfig = pProcessConfig;
if (bot.repo === undefined) {
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.repo === undefined) {
/* The code of the bot is defined at the UI. No need to load a file with the code. */
session.initialize(processConfig, callBackFunction)
}
@@ -61,7 +61,6 @@
}
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();
TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).MAIN_LOOP_COUNTER++;
@@ -122,7 +121,7 @@
function initializeProcessExecutionEvents() {
try {
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(processIndex, bot, logger)
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(processIndex, logger)
processExecutionEvents.initialize(processConfig, onInizialized);
function onInizialized(err) {
@@ -223,7 +222,7 @@
function initializeStatusDependencies() {
try {
statusDependencies = STATUS_DEPENDENCIES.newStatusDependencies(processIndex, bot, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT);
statusDependencies = STATUS_DEPENDENCIES.newStatusDependencies(processIndex, logger, STATUS_REPORT, UTILITIES, PROCESS_OUTPUT);
statusDependencies.initialize(onInizialized);
function onInizialized(err) {
@@ -271,7 +270,7 @@
function initializeDataDependencies() {
try {
dataDependencies = DATA_DEPENDENCIES.newDataDependencies(processIndex, bot, logger, DATA_SET);
dataDependencies = DATA_DEPENDENCIES.newDataDependencies(processIndex, logger, DATA_SET);
dataDependencies.initialize(onInizialized);
function onInizialized(err) {
@@ -281,7 +280,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(processIndex, bot, logger, UTILITIES);
processFramework = TRADING_PROCESS_MODULE.newTradingProcess(processIndex, logger, UTILITIES);
intitializeProcessFramework();
break;
}
+2 -2
View File
@@ -1,4 +1,4 @@
exports.newTradingSession = function (processIndex, bot, parentLogger) {
exports.newTradingSession = function (processIndex, parentLogger) {
const MODULE_NAME = "Trading Session"
@@ -7,7 +7,7 @@
}
const SOCIAL_BOTS_MODULE = require('./SocialBots.js')
TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SOCIAL_BOTS_MODULE = SOCIAL_BOTS_MODULE.newSocialBots(processIndex, bot, parentLogger)
TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SOCIAL_BOTS_MODULE = SOCIAL_BOTS_MODULE.newSocialBots(processIndex, parentLogger)
return thisObject;