Beta 6 without Execution
This commit is contained in:
1 parent
4033d4d07f
commit
d40b985f5e
123 files changed
+8114
-12392
No files matched your search
+41
-52
@@ -35,7 +35,6 @@
|
||||
|
||||
global.dailyFilePeriods = JSON.parse(global.dailyFilePeriods);
|
||||
|
||||
const ROOT_DIR = './';
|
||||
const MODULE_NAME = "Root";
|
||||
const WAIT_TIME_FOR_ALL_PROCESS_INSTANCES_TO_START = 10000 // This avoid a race condition that could happen if one process finished before all the other even started.
|
||||
|
||||
@@ -112,7 +111,7 @@
|
||||
|
||||
}
|
||||
catch (err) {
|
||||
console.log(logDisplace + "Root : [ERROR] initialize -> err = " + err.stack);
|
||||
console.log(logDisplace + "Root : [ERROR] initialize -> err = " + err.stack);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -132,28 +131,28 @@
|
||||
|
||||
/* Process Loops Declarations. */
|
||||
|
||||
const INDICATOR_BOT_MAIN_LOOP_MODULE = require('./IndicatorBotProcessMainLoop');
|
||||
const SENSOR_BOT_MAIN_LOOP_MODULE = require('./SensorBotProcessMainLoop');
|
||||
const TRADING_ENGINE_MAIN_LOOP_MODULE = require('./TradingBotProcessMainLoop');
|
||||
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.code.framework !== undefined &&
|
||||
( processInstance.referenceParent.code.framework.name === 'Multi-Period-Market' ||
|
||||
processInstance.referenceParent.code.framework.name === 'Multi-Period-Daily' ||
|
||||
processInstance.referenceParent.code.framework.name === 'Multi-Period')
|
||||
) {
|
||||
botConfig = processInstance.referenceParent.parentNode.code
|
||||
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() {
|
||||
|
||||
@@ -162,7 +161,7 @@
|
||||
const FILE_STORAGE = require('./FileStorage.js');
|
||||
let fileStorage = FILE_STORAGE.newFileStorage();
|
||||
|
||||
let filePath = global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.code.codeName + '/bots/' + global.TASK_NODE.bot.code.repo + '/this.bot.config.json';
|
||||
let filePath = global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + '/bots/' + global.TASK_NODE.bot.config.repo + '/this.bot.config.json';
|
||||
|
||||
fileStorage.getTextFile(filePath, onFileReceived);
|
||||
|
||||
@@ -171,16 +170,16 @@
|
||||
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.code.codeName);
|
||||
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.code.repo;
|
||||
botConfig.repo = global.TASK_NODE.bot.config.repo;
|
||||
bootingBot(processIndex);
|
||||
} catch (err) {
|
||||
console.log(logDisplace + "Root : [ERROR] start -> getBotConfigFromFile -> onInizialized -> onFileReceived -> err = " + JSON.stringify(err));
|
||||
console.log(logDisplace + "Root : [ERROR] start -> getBotConfigFromFile -> onInizialized -> onFileReceived -> err = " + err.stack);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -195,7 +194,7 @@
|
||||
|
||||
try {
|
||||
|
||||
botConfig.process = global.TASK_NODE.bot.processes[processIndex].referenceParent.code.codeName
|
||||
botConfig.process = global.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName
|
||||
botConfig.debug = {};
|
||||
botConfig.processNode = global.TASK_NODE.bot.processes[processIndex]
|
||||
|
||||
@@ -204,28 +203,21 @@
|
||||
botConfig.DELETE_QUEUE_SIZE = 10 // This number represents how many log files can be at the queue at any point in time, which means how many logs are not still deleted.
|
||||
|
||||
/* Simplifying the access to basic info */
|
||||
botConfig.dataMine = global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.code.codeName
|
||||
botConfig.dataMine = global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName
|
||||
botConfig.exchange = global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.parentNode.parentNode.name
|
||||
botConfig.exchangeNode = global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.parentNode.parentNode
|
||||
botConfig.market = {
|
||||
baseAsset: global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.baseAsset.referenceParent.code.codeName,
|
||||
quotedAsset: global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.quotedAsset.referenceParent.code.codeName
|
||||
baseAsset: global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.baseAsset.referenceParent.config.codeName,
|
||||
quotedAsset: global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.quotedAsset.referenceParent.config.codeName
|
||||
}
|
||||
botConfig.uiStartDate = global.TASK_NODE.bot.code.startDate
|
||||
botConfig.code = global.TASK_NODE.bot.code
|
||||
|
||||
/* This stuff is still hardcoded and unresolved. */
|
||||
botConfig.version = {
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
}
|
||||
botConfig.dataSetVersion = "dataSet.V1"
|
||||
botConfig.uiStartDate = global.TASK_NODE.bot.config.startDate
|
||||
botConfig.config = global.TASK_NODE.bot.config
|
||||
|
||||
/* Loop Counter */
|
||||
botConfig.loopCounter = 0;
|
||||
botConfig.loopCounter = 0;
|
||||
|
||||
/* File Path Root */
|
||||
botConfig.filePathRoot = botConfig.exchange + "/" + botConfig.market.baseAsset + "-" + botConfig.market.quotedAsset + "/" + botConfig.dataMine + "/" + botConfig.codeName ;
|
||||
botConfig.filePathRoot = botConfig.exchange + "/" + botConfig.market.baseAsset + "-" + botConfig.market.quotedAsset + "/" + botConfig.dataMine + "/" + botConfig.codeName;
|
||||
|
||||
/* Process Key */
|
||||
botConfig.processKey = global.TASK_NODE.bot.processes[processIndex].name + '-' + global.TASK_NODE.bot.processes[processIndex].type + '-' + global.TASK_NODE.bot.processes[processIndex].id
|
||||
@@ -243,17 +235,17 @@
|
||||
if (botConfig.processNode.marketReference.keyInstance.referenceParent !== undefined) {
|
||||
let key = botConfig.processNode.marketReference.keyInstance.referenceParent
|
||||
|
||||
process.env.KEY = key.code.codeName
|
||||
process.env.SECRET = key.code.secret
|
||||
process.env.KEY = key.config.codeName
|
||||
process.env.SECRET = key.config.secret
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let processConfig = global.TASK_NODE.bot.processes[processIndex].referenceParent.code
|
||||
let processConfig = global.TASK_NODE.bot.processes[processIndex].referenceParent.config
|
||||
|
||||
if (processConfig.framework !== undefined) {
|
||||
if (processConfig.framework.name === "Multi-Period-Daily" || processConfig.framework.name === "Multi-Period-Market" || processConfig.framework.name === "Multi-Period") {
|
||||
if (processConfig.framework.name === "Multi-Period-Daily" || processConfig.framework.name === "Multi-Period-Market" || processConfig.framework.name === "Low-Frequency-Trading-Process") {
|
||||
if (processConfig.framework.startDate !== undefined) {
|
||||
processConfig.framework.startDate.resumeExecution = true;
|
||||
if (processConfig.startMode.noTime !== undefined) {
|
||||
@@ -283,7 +275,7 @@
|
||||
if (processConfig.startMode === undefined) { // Default
|
||||
|
||||
botConfig.hasTheBotJustStarted = true;
|
||||
|
||||
|
||||
switch (botConfig.type) {
|
||||
case 'Sensor Bot': {
|
||||
runSensorBot(botConfig, processConfig);
|
||||
@@ -387,7 +379,7 @@
|
||||
try {
|
||||
global.TOTAL_PROCESS_INSTANCES_CREATED++
|
||||
|
||||
const DEBUG_MODULE = require(ROOT_DIR + 'DebugLog');
|
||||
const DEBUG_MODULE = require(global.ROOT_DIR + 'DebugLog');
|
||||
let logger;
|
||||
|
||||
logger = DEBUG_MODULE.newDebugLog();
|
||||
@@ -396,14 +388,14 @@
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> bootingBot -> runSensorBot -> Entering function."); }
|
||||
|
||||
let extractionBotMainLoop = SENSOR_BOT_MAIN_LOOP_MODULE.newSensorBotProcessMainLoop(pBotConfig, logger);
|
||||
extractionBotMainLoop.initialize(pProcessConfig, onInitializeReady);
|
||||
let sensorBot = SENSOR_BOT.newSensorBot(pBotConfig, logger);
|
||||
sensorBot.initialize(pProcessConfig, onInitializeReady);
|
||||
|
||||
function onInitializeReady(err) {
|
||||
|
||||
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
extractionBotMainLoop.run(whenRunFinishes);
|
||||
sensorBot.run(whenRunFinishes);
|
||||
|
||||
function whenRunFinishes(err) {
|
||||
|
||||
@@ -412,14 +404,11 @@
|
||||
let botId = pBotConfig.dataMine + "." + pBotConfig.codeName + "." + pBotConfig.process;
|
||||
|
||||
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
logger.write(MODULE_NAME, "[INFO] start -> bootingBot -> runSensorBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully.");
|
||||
logger.write(MODULE_NAME, "[INFO] start -> bootingBot -> runSensorBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
|
||||
|
||||
logger.persist();
|
||||
|
||||
} else {
|
||||
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> bootingBot -> runSensorBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message);
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> bootingBot -> runSensorBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. ");
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> bootingBot -> runSensorBot -> onInitializeReady -> whenStartFinishes -> Bye.");
|
||||
@@ -452,7 +441,7 @@
|
||||
try {
|
||||
global.TOTAL_PROCESS_INSTANCES_CREATED++
|
||||
|
||||
const DEBUG_MODULE = require(ROOT_DIR + 'DebugLog');
|
||||
const DEBUG_MODULE = require(global.ROOT_DIR + 'DebugLog');
|
||||
let logger;
|
||||
|
||||
logger = DEBUG_MODULE.newDebugLog();
|
||||
@@ -461,21 +450,21 @@
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> bootingBot -> runIndicatorBot -> Entering function."); }
|
||||
|
||||
let indicatorBotMainLoop = INDICATOR_BOT_MAIN_LOOP_MODULE.newIndicatorBotProcessMainLoop(pBotConfig, logger);
|
||||
indicatorBotMainLoop.initialize(pProcessConfig, onInitializeReady);
|
||||
let indicatorBot = INDICATOR_BOT_MODULE.newIndicatorBot(pBotConfig, logger);
|
||||
indicatorBot.initialize(pProcessConfig, onInitializeReady);
|
||||
|
||||
function onInitializeReady(err) {
|
||||
|
||||
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
indicatorBotMainLoop.run(whenRunFinishes);
|
||||
indicatorBot.run(whenRunFinishes);
|
||||
|
||||
function whenRunFinishes(err) {
|
||||
|
||||
pBotConfig.loopCounter = 0;
|
||||
|
||||
let botId = pBotConfig.dataMine + "." + pBotConfig.codeName + "." + pBotConfig.process;
|
||||
|
||||
|
||||
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
logger.write(MODULE_NAME, "[INFO] start -> bootingBot -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully.");
|
||||
@@ -515,7 +504,7 @@
|
||||
global.TOTAL_PROCESS_INSTANCES_CREATED++
|
||||
|
||||
try {
|
||||
const DEBUG_MODULE = require(ROOT_DIR + 'DebugLog');
|
||||
const DEBUG_MODULE = require(global.ROOT_DIR + 'DebugLog');
|
||||
let logger;
|
||||
|
||||
logger = DEBUG_MODULE.newDebugLog();
|
||||
@@ -524,14 +513,14 @@
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> bootingBot -> runTradingBot -> Entering function."); }
|
||||
|
||||
let tradingBotMainLoop = TRADING_ENGINE_MAIN_LOOP_MODULE.newTradingBotProcessMainLoop(pBotConfig, logger);
|
||||
tradingBotMainLoop.initialize(pProcessConfig, onInitializeReady);
|
||||
let tradingBot = TRADING_BOT_MODULE.newTradingBot(pBotConfig, logger);
|
||||
tradingBot.initialize(pProcessConfig, onInitializeReady);
|
||||
|
||||
function onInitializeReady(err) {
|
||||
|
||||
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
tradingBotMainLoop.run(whenRunFinishes);
|
||||
tradingBot.run(whenRunFinishes);
|
||||
|
||||
function whenRunFinishes(err) {
|
||||
|
||||
|
||||
Reference in new issue
Block a user