From 432f70c3ca405bdee50015388b8d1b3fb5b880b6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 25 Nov 2020 15:00:37 +0100 Subject: [PATCH] Data Mining without legacy config file --- TaskServer/IndicatorBot.js | 2 +- .../ReinforcementLearning/LearningBot.js | 2 +- TaskServer/Root.js | 64 +------------------ TaskServer/SensorBot.js | 2 +- TaskServer/TradingBot.js | 2 +- 5 files changed, 7 insertions(+), 65 deletions(-) diff --git a/TaskServer/IndicatorBot.js b/TaskServer/IndicatorBot.js index 87589f4ec..60f044bd1 100644 --- a/TaskServer/IndicatorBot.js +++ b/TaskServer/IndicatorBot.js @@ -28,7 +28,7 @@ try { processConfig = pProcessConfig; - if (bot.definedByUI === true) { + if (bot.repo === undefined) { /* The code of the bot is defined at the UI. No need to load a file with the code. */ callBackFunction(global.DEFAULT_OK_RESPONSE); return diff --git a/TaskServer/ReinforcementLearning/LearningBot.js b/TaskServer/ReinforcementLearning/LearningBot.js index ad887979f..02f857600 100644 --- a/TaskServer/ReinforcementLearning/LearningBot.js +++ b/TaskServer/ReinforcementLearning/LearningBot.js @@ -28,7 +28,7 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { /* This function is exactly the same in the 3 modules representing the 2 different bot types loops. */ try { processConfig = pProcessConfig; - if (bot.definedByUI === true) { + if (bot.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) } diff --git a/TaskServer/Root.js b/TaskServer/Root.js index a50df343c..7aa875fa5 100644 --- a/TaskServer/Root.js +++ b/TaskServer/Root.js @@ -66,68 +66,10 @@ const INDICATOR_BOT_MODULE = require('./IndicatorBot'); const SENSOR_BOT = require('./SensorBot'); const TRADING_BOT_MODULE = require('./TradingBot'); - - let botConfig; + let processInstance = global.TASK_NODE.bot.processes[processIndex] - - /* Here we will check if we need to load the configuration and code of the bot from a file or we will take that from the UI. */ - if ( - processInstance.referenceParent.config.framework !== undefined && - (processInstance.referenceParent.config.framework.name === 'Multi-Period-Market' || - processInstance.referenceParent.config.framework.name === 'Multi-Period-Daily' || - processInstance.referenceParent.config.framework.name === 'Low-Frequency-Trading-Process') - ) { - botConfig = processInstance.referenceParent.parentNode.config - botConfig.definedByUI = true - bootingBot(processIndex) - return - } else { - getBotConfigFromFile(); - return - } - - function getBotConfigFromFile() { - - try { - - const FILE_STORAGE = require('./FileStorage.js'); - let fileStorage = FILE_STORAGE.newFileStorage(); - - let filePath = - global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.project + // project - '/Bots-Plotters-Code/' + - global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + // mine - '/bots/' + - processInstance.referenceParent.parentNode.config.repo + // bot - '/this.bot.config.json' - - console.log('Reading Bot Config File al: ' + filePath) - fileStorage.getTextFile(filePath, onFileReceived); - - function onFileReceived(err, text) { - - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { - console.log(logDisplace + "Root : [ERROR] start -> getBotConfigFromFile -> onInizialized -> onFileReceived -> err = " + JSON.stringify(err)); - console.log(logDisplace + "Root : [ERROR] start -> getBotConfigFromFile -> onInizialized -> onFileReceived -> filePath = " + filePath); - console.log(logDisplace + "Root : [ERROR] start -> getBotConfigFromFile -> onInizialized -> onFileReceived -> dataMine = " + global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName); - return; - } - - try { - botConfig = JSON.parse(text); - botConfig.repo = global.TASK_NODE.bot.config.repo; - bootingBot(processIndex); - } catch (err) { - console.log(logDisplace + "Root : [ERROR] start -> getBotConfigFromFile -> onInizialized -> onFileReceived -> err = " + err.stack); - return; - } - } - } - catch (err) { - console.log(logDisplace + "Root : [ERROR] start -> getBotConfigFromFile -> err = " + err.stack); - return; - } - } + let botConfig = processInstance.referenceParent.parentNode.config + bootingBot(processIndex) function bootingBot(processIndex) { diff --git a/TaskServer/SensorBot.js b/TaskServer/SensorBot.js index 2936f7eca..2d74140fa 100644 --- a/TaskServer/SensorBot.js +++ b/TaskServer/SensorBot.js @@ -28,7 +28,7 @@ try { processConfig = pProcessConfig; - if (bot.definedByUI === true) { + if (bot.repo === undefined) { /* The code of the bot is defined at the UI. No need to load a file with the code. */ callBackFunction(global.DEFAULT_OK_RESPONSE); return diff --git a/TaskServer/TradingBot.js b/TaskServer/TradingBot.js index 202d101ab..3b0ecc733 100644 --- a/TaskServer/TradingBot.js +++ b/TaskServer/TradingBot.js @@ -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.definedByUI === true) { + if (bot.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) }