From 23c70934ab60f4bc0f327168eb24d98587d5a4e1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 4 Jun 2019 16:55:14 +0200 Subject: [PATCH] Refactoring simulationLogic --- Commons.js | 24 ++++++++++++------------ Multi-Period-Daily/User.Bot.js | 6 +++--- Multi-Period-Market/User.Bot.js | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Commons.js b/Commons.js index 124256778..bd612453c 100644 --- a/Commons.js +++ b/Commons.js @@ -59,7 +59,7 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { strategiesArray, tradesArray, lastObjectsArray, - simulationLogic, + tradingSystem, timePeriod, currentDay, startDate, @@ -256,7 +256,7 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { } - simulationLogic.strategies = await getStrategies(); + tradingSystem.strategies = await getStrategies(); /* Main Simulation Loop: We go thourgh all the candles at this time period. */ @@ -325,9 +325,9 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { conditionsArrayRecord.push(candle.begin); conditionsArrayRecord.push(candle.end); - for (let j = 0; j < simulationLogic.strategies.length; j++) { + for (let j = 0; j < tradingSystem.strategies.length; j++) { - let strategy = simulationLogic.strategies[j]; + let strategy = tradingSystem.strategies[j]; for (let k = 0; k < strategy.entryPoint.situations.length; k++) { @@ -455,9 +455,9 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { function checkEntryPoints() { - for (let j = 0; j < simulationLogic.strategies.length; j++) { + for (let j = 0; j < tradingSystem.strategies.length; j++) { - let strategy = simulationLogic.strategies[j]; + let strategy = tradingSystem.strategies[j]; for (let k = 0; k < strategy.entryPoint.situations.length; k++) { @@ -496,7 +496,7 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { function checkExitPoints() { - let strategy = simulationLogic.strategies[strategyNumber - 1]; + let strategy = tradingSystem.strategies[strategyNumber - 1]; for (let k = 0; k < strategy.exitPoint.situations.length; k++) { @@ -601,7 +601,7 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { function checkSellPoints() { - let strategy = simulationLogic.strategies[strategyNumber - 1]; + let strategy = tradingSystem.strategies[strategyNumber - 1]; for (let k = 0; k < strategy.sellPoint.situations.length; k++) { @@ -644,7 +644,7 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { function checkStopPhases() { - let strategy = simulationLogic.strategies[strategyNumber - 1]; + let strategy = tradingSystem.strategies[strategyNumber - 1]; let phase = strategy.stopLoss.phases[stopLossPhase - 1]; for (let k = 0; k < phase.situations.length; k++) { @@ -673,7 +673,7 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { function checkStopLoss() { - let strategy = simulationLogic.strategies[strategyNumber - 1]; + let strategy = tradingSystem.strategies[strategyNumber - 1]; let phase = strategy.stopLoss.phases[stopLossPhase - 1]; try { @@ -707,7 +707,7 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { function checkBuyOrderPhases() { - let strategy = simulationLogic.strategies[strategyNumber - 1]; + let strategy = tradingSystem.strategies[strategyNumber - 1]; let phase = strategy.buyOrder.phases[buyOrderPhase - 1]; for (let k = 0; k < phase.situations.length; k++) { @@ -736,7 +736,7 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { function checkBuyOrder() { - let strategy = simulationLogic.strategies[strategyNumber - 1]; + let strategy = tradingSystem.strategies[strategyNumber - 1]; let phase = strategy.buyOrder.phases[buyOrderPhase - 1]; try { diff --git a/Multi-Period-Daily/User.Bot.js b/Multi-Period-Daily/User.Bot.js index eb96ce694..e1751c635 100644 --- a/Multi-Period-Daily/User.Bot.js +++ b/Multi-Period-Daily/User.Bot.js @@ -68,7 +68,7 @@ let strategiesArray = []; let tradesArray = []; - let simulationLogic = {}; + let tradingSystem = {}; let lastObjectsArray = []; commons.initializeData(); @@ -113,7 +113,7 @@ strategiesArray, tradesArray, lastObjectsArray, - simulationLogic, + tradingSystem, timePeriod, currentDay, startDate, @@ -260,7 +260,7 @@ } fileContent = "[" + fileContent + "]"; - fileContent = "[" + JSON.stringify(simulationLogic) + "," + JSON.stringify(lastObjectsArray) + "," + fileContent + "]"; + fileContent = "[" + JSON.stringify(tradingSystem) + "," + JSON.stringify(lastObjectsArray) + "," + fileContent + "]"; let dateForPath = currentDay.getUTCFullYear() + '/' + utilities.pad(currentDay.getUTCMonth() + 1, 2) + '/' + utilities.pad(currentDay.getUTCDate(), 2); let fileName = '' + market.assetA + '_' + market.assetB + '.json'; diff --git a/Multi-Period-Market/User.Bot.js b/Multi-Period-Market/User.Bot.js index d0aaf744c..52c201be9 100644 --- a/Multi-Period-Market/User.Bot.js +++ b/Multi-Period-Market/User.Bot.js @@ -69,7 +69,7 @@ let tradesArray = []; let lastObjectsArray = []; - let simulationLogic = {}; + let tradingSystem = {}; let interExecutionMemory = {}; let currentDay = bot.processDatetime; @@ -115,7 +115,7 @@ strategiesArray, tradesArray, lastObjectsArray, - simulationLogic, + tradingSystem, timePeriod, currentDay, startDate, @@ -250,7 +250,7 @@ } fileContent = "[" + fileContent + "]"; - fileContent = "[" + JSON.stringify(simulationLogic) + "," + JSON.stringify(lastObjectsArray) + "," + fileContent + "]"; + fileContent = "[" + JSON.stringify(tradingSystem) + "," + JSON.stringify(lastObjectsArray) + "," + fileContent + "]"; let fileName = '' + market.assetA + '_' + market.assetB + '.json'; let filePathRoot = bot.devTeam + "/" + bot.codeName + "." + bot.version.major + "." + bot.version.minor + "/" + global.PLATFORM_CONFIG.codeName + "." + global.PLATFORM_CONFIG.version.major + "." + global.PLATFORM_CONFIG.version.minor + "/" + global.EXCHANGE_NAME + "/" + bot.dataSetVersion;