Simulation being called

This commit is contained in:
Luis Fernando Molina committed 2020-06-11 18:39:19 +02:00
1 parent c21684fde6
commit e404047a07
4 files changed
+15 -18

No files matched your search

+7 -7
View File
@@ -45,8 +45,11 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, UTILITIES, FIL
const TRADING_SIMULATION = require('./TradingSimulation.js')
let tradingSimulation = TRADING_SIMULATION.newTradingSimulation(bot, logger, UTILITIES)
let outputDatasets = bot.processNode.referenceParent.processOutput.outputDatasets
let market = bot.market
let totalFilesToBeRead = 0
let totalFilesRead = 0
let totalFilesToBeWritten = 0
let totalFilesWritten = 0
let outputDatasetsMap = new Map()
@@ -102,9 +105,8 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, UTILITIES, FIL
}
function readOutputFile(fileName, filePath, productName) {
totalFilesToBeRead++
filePath += '/' + fileName
fileStorage.getTextFile(filePath, onFileRead, true)
function onFileRead(err, text) {
@@ -136,7 +138,7 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, UTILITIES, FIL
function anotherFileRead() {
totalFilesRead++
if (totalFilesRead === outputDatasets.length) {
if (totalFilesRead === totalFilesToBeRead) {
runSimulation()
}
}
@@ -144,9 +146,7 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, UTILITIES, FIL
function runSimulation() {
tradingSimulation.runSimulation(
chart,
dataDependencies,
simulationState,
outputDatasets,
outputDatasetsMap,
writeFiles,
callBackFunction)
@@ -195,7 +195,7 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, UTILITIES, FIL
}
function writeOutputFile(fileName, filePath, productName) {
totalFilesToBeWritten++
filePath += '/' + fileName
let fileContent = JSON.stringify(outputDatasetsMap.get(productName))
@@ -222,7 +222,7 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, UTILITIES, FIL
function anotherFileWritten() {
totalFilesWritten++
if (totalFilesWritten === outputDatasets.length) {
if (totalFilesWritten === totalFilesToBeWritten) {
callBackFunction(global.DEFAULT_OK_RESPONSE)
}
}
+3 -3
View File
@@ -558,7 +558,7 @@
let products = {}
if (dataFiles !== undefined) {
commons.inflateDatafiles(dataFiles, dataDependencies, products, mainDependency, timeFrame)
commons.inflateDatafiles(dataFiles, dataDependencies, products, mainDependency, currentTimeFrame)
let propertyName = 'at' + timeFrameLabel.replace('-', '')
chart[propertyName] = products
@@ -571,7 +571,7 @@
let products = {}
if (dataFiles !== undefined) {
commons.inflateDatafiles(dataFiles, dataDependencies, products, mainDependency, timeFrame)
commons.inflateDatafiles(dataFiles, dataDependencies, products, mainDependency, currentTimeFrame)
let propertyName = 'at' + timeFrameLabel.replace('-', '')
chart[propertyName] = products
@@ -583,7 +583,7 @@
let products = {}
if (dataFiles !== undefined) {
commons.inflateDatafiles(dataFiles, dataDependencies, products, mainDependency, timeFrame)
commons.inflateDatafiles(dataFiles, dataDependencies, products, mainDependency, currentTimeFrame)
let propertyName = 'atAnyTimeFrame'
chart[propertyName] = products
+1 -3
View File
@@ -10,7 +10,6 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
let tradingEngine
let tradingSystem
let outputDatasets
let outputDatasetsMap
return thisObject
@@ -18,14 +17,12 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
function initialize(pOutputDatasets, pOutputDatasetsMap) {
tradingEngine = bot.TRADING_ENGINE
tradingSystem = bot.TRADING_SYSTEM
outputDatasets = pOutputDatasets // These are the nodes defined at the UI
outputDatasetsMap = pOutputDatasetsMap // These are the files turned into arrays, stored in a Map by Product codeName.
}
function finalize() {
tradingEngine = undefined
tradingSystem = undefined
outputDatasets = undefined
outputDatasetsMap = undefined
}
@@ -35,6 +32,7 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
we have a pointer to the node that have the information we need to extract.
Later, based on the product record definition we will extract each individual value.
*/
let outputDatasets = bot.processNode.referenceParent.processOutput.outputDatasets
for (let i = 0; i < outputDatasets.length; i++) {
let outputDatasetNode = outputDatasets[i]
let dataset = outputDatasetNode.referenceParent
+4 -5
View File
@@ -18,9 +18,7 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, UTILIT
function runSimulation(
chart,
dataDependencies,
simulationState,
outputDatasets,
outputDatasetsMap,
callback,
callBackFunction) {
@@ -57,13 +55,13 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, UTILIT
let tradingEngineModule = TRADING_ENGINE_MODULE.newTradingEngine(bot, logger)
tradingEngineModule.initialize()
const TRADING_ENGINE_MODULE = require('./TradingExecution.js')
let tradingExecutionModule = TRADING_ENGINE_MODULE.newTradingExecution(bot, logger)
const TRADING_ENGINE_EXECUTION = require('./TradingExecution.js')
let tradingExecutionModule = TRADING_ENGINE_EXECUTION.newTradingExecution(bot, logger)
tradingExecutionModule.initialize()
const TRADING_RECORDS_MODULE = require('./TradingRecords.js')
let tradingRecordsModule = TRADING_RECORDS_MODULE.newTradingRecords(bot, logger)
tradingRecordsModule.initialize(outputDatasets, outputDatasetsMap)
tradingRecordsModule.initialize(outputDatasetsMap)
const SNAPSHOTS_MODULE = require('./Snapshots.js')
let snapshotsModule = SNAPSHOTS_MODULE.newSnapshots(bot, logger)
@@ -350,6 +348,7 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, UTILIT
easy access to the current candle for instance, or the current bollinger band, meaning the one the Simulation is currently standing at.
For that reason we do the following processing, to have at the chart data structure the current objects of each indicator / time frame.
*/
let dataDependencies = bot.processNode.referenceParent.processDependencies.dataDependencies
/* Finding the Current Element on Market Files */
if (bot.processingDailyFiles) {