Bug Fixes plus backtesting running

This commit is contained in:
Luis Fernando Molina committed 2020-02-06 10:16:53 +01:00
1 parent 7b6bcb6634
commit 009b0ddb55
6 files changed
+29 -42

No files matched your search

+21 -7
View File
@@ -49,7 +49,6 @@
/* We are going to run the Definition comming at the event. */
bot.TRADING_SYSTEM = JSON.parse(message.event.tradingSystem)
bot.SESSION = JSON.parse(message.event.session)
bot.UI_CURRENT_VALUES = message.event.uiCurrentValues
/* Set the folderName for logging, reports, context and data output */
let code
@@ -189,7 +188,6 @@
minimumBalanceB: 0,
maximumBalanceA: 0.002,
maximumBalanceB: 0,
timeFrame: bot.UI_CURRENT_VALUES.timeFrame,
slippage: {
positionRate: 0,
stopLoss: 0,
@@ -209,7 +207,7 @@
const ONE_YEAR_IN_MILISECONDS = 365 * 24 * 60 * 60 * 1000
switch (bot.SESSION.type) {
case 'Backtesting Session': {
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date(bot.UI_CURRENT_VALUES.initialDatetime)
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date((new Date()).valueOf() - ONE_YEAR_IN_MILISECONDS)
bot.VALUES_TO_USE.timeRange.finalDatetime = new Date()
break
}
@@ -325,10 +323,18 @@
let code = tradingSystem.parameters.timeRange.code
if (code.initialDatetime !== undefined) {
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date(code.initialDatetime)
if (isNaN(Date.parse(code.initialDatetime)) === true) {
parentLogger.write(MODULE_NAME, "[WARN] initialize -> runSession -> setValuesToUse -> Cannot use initialDatatime provided at Trading System Parameters because it is not a valid Date.");
} else {
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date(code.initialDatetime)
}
}
if (code.finalDatetime !== undefined) {
bot.VALUES_TO_USE.timeRange.finalDatetime = new Date(code.finalDatetime)
if (isNaN(Date.parse(code.finalDatetime)) === true) {
parentLogger.write(MODULE_NAME, "[WARN] initialize -> runSession -> setValuesToUse -> Cannot use finalDatetime provided at Trading System Parameters because it is not a valid Date.");
} else {
bot.VALUES_TO_USE.timeRange.finalDatetime = new Date(code.finalDatetime)
}
}
}
}
@@ -426,10 +432,18 @@
let code = bot.SESSION.parameters.timeRange.code
if (code.initialDatetime !== undefined) {
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date(code.initialDatetime)
if (isNaN(Date.parse(code.initialDatetime)) === true) {
parentLogger.write(MODULE_NAME, "[WARN] initialize -> runSession -> setValuesToUse -> Cannot use initialDatatime provided at Session Parameters because it is not a valid Date.");
} else {
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date(code.initialDatetime)
}
}
if (code.finalDatetime !== undefined) {
bot.VALUES_TO_USE.timeRange.finalDatetime = new Date(code.finalDatetime)
if (isNaN(Date.parse(code.finalDatetime)) === true) {
parentLogger.write(MODULE_NAME, "[WARN] initialize -> runSession -> setValuesToUse -> Cannot use finalDatetime provided at Session Parameters because it is not a valid Date.");
} else {
bot.VALUES_TO_USE.timeRange.finalDatetime = new Date(code.finalDatetime)
}
}
}
}