Several bug fixes
This commit is contained in:
1 parent
68f767e15a
commit
98484dc7fa
4 files changed
+22
-19
No files matched your search
@@ -54,7 +54,7 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, UTILITIES, FIL
|
||||
} else {
|
||||
await readFiles()
|
||||
}
|
||||
|
||||
|
||||
await tradingSimulation.runSimulation(
|
||||
chart,
|
||||
outputDatasetsMap,
|
||||
@@ -148,7 +148,7 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, UTILITIES, FIL
|
||||
if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
throw(response.err)
|
||||
}
|
||||
outputDatasetsMap.set(productName, JSON.parse(text))
|
||||
outputDatasetsMap.set(productName, JSON.parse(response.text))
|
||||
}
|
||||
|
||||
async function writeFiles() {
|
||||
|
||||
@@ -63,7 +63,7 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
|
||||
}
|
||||
|
||||
/* Clean the file from information of previous executions */
|
||||
pruneOutputFile(product, outputDatasetArray)
|
||||
pruneOutputFile(product, outputDatasetArray, tradingEngine.current.episode.candle.end.value)
|
||||
|
||||
/* Clean Open Records */
|
||||
if (product.config.saveAsObjects === true) {
|
||||
@@ -321,7 +321,7 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
|
||||
return value
|
||||
}
|
||||
|
||||
function pruneOutputFile(product, outputFile) {
|
||||
function pruneOutputFile(product, outputFile, currentEnd) {
|
||||
if (outputFile.isPrunned === true) { return }
|
||||
/*
|
||||
When a session is resumed, we will be potentially reading output files belonging to a previous session execution.
|
||||
@@ -335,14 +335,14 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
|
||||
let recordProperty = product.record.properties[j]
|
||||
if (recordProperty.config.codeName === 'end') {
|
||||
let end = record[j]
|
||||
if (end >= tradingEngine.current.episode.candle.end.value) {
|
||||
if (end >= currentEnd) {
|
||||
outputFile.splice(i, 1)
|
||||
/*
|
||||
This will execute the next prune call in the next iteration of the NodeJs event loop
|
||||
allowing for other callbacks to be executed. It also prevents the error
|
||||
'Maximum call stack size exceeded', since the call is not placed at the call stack.
|
||||
*/
|
||||
setImmediate(pruneOutputFile, product, outputFile)
|
||||
setImmediate(pruneOutputFile, product, outputFile, currentEnd)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,8 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, UTILIT
|
||||
This will happen when the sessionParameters.timeRange.config.initialDatetime is beyond the last candle available,
|
||||
meaning that the dataSet needs to be updated with more up-to-date data.
|
||||
*/
|
||||
tradingEngine.current.episode.candle.index.value = candles.length - 1
|
||||
bot.SESSION.stop('Data is not up-to-date enough. Please start the Masters Data Mining Operation.')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-12
@@ -38,8 +38,8 @@
|
||||
bot.sessionKey = bot.processNode.session.name + '-' + bot.processNode.session.type + '-' + bot.processNode.session.id
|
||||
global.SESSION_MAP.set(bot.sessionKey, bot.sessionKey)
|
||||
|
||||
global.EVENT_SERVER_CLIENT.listenToEvent(bot.sessionKey, 'Run Session', undefined, bot.sessionKey, undefined, runSession)
|
||||
global.EVENT_SERVER_CLIENT.listenToEvent(bot.sessionKey, 'Stop Session', undefined, bot.sessionKey, undefined, stopSession)
|
||||
global.EVENT_SERVER_CLIENT.listenToEvent(bot.sessionKey, 'Run Session', undefined, bot.sessionKey, undefined, onSessionRan)
|
||||
global.EVENT_SERVER_CLIENT.listenToEvent(bot.sessionKey, 'Stop Session', undefined, bot.sessionKey, undefined, onSessionStopped)
|
||||
|
||||
/* Errors sent to the UI */
|
||||
bot.sessionError = sessionError
|
||||
@@ -50,7 +50,7 @@
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE)
|
||||
return
|
||||
|
||||
function runSession(message) {
|
||||
function onSessionRan(message) {
|
||||
try {
|
||||
if (bot.SESSION_STATUS === 'Idle' || bot.SESSION_STATUS === 'Running') { return } // This happens when the UI is reloaded, the session was running and tries to run it again.
|
||||
|
||||
@@ -99,19 +99,21 @@
|
||||
|
||||
socialBotsModule.sendMessage(bot.SESSION.type + " '" + bot.SESSION.name + "' is starting.")
|
||||
} catch (err) {
|
||||
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> runSession -> err = " + err.stack);
|
||||
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onSessionRan -> err = " + err.stack);
|
||||
}
|
||||
}
|
||||
|
||||
function onSessionStopped() {
|
||||
stopSession('Session Stopped From the User Interface.')
|
||||
}
|
||||
|
||||
function stopSession(commandOrigin) {
|
||||
try {
|
||||
if (commandOrigin === undefined) { commandOrigin = ' from the User Interface.' }
|
||||
socialBotsModule.sendMessage(bot.SESSION.type + " '" + bot.SESSION.name + "' is stopping " + commandOrigin)
|
||||
socialBotsModule.finalize()
|
||||
bot.STOP_SESSION = true
|
||||
} catch (err) {
|
||||
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> stopSession -> err = " + err.stack);
|
||||
}
|
||||
|
||||
socialBotsModule.sendMessage(bot.SESSION.type + " '" + bot.SESSION.name + "' is stopping " + commandOrigin)
|
||||
socialBotsModule.finalize()
|
||||
bot.STOP_SESSION = true
|
||||
sessionError(bot.SESSION, commandOrigin)
|
||||
|
||||
}
|
||||
|
||||
function setUpAppSchema() {
|
||||
|
||||
Reference in new issue
Block a user