9 files changed
+131
-86
No files matched your search
+19
-16
@@ -200,12 +200,12 @@
|
||||
|
||||
/* This is Initialization Code */
|
||||
if (calculationsProcedure.initialization !== undefined) {
|
||||
if (calculationsProcedure.initialization.code !== undefined) {
|
||||
if (calculationsProcedure.initialization.javascriptCode !== undefined) {
|
||||
try {
|
||||
eval(calculationsProcedure.initialization.code.code)
|
||||
eval(calculationsProcedure.initialization.javascriptCode.code)
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] calculationsProcedure -> initialization -> Error executing User Code. Error = " + err.stack)
|
||||
logger.write(MODULE_NAME, "[ERROR] calculationsProcedure -> initialization -> Error executing User Code. Code = " + calculationsProcedure.initialization.code.code);
|
||||
logger.write(MODULE_NAME, "[ERROR] calculationsProcedure -> initialization -> Error executing User Code. Code = " + calculationsProcedure.initialization.javascriptCode.code);
|
||||
throw ("Error Executing User Code.")
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@
|
||||
|
||||
/* This is Initialization Code */
|
||||
if (calculationsProcedure.loop !== undefined) {
|
||||
if (calculationsProcedure.loop.code !== undefined) {
|
||||
if (calculationsProcedure.loop.javascriptCode !== undefined) {
|
||||
for (let index = 0; index < jsonArray.length; index++) {
|
||||
|
||||
let product = {}
|
||||
@@ -221,11 +221,11 @@
|
||||
|
||||
/* This is Loop Code */
|
||||
try {
|
||||
eval(calculationsProcedure.loop.code.code)
|
||||
eval(calculationsProcedure.loop.javascriptCode.code)
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] calculationsProcedure -> loop -> Error executing User Code. Error = " + err.stack)
|
||||
logger.write(MODULE_NAME, "[ERROR] calculationsProcedure -> loop -> Error executing User Code. product = " + JSON.stringify(product))
|
||||
logger.write(MODULE_NAME, "[ERROR] calculationsProcedure -> loop -> Error executing User Code. Code = " + calculationsProcedure.loop.code.code);
|
||||
logger.write(MODULE_NAME, "[ERROR] calculationsProcedure -> loop -> Error executing User Code. Code = " + calculationsProcedure.loop.javascriptCode.code);
|
||||
throw ("Error Executing User Code.")
|
||||
}
|
||||
|
||||
@@ -264,6 +264,7 @@
|
||||
recordDefinition,
|
||||
dataBuildingProcedure,
|
||||
variableName,
|
||||
productName,
|
||||
timePeriod,
|
||||
timePeriodLabel,
|
||||
resultsWithIrregularPeriods,
|
||||
@@ -290,12 +291,12 @@
|
||||
|
||||
/* This is Initialization Code */
|
||||
if (dataBuildingProcedure.initialization !== undefined) {
|
||||
if (dataBuildingProcedure.initialization.code !== undefined) {
|
||||
if (dataBuildingProcedure.initialization.javascriptCode !== undefined) {
|
||||
try {
|
||||
eval(dataBuildingProcedure.initialization.code.code)
|
||||
eval(dataBuildingProcedure.initialization.javascriptCode.code)
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] dataBuildingProcedure -> initialization -> Error executing User Code. Error = " + err.stack)
|
||||
logger.write(MODULE_NAME, "[ERROR] dataBuildingProcedure -> initialization -> Error executing User Code. Code = " + dataBuildingProcedure.initialization.code.code);
|
||||
logger.write(MODULE_NAME, "[ERROR] dataBuildingProcedure -> initialization -> Error executing User Code. Code = " + dataBuildingProcedure.initialization.javascriptCode.code);
|
||||
throw ("Error Executing User Code.")
|
||||
}
|
||||
}
|
||||
@@ -305,19 +306,20 @@
|
||||
/* Initialization of Last Instance */
|
||||
lastInstantOfTheDay = currentDay.valueOf() + ONE_DAY_IN_MILISECONDS - 1;
|
||||
|
||||
if (interExecutionMemory.variable === undefined) {
|
||||
if (interExecutionMemory[productName] === undefined) {
|
||||
/* The first time the intialization variables goes to the Inter Execution Memory. */
|
||||
interExecutionMemory.variable = JSON.parse(JSON.stringify(variable))
|
||||
interExecutionMemory[productName] = {}
|
||||
interExecutionMemory[productName].variable = JSON.parse(JSON.stringify(variable))
|
||||
}
|
||||
else {
|
||||
/* We override the initialization, since the valid stuff is already at the Inter Execution Memory */
|
||||
variable = JSON.parse(JSON.stringify(interExecutionMemory.variable))
|
||||
variable = JSON.parse(JSON.stringify(interExecutionMemory[productName].variable))
|
||||
}
|
||||
}
|
||||
|
||||
/* This is Initialization Code */
|
||||
if (dataBuildingProcedure.loop !== undefined) {
|
||||
if (dataBuildingProcedure.loop.code !== undefined) {
|
||||
if (dataBuildingProcedure.loop.javascriptCode !== undefined) {
|
||||
let lastRecord
|
||||
for (let index = 0; index < mainDependency.records.length; index++) {
|
||||
|
||||
@@ -338,11 +340,11 @@
|
||||
|
||||
/* This is Loop Code */
|
||||
try {
|
||||
eval(dataBuildingProcedure.loop.code.code)
|
||||
eval(dataBuildingProcedure.loop.javascriptCode.code)
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] dataBuildingProcedure -> loop -> Error executing User Code. Error = " + err.stack)
|
||||
logger.write(MODULE_NAME, "[ERROR] dataBuildingProcedure -> loop -> Error executing User Code. product = " + JSON.stringify(product))
|
||||
logger.write(MODULE_NAME, "[ERROR] dataBuildingProcedure -> loop -> Error executing User Code. Code = " + dataBuildingProcedure.loop.code.code);
|
||||
logger.write(MODULE_NAME, "[ERROR] dataBuildingProcedure -> loop -> Error executing User Code. Code = " + dataBuildingProcedure.loop.javascriptCode.code);
|
||||
throw ("Error Executing User Code.")
|
||||
}
|
||||
|
||||
@@ -386,7 +388,8 @@
|
||||
*/
|
||||
if (processingDailyFiles) {
|
||||
if (lastRecord.current.end === lastInstantOfTheDay && yesterday.variable !== undefined) {
|
||||
interExecutionMemory.variable = JSON.parse(JSON.stringify(yesterday.variable))
|
||||
interExecutionMemory[productName] = {}
|
||||
interExecutionMemory[productName].variable = JSON.parse(JSON.stringify(yesterday.variable))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-2
@@ -90,8 +90,19 @@ exports.newDebugLog = function newDebugLog() {
|
||||
thisObject.bot.LOGS_TO_DELETE_QUEUE.push(filePath + '/' + fileName)
|
||||
if (thisObject.bot.LOGS_TO_DELETE_QUEUE.length > thisObject.bot.DELETE_QUEUE_SIZE) {
|
||||
let fileToDelete = thisObject.bot.LOGS_TO_DELETE_QUEUE[0]
|
||||
thisObject.bot.LOGS_TO_DELETE_QUEUE.splice(0,1)
|
||||
fileStorage.deleteTextFile(thisObject.bot.devTeam, fileToDelete);
|
||||
thisObject.bot.LOGS_TO_DELETE_QUEUE.splice(0, 1)
|
||||
/* Will delete this file only if it does not contains ERROR inside. */
|
||||
let fileContent = fileStorage.getTextFile(thisObject.bot.devTeam, fileToDelete, onGetFile, true)
|
||||
function onGetFile(err, fileContent) {
|
||||
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
|
||||
if (fileContent.indexOf("ERROR") < 0) {
|
||||
/* Logs will only be deleted when they contain no ERROR in them. */
|
||||
fileStorage.deleteTextFile(thisObject.bot.devTeam, fileToDelete);
|
||||
}
|
||||
} else {
|
||||
fileStorage.deleteTextFile(thisObject.bot.devTeam, fileToDelete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function writeLog() {
|
||||
|
||||
+7
-3
@@ -89,8 +89,11 @@
|
||||
singularVariableName = outputDatasetNode.referenceParent.parentNode.code.singularVariableName
|
||||
|
||||
/* Check Irregular Periods */
|
||||
if (outputDatasetNode.referenceParent.parentNode.dataBuilding.loop.code.code.indexOf('results.push') >= 0) {
|
||||
resultsWithIrregularPeriods = true
|
||||
|
||||
if (outputDatasetNode.referenceParent.parentNode.dataBuilding.loop.javascriptCode !== undefined) {
|
||||
if (outputDatasetNode.referenceParent.parentNode.dataBuilding.loop.javascriptCode.code.indexOf('results.push') >= 0) {
|
||||
resultsWithIrregularPeriods = true
|
||||
}
|
||||
}
|
||||
|
||||
/* Build the data */
|
||||
@@ -100,6 +103,7 @@
|
||||
recordDefinition,
|
||||
outputDatasetNode.referenceParent.parentNode.dataBuilding,
|
||||
singularVariableName,
|
||||
outputDatasetNode.referenceParent.parentNode.code.codeName,
|
||||
timePeriod,
|
||||
timePeriodLabel,
|
||||
resultsWithIrregularPeriods,
|
||||
@@ -126,7 +130,7 @@
|
||||
let contextSummary = {}
|
||||
|
||||
/* Check Irregular Periods */
|
||||
if (outputDatasetNode.referenceParent.parentNode.dataBuilding.loop.code.code.indexOf('results.push') >= 0) {
|
||||
if (outputDatasetNode.referenceParent.parentNode.dataBuilding.loop.javascriptCode.code.indexOf('results.push') >= 0) {
|
||||
resultsWithIrregularPeriods = true
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -333,7 +333,7 @@
|
||||
|
||||
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriodsMarketFiles -> periodsLoopBody -> dependencyLoopBody -> getFile -> onFileReceived -> err = " + err.stack);
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriodsMarketFiles -> periodsLoopBody -> dependencyLoopBody -> getFile -> onFileReceived -> err = " + err.message);
|
||||
callBackFunction(err);
|
||||
return;
|
||||
}
|
||||
@@ -987,7 +987,7 @@
|
||||
|
||||
let dataRange = {
|
||||
begin: pBegin.valueOf(),
|
||||
end: pEnd.valueOf()
|
||||
end: pEnd.valueOf() + ONE_DAY_IN_MILISECONDS
|
||||
};
|
||||
|
||||
let fileContent = JSON.stringify(dataRange);
|
||||
|
||||
+4
-4
@@ -124,13 +124,13 @@
|
||||
} else {
|
||||
|
||||
/*
|
||||
We look first for the bot who knows the begining of the marke in order to get when the market starts.
|
||||
We look first for the bot who knows the begining of the market in order to get when the market starts.
|
||||
*/
|
||||
|
||||
statusReport = statusDependencies.reportsByMainUtility.get("Market Starting Point")
|
||||
|
||||
if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month.
|
||||
logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. ");
|
||||
logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Market Starting Point -> Status Report does not exist or Market Starting Point not defined. Retrying Later. ");
|
||||
callBackFunction(global.DEFAULT_RETRY_RESPONSE);
|
||||
return;
|
||||
}
|
||||
@@ -175,7 +175,7 @@
|
||||
statusReport = statusDependencies.reportsByMainUtility.get("Market Ending Point")
|
||||
|
||||
if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month.
|
||||
logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. ");
|
||||
logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Market Ending Point -> Status Report does not exist or Market Ending Point not defined. Retrying Later. ");
|
||||
callBackFunction(global.DEFAULT_RETRY_RESPONSE);
|
||||
return;
|
||||
}
|
||||
@@ -208,7 +208,7 @@
|
||||
statusReport = statusDependencies.reportsByMainUtility.get("Self Reference")
|
||||
|
||||
if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month.
|
||||
logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. ");
|
||||
logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Self Reference -> Status Report does not exist or Self Reference not defined. Retrying Later. ");
|
||||
callBackFunction(global.DEFAULT_RETRY_RESPONSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -911,7 +911,9 @@
|
||||
break;
|
||||
case 'Retry': {
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> Restarting Loop in " + (processConfig.retryWaitTime / 1000) + " seconds."); }
|
||||
checkLoopHealthHandle = setTimeout(checkLoopHealth, processConfig.retryWaitTime * 5, bot.loopCounter);
|
||||
if (processConfig.deadWaitTime > 0) {
|
||||
checkLoopHealthHandle = setTimeout(checkLoopHealth, processConfig.retryWaitTime * 5, bot.loopCounter);
|
||||
}
|
||||
nextLoopTimeoutHandle = setTimeout(loop, processConfig.retryWaitTime);
|
||||
logger.persist();
|
||||
}
|
||||
|
||||
+3
-13
@@ -97,7 +97,7 @@
|
||||
/* Simplifying the access to basic info */
|
||||
statusDependencyNode.bot = statusDependencyNode.referenceParent.parentNode.parentNode.code.codeName
|
||||
statusDependencyNode.process = statusDependencyNode.referenceParent.parentNode.code.codeName
|
||||
statusDependencyNode.type = statusDependencyNode.referenceParent.parentNode.parentNode.type
|
||||
statusDependencyNode.bottype = statusDependencyNode.referenceParent.parentNode.parentNode.type
|
||||
statusDependencyNode.devTeam = statusDependencyNode.referenceParent.parentNode.parentNode.parentNode.code.codeName
|
||||
|
||||
/* Let's see if the process is run monthly or not. */
|
||||
@@ -125,12 +125,10 @@
|
||||
}
|
||||
statusDependencyNode.dataSetVersion = "dataSet.V1"
|
||||
|
||||
|
||||
|
||||
if (bot.SESSION !== undefined && statusDependencyNode.type === "Trading Bot Instance") {
|
||||
if (bot.SESSION !== undefined && statusDependencyNode.bottype === "Trading Bot") {
|
||||
sessionPath = bot.SESSION.folderName + "/"
|
||||
}
|
||||
|
||||
|
||||
if (statusDependencyNode.processRunMonthly === true && month !== undefined && year !== undefined) {
|
||||
logger.fileName = MODULE_NAME + "." + statusDependencyNode.bot + "." + statusDependencyNode.process + "." + year + "." + month;
|
||||
timePath = "/" + year + "/" + month;
|
||||
@@ -163,10 +161,6 @@
|
||||
filePath = bot.filePathRoot + "/Reports/" + sessionPath + statusDependencyNode.process + timePath;
|
||||
}
|
||||
|
||||
if (statusDependencyNode.type === 'Trading') {
|
||||
fileName = bot.startMode + "." + fileName;
|
||||
}
|
||||
|
||||
filePath += '/' + fileName
|
||||
|
||||
fileStorage.getTextFile(statusDependencyNode.devTeam, filePath, onFileReceived);
|
||||
@@ -254,10 +248,6 @@
|
||||
let fileName = "Status.Report." + global.MARKET.assetA + '_' + global.MARKET.assetB + ".json";
|
||||
let filePath = bot.filePathRoot + "/Reports/" + sessionPath + statusDependencyNode.process + timePath;
|
||||
|
||||
if (bot.type === 'Trading' ) {
|
||||
fileName = bot.startMode + "." + fileName;
|
||||
}
|
||||
|
||||
filePath += '/' + fileName
|
||||
let fileContent = JSON.stringify(thisObject.file);
|
||||
|
||||
|
||||
+74
-39
@@ -497,6 +497,7 @@
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> loop -> Entering function."); }
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> loop -> Processing candle # " + currentCandleIndex); }
|
||||
|
||||
let announcementsToBeMade = []
|
||||
let candle = candles[currentCandleIndex];
|
||||
|
||||
/* Not processing while out of user-defined time range */
|
||||
@@ -657,8 +658,8 @@
|
||||
let condition = situation.conditions[m];
|
||||
let key = j + '-' + 'triggerStage' + '-' + 'triggerOn' + '-' + k + '-' + m;
|
||||
|
||||
if (condition.code !== undefined) {
|
||||
newCondition(key, condition.code);
|
||||
if (condition.javascriptCode !== undefined) {
|
||||
newCondition(key, condition.javascriptCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -675,8 +676,8 @@
|
||||
let condition = situation.conditions[m];
|
||||
let key = j + '-' + 'triggerStage' + '-' + 'triggerOff' + '-' + k + '-' + m;
|
||||
|
||||
if (condition.code !== undefined) {
|
||||
newCondition(key, condition.code);
|
||||
if (condition.javascriptCode !== undefined) {
|
||||
newCondition(key, condition.javascriptCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -693,8 +694,8 @@
|
||||
let condition = situation.conditions[m];
|
||||
let key = j + '-' + 'triggerStage' + '-' + 'takePosition' + '-' + k + '-' + m;
|
||||
|
||||
if (condition.code !== undefined) {
|
||||
newCondition(key, condition.code);
|
||||
if (condition.javascriptCode !== undefined) {
|
||||
newCondition(key, condition.javascriptCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -824,8 +825,8 @@
|
||||
let condition = situation.conditions[m];
|
||||
let key = j + '-' + 'openStage' + '-' + 'initialDefinition' + '-' + 'stopLoss' + '-' + p + '-' + k + '-' + m;
|
||||
|
||||
if (condition.code !== undefined) {
|
||||
newCondition(key, condition.code);
|
||||
if (condition.javascriptCode !== undefined) {
|
||||
newCondition(key, condition.javascriptCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -890,8 +891,8 @@
|
||||
let condition = situation.conditions[m];
|
||||
let key = j + '-' + 'openStage' + '-' + 'initialDefinition' + '-' + 'takeProfit' + '-' + p + '-' + k + '-' + m;
|
||||
|
||||
if (condition.code !== undefined) {
|
||||
newCondition(key, condition.code);
|
||||
if (condition.javascriptCode !== undefined) {
|
||||
newCondition(key, condition.javascriptCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -966,8 +967,8 @@
|
||||
let condition = situation.conditions[m];
|
||||
let key = j + '-' + 'manageStage' + '-' + 'stopLoss' + '-' + p + '-' + k + '-' + m;
|
||||
|
||||
if (condition.code !== undefined) {
|
||||
newCondition(key, condition.code);
|
||||
if (condition.javascriptCode !== undefined) {
|
||||
newCondition(key, condition.javascriptCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1033,8 +1034,8 @@
|
||||
let condition = situation.conditions[m];
|
||||
let key = j + '-' + 'manageStage' + '-' + 'takeProfit' + '-' + p + '-' + k + '-' + m;
|
||||
|
||||
if (condition.code !== undefined) {
|
||||
newCondition(key, condition.code);
|
||||
if (condition.javascriptCode !== undefined) {
|
||||
newCondition(key, condition.javascriptCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1224,7 +1225,7 @@
|
||||
currentStrategy.number = currentStrategyIndex
|
||||
currentStrategy.end = candle.end;
|
||||
currentStrategy.endRate = candle.min;
|
||||
currentStrategy.status = 1;
|
||||
currentStrategy.status = 1; // This means the strategy is closed, i.e. that has a begin and end.
|
||||
strategyStage = 'No Stage';
|
||||
currentStrategyIndex = -1;
|
||||
|
||||
@@ -2453,7 +2454,7 @@
|
||||
currentStrategy.number = currentStrategyIndex
|
||||
currentStrategy.end = candle.end;
|
||||
currentStrategy.endRate = candle.min;
|
||||
currentStrategy.status = 1;
|
||||
currentStrategy.status = 1; // This means the strategy is closed, i.e. that has a begin and end.
|
||||
|
||||
if (processingDailyFiles) {
|
||||
if (positionedAtYesterday) {
|
||||
@@ -2601,13 +2602,18 @@
|
||||
|
||||
conditionsArray.push(conditionsArrayRecord);
|
||||
|
||||
/*
|
||||
Lets see if there will be an open strategy ...
|
||||
Except if we are at the head of the market (remember we skipped the last candle for not being closed.)
|
||||
*/
|
||||
if (currentStrategy.begin !== 0 && currentStrategy.end === 0 && currentCandleIndex === candles.length - 2 && lastCandle.end !== lastInstantOfTheDay) {
|
||||
currentStrategy.status = 2; // This means the strategy is open, i.e. that has a begin but no end.
|
||||
currentStrategy.end = candle.end
|
||||
}
|
||||
|
||||
/* Prepare the information for the Strategies File*/
|
||||
|
||||
if (
|
||||
(currentStrategy.begin !== 0 && currentStrategy.end !== 0) ||
|
||||
(currentStrategy.begin !== 0 && currentCandleIndex === candles.length - 1 && lastCandle.end !== lastInstantOfTheDay)
|
||||
) {
|
||||
|
||||
if (currentStrategy.begin !== 0 && currentStrategy.end !== 0)
|
||||
{
|
||||
strategiesArray.push(currentStrategy);
|
||||
|
||||
currentStrategy = {
|
||||
@@ -2633,12 +2639,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Prepare the information for the Trades File */
|
||||
/*
|
||||
Lets see if there will be an open trade ...
|
||||
Except if we are at the head of the market (remember we skipped the last candle for not being closed.)
|
||||
*/
|
||||
if (currentTrade.begin !== 0 && currentTrade.end === 0 && currentCandleIndex === candles.length - 2 && lastCandle.end !== lastInstantOfTheDay) {
|
||||
currentTrade.status = 2; // This means the trade is open
|
||||
currentTrade.end = candle.end
|
||||
currentTrade.endRate = candle.close
|
||||
|
||||
if (
|
||||
(currentTrade.begin !== 0 && currentTrade.end !== 0) ||
|
||||
(currentTrade.begin !== 0 && currentCandleIndex === candles.length - 1 && lastCandle.end !== lastInstantOfTheDay)
|
||||
) {
|
||||
/* Here we will calculate the ongoing ROI */
|
||||
if (bot.VALUES_TO_USE.baseAsset === 'BTC') {
|
||||
currentTrade.lastTradeROI = (tradePositionRate - candle.close) / tradePositionRate * 100
|
||||
} else {
|
||||
currentTrade.lastTradeROI = (candle.close - tradePositionRate) / tradePositionRate * 100
|
||||
}
|
||||
}
|
||||
|
||||
/* Prepare the information for the Trades File */
|
||||
if (currentTrade.begin !== 0 && currentTrade.end !== 0) {
|
||||
|
||||
currentTrade.profit = lastTradeProfitLoss;
|
||||
|
||||
@@ -2668,6 +2687,8 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
makeAnnoucements() // After everything at the simulation level was done, we will do the annoucements that are pending.
|
||||
}
|
||||
|
||||
function checkAnnouncements(node, value) {
|
||||
@@ -2714,18 +2735,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Here we check if there is a formula attached to the annoucement, we evaluate it to get the annoucement text. */
|
||||
let formulaValue
|
||||
if (announcement.formula !== undefined) {
|
||||
try {
|
||||
formulaValue = eval(announcement.formula.code);
|
||||
} catch (err) {
|
||||
announcement.formula.error = err.message
|
||||
}
|
||||
}
|
||||
announcement.formulaValue = formulaValue
|
||||
|
||||
bot.SESSION.socialBots.announce(announcement)
|
||||
/*
|
||||
We store the announcement temporarily at an Array to differ its execution, becasue we need to evaulate its formula
|
||||
and at this point in time the potential variables used at the formula are still not set.
|
||||
*/
|
||||
announcementsToBeMade.push(announcement)
|
||||
|
||||
/* Next, we will remmeber this announcement was already done, so that it is not announced again in further processing of the same day. */
|
||||
if (newAnnouncementRecord.periods !== undefined) {
|
||||
@@ -2743,8 +2757,29 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function makeAnnoucements() {
|
||||
/* Here we go through all the annoucements that need to be done during this loop, and we just do them. */
|
||||
for (let i = 0; i < announcementsToBeMade.length; i++) {
|
||||
announcement = announcementsToBeMade[i]
|
||||
/* Here we check if there is a formula attached to the annoucement, we evaluate it to get the annoucement text. */
|
||||
let formulaValue
|
||||
if (announcement.formula !== undefined) {
|
||||
try {
|
||||
formulaValue = eval(announcement.formula.code);
|
||||
} catch (err) {
|
||||
announcement.formula.error = err.message
|
||||
}
|
||||
}
|
||||
announcement.formulaValue = formulaValue
|
||||
|
||||
bot.SESSION.socialBots.announce(announcement)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function controlLoop() {
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> controlLoop -> Entering function."); }
|
||||
|
||||
|
||||
@@ -177,32 +177,32 @@ function bootLoader() {
|
||||
/* Validate that the minimun amount of parameters required are defined. */
|
||||
|
||||
if (global.TASK_NODE.bot.processes[processIndex].referenceParent === undefined) {
|
||||
console.log("[INFO] Task Server -> server -> bootLoader -> Process Instance without a Reference Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
|
||||
console.log("[WARN] Task Server -> server -> bootLoader -> Process Instance without a Reference Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
|
||||
continue
|
||||
}
|
||||
|
||||
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode === undefined) {
|
||||
console.log("[INFO] Task Server -> server -> bootLoader -> Process Definition without parent Bot Definition. -> Process Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent));
|
||||
console.log("[WARN] Task Server -> server -> bootLoader -> Process Definition without parent Bot Definition. -> Process Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent));
|
||||
continue
|
||||
}
|
||||
|
||||
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode === undefined) {
|
||||
console.log("[INFO] Task Server -> server -> bootLoader -> Bot Definition without parent Team. -> Bot Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode));
|
||||
console.log("[WARN] Task Server -> server -> bootLoader -> Bot Definition without parent Team. -> Bot Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode));
|
||||
continue
|
||||
}
|
||||
|
||||
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.code.codeName === undefined) {
|
||||
console.log("[INFO] Task Server -> server -> bootLoader -> Process Definition without a codeName defined. -> Process Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent));
|
||||
console.log("[WARN] Task Server -> server -> bootLoader -> Process Definition without a codeName defined. -> Process Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent));
|
||||
continue
|
||||
}
|
||||
|
||||
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.code.codeName === undefined) {
|
||||
console.log("[INFO] Task Server -> server -> bootLoader -> Bot Definition without a codeName defined. -> Bot Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode));
|
||||
console.log("[WARN] Task Server -> server -> bootLoader -> Bot Definition without a codeName defined. -> Bot Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode));
|
||||
continue
|
||||
}
|
||||
|
||||
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.code.codeName === undefined) {
|
||||
console.log("[INFO] Task Server -> server -> bootLoader -> Team without a codeName defined. -> Team Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode));
|
||||
console.log("[WARN] Task Server -> server -> bootLoader -> Team without a codeName defined. -> Team Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode));
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user