TradingBot can be executed

This commit is contained in:
Luis Fernando Molina committed 2019-11-19 14:56:56 +01:00
1 parent db6db6409e
commit 3da386abce
7 files changed
+51 -34

No files matched your search

+8
View File
@@ -8,6 +8,7 @@
let thisObject = {
initialize: initialize,
finalize: finalize,
start: start
};
@@ -19,6 +20,13 @@
return thisObject;
function finalize() {
thisObject = undefined
utilities = undefined
fileStorage = undefined
commons = undefined
}
function initialize(callBackFunction) {
try {
+2 -2
View File
@@ -412,12 +412,12 @@
switch (processConfig.framework.name) {
case 'Multi-Period-Market': {
processFramework = MULTI_PERIOD_MARKET.newMultiPeriodMarket(bot, logger, UTILITIES, USER_BOT_MODULE, FILE_STORAGE);
processFramework = MULTI_PERIOD_MARKET.newMultiPeriodMarket(bot, logger, UTILITIES, FILE_STORAGE);
intitializeProcessFramework();
break;
}
case 'Multi-Period-Daily': {
processFramework = MULTI_PERIOD_DAILY.newMultiPeriodDaily(bot, logger, UTILITIES, USER_BOT_MODULE, FILE_STORAGE);
processFramework = MULTI_PERIOD_DAILY.newMultiPeriodDaily(bot, logger, UTILITIES, FILE_STORAGE);
intitializeProcessFramework();
break;
}
+9 -7
View File
@@ -1,4 +1,4 @@
exports.newMultiPeriod = function newMultiPeriod(bot, logger, COMMONS, UTILITIES, USER_BOT_MODULE, COMMONS_MODULE) {
exports.newMultiPeriod = function newMultiPeriod(bot, logger, UTILITIES, USER_BOT_MODULE, USER_BOT_COMMONS) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
@@ -20,7 +20,7 @@
let dataFiles = [];
let multiPeriodDataFiles = new Map();
let usertBot;
let botInstance;
const FILE_STORAGE = require('./FileStorage.js');
let fileStorage = FILE_STORAGE.newFileStorage(logger);
@@ -60,8 +60,10 @@
}
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, fileStorage);
usertBot.initialize(callBackFunction, pAssistant);
let USER_BOT_MODULE = require("./TradingBot")
botInstance = USER_BOT_MODULE.newTradingBot(bot, logger, UTILITIES, FILE_STORAGE);
botInstance.initialize(callBackFunction);
} catch (err) {
logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack);
@@ -75,8 +77,8 @@
multiPeriodDataFiles = undefined
statusDependencies = undefined
dataDependencies = undefined
usertBot.finalize()
usertBot = undefined
botInstance.finalize()
botInstance = undefined
fileStorage = undefined
processConfig = undefined
thisObject = undefined
@@ -839,7 +841,7 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> processTimePeriodsDailyFiles -> callTheBot -> Entering function."); }
usertBot.start(
botInstance.start(
multiPeriodDataFiles,
currentTimePeriod,
currentOutputPeriodName,
+1 -1
View File
@@ -1,4 +1,4 @@
exports.newMultiPeriodDaily = function newMultiPeriodDaily(bot, logger, UTILITIES, USER_BOT_MODULE, FILE_STORAGE) {
exports.newMultiPeriodDaily = function newMultiPeriodDaily(bot, logger, UTILITIES, FILE_STORAGE) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
+1 -1
View File
@@ -1,4 +1,4 @@
exports.newMultiPeriodMarket = function newMultiPeriodMarket(bot, logger, UTILITIES, USER_BOT_MODULE, FILE_STORAGE) {
exports.newMultiPeriodMarket = function newMultiPeriodMarket(bot, logger, UTILITIES, FILE_STORAGE) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
+25 -8
View File
@@ -1,4 +1,4 @@
exports.newTradingBot = function newTradingBot(bot, logger, USER_BOT_COMMONS, UTILITIES, FILE_STORAGE) {
exports.newTradingBot = function newTradingBot(bot, logger, UTILITIES, FILE_STORAGE) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
@@ -8,6 +8,7 @@
let thisObject = {
initialize: initialize,
finalize: finalize,
start: start
};
@@ -19,6 +20,13 @@
return thisObject;
function finalize() {
thisObject = undefined
utilities = undefined
fileStorage = undefined
commons = undefined
}
function initialize(callBackFunction) {
try {
@@ -42,7 +50,7 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> Entering function."); }
let products = {}
let chart = {}
let mainDependency = {}
let processingDailyFiles
@@ -62,24 +70,33 @@
/* The second phase is about transforming the inputs into a format that can be used to apply the user defined code. */
for (let j = 0; j < global.marketFilesPeriods.length; j++) {
let mapKey = marketFilesPeriods[j][1]
let dataFiles = multiPeriodDataFiles.get(mapKey)
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> Building Dataset for timePeriod = " + mapKey); }
let timePeriodLabel = marketFilesPeriods[j][1]
let dataFiles = multiPeriodDataFiles.get(timePeriodLabel)
let products = {}
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> Inflating Data Files for timePeriod = " + timePeriodLabel); }
if (dataFiles !== undefined) {
commons.inflateDatafiles(dataFiles, dataDependencies, products, mainDependency, timePeriod)
let propertyName = 'at' + timePeriodLabel.replace('-', '');
chart[propertyName] = products
}
}
for (let j = 0; j < global.dailyFilePeriods.length; j++) {
let mapKey = global.dailyFilePeriods[j][1]
let dataFiles = multiPeriodDataFiles.get(mapKey)
let timePeriodLabel = global.dailyFilePeriods[j][1]
let dataFiles = multiPeriodDataFiles.get(timePeriodLabel)
let products = {}
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> Building Dataset for timePeriod = " + mapKey); }
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> Inflating Data Files for timePeriod = " + timePeriodLabel); }
if (dataFiles !== undefined) {
commons.inflateDatafiles(dataFiles, dataDependencies, products, mainDependency, timePeriod)
let propertyName = 'at' + timePeriodLabel.replace('-', '');
chart[propertyName] = products
}
}
+5 -15
View File
@@ -6,7 +6,7 @@
const FULL_LOG = true;
let USER_BOT_MODULE;
let COMMONS_MODULE;
let USER_BOT_COMMONS;
const MULTI_PERIOD_MARKET = require(ROOT_DIR + 'MultiPeriodMarket');
const MULTI_PERIOD_DAILY = require(ROOT_DIR + 'MultiPeriodDaily');
@@ -81,9 +81,9 @@
return;
}
COMMONS_MODULE = {}
//COMMONS_MODULE.newCommons = require(process.env.BOTS_PATH + '/aamasters/AAMasters/bots/AAJason-Trading-Engine-Bot/Commons').newCommons // Use this for a better debugging experience. You need to bring this js module to this folder in order to work.
COMMONS_MODULE.newCommons = eval(text); // Use this for production
USER_BOT_COMMONS = {}
//USER_BOT_COMMONS.newCommons = require(process.env.BOTS_PATH + '/aamasters/AAMasters/bots/AAJason-Trading-Engine-Bot/Commons').newCommons // Use this for a better debugging experience. You need to bring this js module to this folder in order to work.
USER_BOT_COMMONS.newCommons = eval(text); // Use this for production
session.initialize(onSessionInitialized)
@@ -673,18 +673,8 @@
}
switch (processConfig.framework.name) {
case 'Multi-Period-Market': {
processFramework = MULTI_PERIOD_MARKET.newMultiPeriodMarket(bot, logger, COMMONS_MODULE, UTILITIES, USER_BOT_MODULE, COMMONS_MODULE);
intitializeProcessFramework();
break;
}
case 'Multi-Period-Daily': {
processFramework = MULTI_PERIOD_DAILY.newMultiPeriodDaily(bot, logger, COMMONS_MODULE, UTILITIES, USER_BOT_MODULE, COMMONS_MODULE);
intitializeProcessFramework();
break;
}
case 'Multi-Period': {
processFramework = MULTI_PERIOD.newMultiPeriod(bot, logger, COMMONS_MODULE, UTILITIES, USER_BOT_MODULE, COMMONS_MODULE);
processFramework = MULTI_PERIOD.newMultiPeriod(bot, logger, UTILITIES, USER_BOT_MODULE, USER_BOT_COMMONS);
intitializeProcessFramework();
break;
}