From 919f8946aeae941e55187d99fd55ef05d36dad85 Mon Sep 17 00:00:00 2001 From: Matias Benitez Date: Mon, 9 Jul 2018 11:17:54 -0300 Subject: [PATCH 1/4] Improving email function --- Assistant.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Assistant.js b/Assistant.js index 5681e0447..8ceffa1ce 100644 --- a/Assistant.js +++ b/Assistant.js @@ -1312,14 +1312,11 @@ } function sendMessage(pRelevance, pTitle, pBody) { + let runIndex = context.statusReport.runs.length - 1; context.newHistoryRecord.messageRelevance = pRelevance; - context.newHistoryRecord.messageTitle = pTitle; + context.newHistoryRecord.messageTitle = bot.startMode + "." + runIndex +": "+ pTitle; context.newHistoryRecord.messageBody = pBody; - - if(pRelevance > 6){ - sendEmail(pTitle, pBody, false); - } } @@ -1347,12 +1344,10 @@ } - function sendEmail(pTitle, pBody, pSendToAdmins) { + function sendEmail(pTitle, pBody, pTo) { try { - let emailList = global.EMAIL_CONFIG.distributionList; - if (pSendToAdmins) { - emailList = global.EMAIL_CONFIG.adminList; - } + let emailList = pTo; //TODO Pending to add spam controller + let runIndex = context.statusReport.runs.length - 1; let transporter = nodemailer.createTransport({ service: global.EMAIL_CONFIG.service, @@ -1365,7 +1360,7 @@ let mailOptions = { from: global.EMAIL_CONFIG.from, bcc: emailList, - subject: bot.startMode + ' - ' + pTitle, + subject: bot.startMode + "." + runIndex + ' - ' + pTitle, text: pBody }; @@ -1381,4 +1376,5 @@ logger.write(MODULE_NAME, "[ERROR] sendEmail -> err = " + err.message); } } + }; \ No newline at end of file From fce7e0371b53a9595068a8fc5acbc720bdc777fe Mon Sep 17 00:00:00 2001 From: Matias Benitez Date: Mon, 9 Jul 2018 11:18:15 -0300 Subject: [PATCH 2/4] Pointing proyect to relative path --- Project.njsproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Project.njsproj b/Project.njsproj index 34e1c0483..a7e60900f 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -7,7 +7,7 @@ ShowAllFiles Run.js - C:\Users\Luis\source\repos\AACloud + .\ . {3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{349c5851-65df-11da-9384-00065b846f21};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD} 14.0 @@ -16,6 +16,7 @@ Trading-Process C:\Program Files\nodejs\node.exe False + Debug|Any CPU From b13bfeaa4e1d5be138ea65e86e9333c432607f99 Mon Sep 17 00:00:00 2001 From: Matias Benitez Date: Mon, 9 Jul 2018 11:18:44 -0300 Subject: [PATCH 3/4] Disabling content log for context --- Root.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Root.js b/Root.js index 1fe0135d1..cf2dd5839 100644 --- a/Root.js +++ b/Root.js @@ -132,7 +132,7 @@ exports.newRoot = function newRoot() { logInfo: true, logWarnings: false, logErrors: true, - logContent: true, + logContent: false, intensiveLogging: false } }; From f4a9b63dc8da95b6734789346e24b0c29d461112 Mon Sep 17 00:00:00 2001 From: Matias Benitez Date: Mon, 9 Jul 2018 11:19:35 -0300 Subject: [PATCH 4/4] Changing email and initial time for backtesting. Initial time for backtesting looks for mimic the live scenario. --- TradingBotProcessMainLoop.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/TradingBotProcessMainLoop.js b/TradingBotProcessMainLoop.js index 4dd3897be..d6b20ac0b 100644 --- a/TradingBotProcessMainLoop.js +++ b/TradingBotProcessMainLoop.js @@ -247,11 +247,11 @@ } /* - We will standarize the backtesting execution time, setting the exact time at the middle of the candle or timePeriod. + We will standarize the backtesting execution time, setting the exact time a fraction after the start of the candle or timePeriod. */ let totalMiliseconds = bot.processDatetime.valueOf(); - totalMiliseconds = Math.trunc(totalMiliseconds / timePeriod) * timePeriod + timePeriod / 2; + totalMiliseconds = Math.trunc(totalMiliseconds / timePeriod) * timePeriod + timePeriod / 6; bot.processDatetime = new Date(totalMiliseconds); @@ -855,7 +855,7 @@ clearTimeout(nextLoopTimeoutHandle); clearTimeout(checkLoopHealthHandle); bot.enableCheckLoopHealth = false; - assistant.sendEmail("FAIL", "Operation Failed. Aborting the process. err = " + err.message, true); + assistant.sendEmail("FAIL", "Operation Failed. Aborting the process. err = " + err.message, emailList = global.EMAIL_CONFIG.adminList); callBackFunction(err); return; } @@ -868,7 +868,7 @@ clearTimeout(nextLoopTimeoutHandle); clearTimeout(checkLoopHealthHandle); bot.enableCheckLoopHealth = false; - assistant.sendEmail("FAIL", "Operation Failed. Aborting the process. err = " + err.message, true); + assistant.sendEmail("FAIL", "Operation Failed. Aborting the process. err = " + err.message, emailList = global.EMAIL_CONFIG.adminList); callBackFunction(global.DEFAULT_FAIL_RESPONSE); return; } @@ -881,7 +881,7 @@ clearTimeout(nextLoopTimeoutHandle); clearTimeout(checkLoopHealthHandle); bot.enableCheckLoopHealth = false; - assistant.sendEmail("FAIL", "Operation Failed. Aborting the process. err = " + err.message, true); + assistant.sendEmail("FAIL", "Operation Failed. Aborting the process. err = " + err.message, emailList = global.EMAIL_CONFIG.adminList); callBackFunction(err); } } @@ -893,7 +893,7 @@ clearTimeout(nextLoopTimeoutHandle); clearTimeout(checkLoopHealthHandle); bot.enableCheckLoopHealth = false; - assistant.sendEmail("FAIL", "Operation Failed. Aborting the process. err = " + err.message, true); + assistant.sendEmail("FAIL", "Operation Failed. Aborting the process. err = " + err.message, emailList = global.EMAIL_CONFIG.adminList); callBackFunction(err); } }