diff --git a/LowFrequencyTrading/Announcements.js b/LowFrequencyTrading/Announcements.js index 4f9d92f5a..99fdb57b3 100644 --- a/LowFrequencyTrading/Announcements.js +++ b/LowFrequencyTrading/Announcements.js @@ -14,7 +14,7 @@ exports.newAnnouncements = function newAnnouncements(bot, logger) { return thisObject function initialize() { - tradingEngine = bot.TRADING_ENGINE + tradingEngine = bot.simulationState.tradingEngine } function finalize() { diff --git a/LowFrequencyTrading/Snapshots.js b/LowFrequencyTrading/Snapshots.js index a8aa133f8..37c8ddf9b 100644 --- a/LowFrequencyTrading/Snapshots.js +++ b/LowFrequencyTrading/Snapshots.js @@ -39,7 +39,7 @@ exports.newSnapshots = function newSnapshots(bot, logger) { return thisObject function initialize() { - tradingEngine = bot.TRADING_ENGINE + tradingEngine = bot.simulationState.tradingEngine } function finalize() { diff --git a/LowFrequencyTrading/TradingEngine.js b/LowFrequencyTrading/TradingEngine.js index 3fa6fdd64..4f61a7282 100644 --- a/LowFrequencyTrading/TradingEngine.js +++ b/LowFrequencyTrading/TradingEngine.js @@ -22,7 +22,7 @@ exports.newTradingEngine = function newTradingEngine(bot, logger) { function initialize() { /* Here we will go through all the nodes in the Trading Engine hiriarchy and apply the initial value to the value property when needed */ - tradingEngine = bot.TRADING_ENGINE + tradingEngine = bot.simulationState.tradingEngine if (tradingEngine.isInitialized !== true || bot.RESUME === false) { tradingEngine.isInitialized = true diff --git a/LowFrequencyTrading/TradingExecution.js b/LowFrequencyTrading/TradingExecution.js index 4aa191a79..b8343c0d7 100644 --- a/LowFrequencyTrading/TradingExecution.js +++ b/LowFrequencyTrading/TradingExecution.js @@ -15,7 +15,7 @@ exports.newTradingExecution = function newTradingExecution(bot, logger) { function initialize() { - tradingEngine = bot.TRADING_ENGINE + tradingEngine = bot.simulationState.tradingEngine } diff --git a/LowFrequencyTrading/TradingOutput.js b/LowFrequencyTrading/TradingOutput.js index cd5c60f2b..158758c7d 100644 --- a/LowFrequencyTrading/TradingOutput.js +++ b/LowFrequencyTrading/TradingOutput.js @@ -32,7 +32,7 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, UTILITIES, FIL } } - function start(chart, timeFrame, timeFrameLabel, currentDay, simulationState, callBackFunction) { + function start(chart, timeFrame, timeFrameLabel, currentDay, callBackFunction) { try { bot.processingDailyFiles if (timeFrame > global.dailyFilePeriods[0][0]) { @@ -54,8 +54,8 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, UTILITIES, FIL let outputDatasetsMap = new Map() if (bot.RESUME !== true) { - simulationState.tradingEngine = bot.SESSION.tradingEngine - simulationState.tradingSystem = bot.SESSION.tradingSystem + bot.simulationState.tradingEngine = bot.simulationState.tradingEngine + bot.simulationState.tradingSystem = bot.simulationState.tradingSystem } readFiles() return @@ -146,7 +146,6 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, UTILITIES, FIL function runSimulation() { tradingSimulation.runSimulation( chart, - simulationState, outputDatasetsMap, writeFiles, callBackFunction) diff --git a/LowFrequencyTrading/TradingProcess.js b/LowFrequencyTrading/TradingProcess.js index aedb17798..188b93060 100644 --- a/LowFrequencyTrading/TradingProcess.js +++ b/LowFrequencyTrading/TradingProcess.js @@ -79,7 +79,6 @@ }; let previousDay; // Holds the date of the previous day relative to the processing date. - let simulationState getContextVariables(); @@ -152,8 +151,8 @@ } thisReport = statusReport.file; - simulationState = thisReport.simulationState; - if (simulationState === undefined) { simulationState = {} } // This should happen only when there is no status report + bot.simulationState = thisReport.simulationState; + if (bot.simulationState === undefined) { bot.simulationState = {} } // This should happen only when there is no status report if (thisReport.lastFile !== undefined) { if (bot.hasTheBotJustStarted === true && bot.resumeExecution === false) { @@ -594,7 +593,6 @@ currentTimeFrame, currentTimeFrameLabel, bot.tradingProcessDate, - simulationState, onOutputGenerated); function onOutputGenerated(err) { @@ -716,7 +714,7 @@ thisReport.file.lastExecution = bot.currentDaytime; thisReport.file.lastFile = lastFileDate; - thisReport.file.simulationState = simulationState; + thisReport.file.simulationState = bot.simulationState; thisReport.save(callBack); bot.hasTheBotJustStarted = false; @@ -727,7 +725,7 @@ let thisReport = statusDependencies.statusReports.get(reportKey); thisReport.file.lastExecution = bot.processDatetime; - thisReport.file.simulationState = simulationState; + thisReport.file.simulationState = bot.simulationState; thisReport.save(callBack); logger.newInternalLoop(bot.codeName, bot.process, bot.tradingProcessDate); diff --git a/LowFrequencyTrading/TradingRecords.js b/LowFrequencyTrading/TradingRecords.js index fbbe6cb45..92d5c70c7 100644 --- a/LowFrequencyTrading/TradingRecords.js +++ b/LowFrequencyTrading/TradingRecords.js @@ -15,8 +15,8 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) { return thisObject function initialize(pOutputDatasets, pOutputDatasetsMap) { - tradingEngine = bot.TRADING_ENGINE - tradingSystem = bot.TRADING_SYSTEM + tradingEngine = bot.simulationState.tradingEngine + tradingSystem = bot.simulationState.tradingSystem outputDatasetsMap = pOutputDatasetsMap // These are the files turned into arrays, stored in a Map by Product codeName. } diff --git a/LowFrequencyTrading/TradingSimulation.js b/LowFrequencyTrading/TradingSimulation.js index 51cc0d8ed..b3e79419f 100644 --- a/LowFrequencyTrading/TradingSimulation.js +++ b/LowFrequencyTrading/TradingSimulation.js @@ -18,14 +18,13 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, UTILIT function runSimulation( chart, - simulationState, outputDatasetsMap, callback, callBackFunction) { try { - let tradingSystem = simulationState.tradingSystem - let tradingEngine = simulationState.tradingEngine + let tradingSystem = bot.simulationState.tradingSystem + let tradingEngine = bot.simulationState.tradingEngine let sessionParameters = bot.SESSION.parameters if (FULL_LOG === true) { logger.write(MODULE_NAME, '[INFO] runSimulation -> initialDatetime = ' + sessionParameters.timeRange.config.initialDatetime) } @@ -47,7 +46,7 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, UTILIT /* These are the Modules we will need to run the Simulation */ - const EXCHANGE_API = require(global.ROOT_DIR + 'ExchangeAPI'); + const EXCHANGE_API = require('../ExchangeAPI'); exchangeAPI = EXCHANGE_API.newExchangeAPI(logger, bot); exchangeAPI.initialize(); diff --git a/LowFrequencyTrading/TradingSystem.js b/LowFrequencyTrading/TradingSystem.js index 195b67999..02732f1d9 100644 --- a/LowFrequencyTrading/TradingSystem.js +++ b/LowFrequencyTrading/TradingSystem.js @@ -32,8 +32,8 @@ exports.newTradingSystem = function newTradingSystem(bot, logger) { return thisObject function initialize() { - tradingSystem = bot.TRADING_SYSTEM - tradingEngine = bot.TRADING_ENGINE + tradingSystem = bot.simulationState.tradingSystem + tradingEngine = bot.simulationState.tradingEngine tradingSystem.highlights = [] tradingSystem.conditionsErrors = [] @@ -61,11 +61,11 @@ exports.newTradingSystem = function newTradingSystem(bot, logger) { } function evalConditions() { - evalNode(bot.TRADING_SYSTEM, 'Conditions') + evalNode(bot.simulationState.tradingSystem, 'Conditions') } function evalFormulas() { - evalNode(bot.TRADING_SYSTEM, 'Formulas') + evalNode(bot.simulationState.tradingSystem, 'Formulas') } function evalNode(node, evaluating) {