diff --git a/Commons.js b/Commons.js index 58597556f..4ceb812a8 100644 --- a/Commons.js +++ b/Commons.js @@ -44,6 +44,7 @@ function runSimulation( recordsArray, conditionsArray, + lastObjectsArray, simulationLogic, timePeriod, callback) { @@ -477,8 +478,31 @@ periods++; + let channel = getElement(bollingerChannelsArray, candle.begin, candle.end); let subChannel = getElement(bollingerSubChannelsArray, candle.begin, candle.end); + let lastObjects = { + candle: JSON.parse(JSON.stringify(candle)), + LRC: JSON.parse(JSON.stringify(LRC)), + bollingerBand: JSON.parse(JSON.stringify(bollingerBand)), + percentageBandwidth: JSON.parse(JSON.stringify(percentageBandwidth)), + channel: JSON.parse(JSON.stringify(channel)), + subChannel: JSON.parse(JSON.stringify(subChannel)), + } + + lastObjects.candle.previous = undefined; + lastObjects.LRC.previous = undefined; + lastObjects.bollingerBand.previous = undefined; + lastObjects.percentageBandwidth.previous = undefined; + lastObjects.channel.previous = undefined; + lastObjects.subChannel.previous = undefined; + + lastObjectsArray.push(lastObjects); + + if (lastObjectsArray.length > 5) { + lastObjectsArray.splice(0,1); + } + let conditions = new Map; // Here we store the conditions values that will be use in the simulator for decision making. let conditionsArrayRecord = []; // These are the records that will be saved in a file for the plotter to consume. let conditionsArrayValues = []; // Here we store the conditions values that will be written on file for the plotter. diff --git a/Multi-Period-Daily/User.Bot.js b/Multi-Period-Daily/User.Bot.js index dce80df1e..144182310 100644 --- a/Multi-Period-Daily/User.Bot.js +++ b/Multi-Period-Daily/User.Bot.js @@ -67,6 +67,8 @@ let conditionsArray = []; let simulationLogic = {}; + let lastObjectsArray = []; + commons.initializeData(); for (let i = 0; i < dataDependencies.config.length; i++) { @@ -106,6 +108,7 @@ commons.runSimulation( recordsArray, conditionsArray, + lastObjectsArray, simulationLogic, timePeriod, writeRecordsFile) @@ -242,7 +245,7 @@ } fileContent = "[" + fileContent + "]"; - fileContent = "[" + JSON.stringify(simulationLogic) + "," + fileContent + "]"; + fileContent = "[" + JSON.stringify(simulationLogic) + "," + 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; diff --git a/Multi-Period-Market/User.Bot.js b/Multi-Period-Market/User.Bot.js index 63bb2135b..71a3e83ed 100644 --- a/Multi-Period-Market/User.Bot.js +++ b/Multi-Period-Market/User.Bot.js @@ -65,8 +65,10 @@ let recordsArray = []; let conditionsArray = []; + let lastObjectsArray = []; let simulationLogic = {}; + commons.initializeData(); for (let i = 0; i < dataDependencies.config.length; i++) { @@ -106,6 +108,7 @@ commons.runSimulation( recordsArray, conditionsArray, + lastObjectsArray, simulationLogic, timePeriod, writeRecordsFile) @@ -234,7 +237,7 @@ } fileContent = "[" + fileContent + "]"; - fileContent = "[" + JSON.stringify(simulationLogic) + "," + fileContent + "]"; + fileContent = "[" + JSON.stringify(simulationLogic) + "," + 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;