8 files changed
+418
-188
No files matched your search
+1
-1
@@ -84,7 +84,7 @@
|
||||
statusDependencies = pStatusDependencies;
|
||||
|
||||
if (bot.SESSION !== undefined) {
|
||||
sessionPath = bot.SESSION.id + "/"
|
||||
sessionPath = bot.SESSION.folderName + "/"
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+2
-2
@@ -69,7 +69,7 @@ exports.newDebugLog = function newDebugLog() {
|
||||
let filePath = thisObject.bot.filePathRoot + "/Logs/" + thisObject.bot.process + "/"
|
||||
|
||||
if (thisObject.bot.SESSION !== undefined) {
|
||||
filePath = filePath + thisObject.bot.SESSION.name + "/" + executionDatetime;
|
||||
filePath = filePath + thisObject.bot.SESSION.folderName + "/" + executionDatetime;
|
||||
} else {
|
||||
filePath = filePath + executionDatetime;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ exports.newDebugLog = function newDebugLog() {
|
||||
|
||||
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
console.log("[ERROR] DebugLog -> persist -> onInizialized -> onFileCreated -> err = "+ err.stack);
|
||||
console.log("[ERROR] DebugLog -> persist -> onInizialized -> onFileCreated -> err = "+ err.message);
|
||||
|
||||
setTimeout(writeLog, 10000); // Lets retry until we make it.
|
||||
return;
|
||||
|
||||
+35
-13
@@ -89,7 +89,7 @@
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> Entering function."); }
|
||||
|
||||
let currentTimePeriod
|
||||
let currentOutputPeriodLabel
|
||||
let currentOutputPeriodName
|
||||
|
||||
let market = global.MARKET;
|
||||
let botNeverRan = true;
|
||||
@@ -160,6 +160,17 @@
|
||||
|
||||
contextVariables.dateEndOfMarket = new Date(thisReport.lastFile.valueOf());
|
||||
|
||||
/* Validation that the data is not up-to-date. */
|
||||
|
||||
if (bot.multiPeriodProcessDatetime.valueOf() - ONE_DAY_IN_MILISECONDS > contextVariables.dateEndOfMarket.valueOf() && bot.SESSION.type !== "Backtesting Session") {
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> " + "Head of the market is @ " + contextVariables.dateEndOfMarket); }
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> You need to UPDATE your datasets in order to run a " + bot.SESSION.type) }
|
||||
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/* Finally we get our own Status Report. */
|
||||
|
||||
@@ -286,7 +297,7 @@
|
||||
|
||||
if (bot.VALUES_TO_USE.timePeriod === outputPeriodLabel) {
|
||||
currentTimePeriod = global.marketFilesPeriods[n][0];
|
||||
currentOutputPeriodLabel = global.marketFilesPeriods[n][1];
|
||||
currentOutputPeriodName = global.marketFilesPeriods[n][1];
|
||||
}
|
||||
dependencyLoopBody();
|
||||
|
||||
@@ -587,7 +598,7 @@
|
||||
|
||||
if (bot.VALUES_TO_USE.timePeriod === outputPeriodLabel) {
|
||||
currentTimePeriod = global.dailyFilePeriods[n][0];
|
||||
currentOutputPeriodLabel = global.dailyFilePeriods[n][1];
|
||||
currentOutputPeriodName = global.dailyFilePeriods[n][1];
|
||||
}
|
||||
|
||||
let dependencyIndex = 0;
|
||||
@@ -816,8 +827,12 @@
|
||||
|
||||
n = 0;
|
||||
|
||||
callTheBot();
|
||||
|
||||
if (currentTimePeriod !== undefined) {
|
||||
callTheBot();
|
||||
} else {
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriodsDailyFiles -> periodsControlLoop -> Time Period not Recognized. Can not continue." );
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
@@ -831,11 +846,11 @@
|
||||
try {
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> processTimePeriodsDailyFiles -> callTheBot -> Entering function."); }
|
||||
|
||||
|
||||
usertBot.start(
|
||||
multiPeriodDataFiles,
|
||||
currentTimePeriod,
|
||||
currentOutputPeriodLabel,
|
||||
currentOutputPeriodName,
|
||||
bot.multiPeriodProcessDatetime,
|
||||
interExecutionMemoryArray[n],
|
||||
onBotFinished);
|
||||
@@ -857,7 +872,7 @@
|
||||
writeMarketStatusReport(onMarketStatusReport)
|
||||
|
||||
} else {
|
||||
writeDataRanges(onWritten);
|
||||
writeDataRanges(currentOutputPeriodName, onWritten);
|
||||
}
|
||||
|
||||
function onWritten(err) {
|
||||
@@ -938,7 +953,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function writeDataRanges(callBack) {
|
||||
function writeDataRanges(currentOutputPeriodName, callBack) {
|
||||
|
||||
try {
|
||||
|
||||
@@ -949,9 +964,9 @@
|
||||
|
||||
function productLoopBody() {
|
||||
|
||||
let folderName = bot.products[productIndex].codeName;
|
||||
let product = bot.products[productIndex];
|
||||
|
||||
writeDataRange(contextVariables.dateBeginOfMarket, bot.multiPeriodProcessDatetime, folderName, controlLoop);
|
||||
writeDataRange(contextVariables.dateBeginOfMarket, bot.multiPeriodProcessDatetime, product, currentOutputPeriodName, controlLoop);
|
||||
}
|
||||
|
||||
function controlLoop() {
|
||||
@@ -972,7 +987,7 @@
|
||||
|
||||
}
|
||||
|
||||
function writeDataRange(pBegin, pEnd, pProductFolder, callBack) {
|
||||
function writeDataRange(pBegin, pEnd, product, currentOutputPeriodName, callBack) {
|
||||
|
||||
try {
|
||||
|
||||
@@ -986,7 +1001,7 @@
|
||||
let fileContent = JSON.stringify(dataRange);
|
||||
|
||||
let fileName = '/Data.Range.' + market.assetA + '_' + market.assetB + '.json';
|
||||
let filePath = bot.filePathRoot + "/Output/" + bot.SESSION.id + "/" + pProductFolder + "/" + 'Multi-Period-Daily' + fileName;
|
||||
let filePath = bot.filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + product.codeName + "/" + 'Multi-Period-Daily' + fileName;
|
||||
|
||||
fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
|
||||
|
||||
@@ -1004,6 +1019,13 @@
|
||||
logger.write(MODULE_NAME, "[INFO] start -> writeDataRange -> onFileCreated -> Content written = " + fileContent);
|
||||
}
|
||||
|
||||
let key = bot.devTeam + "-" + bot.codeName + "-" + product.codeName + "-" + currentOutputPeriodName
|
||||
let event = {
|
||||
dateRange: dataRange
|
||||
}
|
||||
|
||||
global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Data Range Updated', event)
|
||||
|
||||
callBack(global.DEFAULT_OK_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
+327
-167
@@ -14,10 +14,19 @@
|
||||
if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, "[INFO] initialize -> Entering function."); }
|
||||
|
||||
/* Initialize this info so that everything is logged propeerly */
|
||||
|
||||
bot.SESSION = {
|
||||
name: bot.processNode.session.name
|
||||
name: bot.processNode.session.name,
|
||||
id: bot.processNode.session.id
|
||||
}
|
||||
|
||||
/* Set the folderName for early logging */
|
||||
if (bot.processNode.session.code.folderName === undefined) {
|
||||
bot.SESSION.folderName = bot.SESSION.id
|
||||
} else {
|
||||
bot.SESSION.folderName = bot.processNode.session.code.folderName + "-" + bot.SESSION.id
|
||||
}
|
||||
|
||||
/* Check if there is a session */
|
||||
if (bot.processNode.session === undefined) {
|
||||
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> Cannot run without a Session.");
|
||||
@@ -27,17 +36,36 @@
|
||||
|
||||
/* Listen to event to start or stop the session. */
|
||||
bot.sessionKey = bot.processNode.session.name + '-' + bot.processNode.session.type + '-' + bot.processNode.session.id
|
||||
|
||||
|
||||
global.SYSTEM_EVENT_HANDLER.listenToEvent(bot.sessionKey, 'Run Session', undefined, undefined, undefined, runSession)
|
||||
global.SYSTEM_EVENT_HANDLER.listenToEvent(bot.sessionKey, 'Stop Session', undefined, undefined, undefined, stopSession)
|
||||
|
||||
function runSession(message) {
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE)
|
||||
return
|
||||
|
||||
function runSession(message) {
|
||||
|
||||
/* We are going to run the Definition comming at the event. */
|
||||
bot.DEFINITION = JSON.parse(message.event.definition)
|
||||
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
|
||||
if (bot.SESSION.code !== undefined) {
|
||||
|
||||
code = bot.SESSION.code
|
||||
if (code.folderName === undefined) {
|
||||
bot.SESSION.folderName = bot.SESSION.id
|
||||
} else {
|
||||
bot.SESSION.folderName = code.folderName + "-" + bot.SESSION.id
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up Social Bots */
|
||||
setUpSocialBots()
|
||||
|
||||
/* Extract values from different sources and consolidate them under one structure that is going to be used later on. */
|
||||
setValuesToUse(message)
|
||||
|
||||
switch (bot.SESSION.type) {
|
||||
@@ -49,6 +77,14 @@
|
||||
startLiveTrading(message)
|
||||
break
|
||||
}
|
||||
case 'Fordward Testing Session': {
|
||||
startFordwardTesting(message)
|
||||
break
|
||||
}
|
||||
case 'Paper Trading Session': {
|
||||
startPaperTrading(message)
|
||||
break
|
||||
}
|
||||
}
|
||||
bot.SESSION_STATUS = 'Idle'
|
||||
bot.STOP_SESSION = false
|
||||
@@ -60,13 +96,82 @@
|
||||
|
||||
function startBackTesting(message) {
|
||||
bot.startMode = "Backtest"
|
||||
if (bot.VALUES_TO_USE.timeRange.finalDatetime.valueOf() > (new Date()).valueOf()) {
|
||||
bot.VALUES_TO_USE.timeRange.finalDatetime = new Date()
|
||||
}
|
||||
bot.resumeExecution = false;
|
||||
bot.hasTheBotJustStarted = true
|
||||
bot.multiPeriodProcessDatetime = bot.VALUES_TO_USE.timeRange.initialDatetime
|
||||
bot.multiPeriodProcessDatetime = new Date(bot.VALUES_TO_USE.timeRange.initialDatetime.valueOf())
|
||||
}
|
||||
|
||||
function startLiveTrading(message) {
|
||||
|
||||
setKeyToUse()
|
||||
|
||||
if (process.env.KEY === undefined || process.env.SECRET === undefined) {
|
||||
if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, "[WARN] initialize -> startLiveTrading -> Key name or Secret not provided, not possible to run the process in Live mode."); }
|
||||
return
|
||||
}
|
||||
|
||||
bot.startMode = "Live"
|
||||
if (bot.VALUES_TO_USE.timeRange.initialDatetime.valueOf() < (new Date()).valueOf()) {
|
||||
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date()
|
||||
}
|
||||
bot.resumeExecution = false;
|
||||
bot.multiPeriodProcessDatetime = new Date(bot.VALUES_TO_USE.timeRange.initialDatetime.valueOf())
|
||||
bot.hasTheBotJustStarted = true
|
||||
|
||||
}
|
||||
|
||||
function startFordwardTesting(message) {
|
||||
|
||||
setKeyToUse()
|
||||
|
||||
if (process.env.KEY === undefined || process.env.SECRET === undefined) {
|
||||
if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, "[WARN] initialize -> startLiveTrading -> Key name or Secret not provided, not possible to run the process in Forward Testing mode."); }
|
||||
return
|
||||
}
|
||||
|
||||
bot.startMode = "Live"
|
||||
if (bot.VALUES_TO_USE.timeRange.initialDatetime.valueOf() < (new Date()).valueOf()) {
|
||||
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date()
|
||||
}
|
||||
bot.resumeExecution = false;
|
||||
bot.multiPeriodProcessDatetime = new Date(bot.VALUES_TO_USE.timeRange.initialDatetime.valueOf())
|
||||
bot.hasTheBotJustStarted = true
|
||||
|
||||
/* Reduce the balance */
|
||||
|
||||
let balancePercentage = 1 // This is the default value
|
||||
|
||||
if (bot.SESSION.code.balancePercentage !== undefined) {
|
||||
balancePercentage = bot.SESSION.code.balancePercentage
|
||||
}
|
||||
|
||||
bot.VALUES_TO_USE.initialBalanceA = bot.VALUES_TO_USE.initialBalanceA * balancePercentage / 100
|
||||
bot.VALUES_TO_USE.initialBalanceB = bot.VALUES_TO_USE.initialBalanceB * balancePercentage / 100
|
||||
|
||||
bot.VALUES_TO_USE.minimumBalanceA = bot.VALUES_TO_USE.minimumBalanceA * balancePercentage / 100
|
||||
bot.VALUES_TO_USE.minimumBalanceB = bot.VALUES_TO_USE.minimumBalanceB * balancePercentage / 100
|
||||
|
||||
bot.VALUES_TO_USE.maximumBalanceA = bot.VALUES_TO_USE.maximumBalanceA * balancePercentage / 100
|
||||
bot.VALUES_TO_USE.maximumBalanceB = bot.VALUES_TO_USE.maximumBalanceB * balancePercentage / 100
|
||||
}
|
||||
|
||||
function startPaperTrading(message) {
|
||||
bot.startMode = "Backtest"
|
||||
console.log("startPaperTrading")
|
||||
if (bot.VALUES_TO_USE.timeRange.initialDatetime.valueOf() < (new Date()).valueOf()) {
|
||||
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date()
|
||||
}
|
||||
bot.resumeExecution = false;
|
||||
bot.hasTheBotJustStarted = true
|
||||
bot.multiPeriodProcessDatetime = new Date(bot.VALUES_TO_USE.timeRange.initialDatetime.valueOf())
|
||||
|
||||
}
|
||||
|
||||
function setKeyToUse() {
|
||||
/* The last place where we can find a key to use is the key pool at the exchange account. */
|
||||
if (bot.DEFINITION.personalData) {
|
||||
if (bot.DEFINITION.personalData.exchangeAccounts) {
|
||||
if (bot.DEFINITION.personalData.exchangeAccounts.length > 0) {
|
||||
@@ -84,19 +189,27 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.KEY === undefined || process.env.SECRET === undefined) {
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[WARN] initialize -> startLiveTrading -> Key name or Secret not provided, not possible to run the process in Live mode."); }
|
||||
return
|
||||
/* This is the primary fallback, when there is no key defined at the parameters at the session level. */
|
||||
if (bot.DEFINITION.tradingSystem) {
|
||||
if (bot.DEFINITION.tradingSystem.parameters) {
|
||||
if (bot.DEFINITION.tradingSystem.parameters.key !== undefined) {
|
||||
let key = bot.DEFINITION.tradingSystem.parameters.key
|
||||
|
||||
process.env.KEY = key.name
|
||||
process.env.SECRET = key.code
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bot.startMode = "Live"
|
||||
if (bot.VALUES_TO_USE.timeRange.initialDatetime.valueOf() < (new Date()).valueOf) {
|
||||
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date()
|
||||
}
|
||||
bot.resumeExecution = false;
|
||||
bot.multiPeriodProcessDatetime = bot.VALUES_TO_USE.timeRange.initialDatetime
|
||||
bot.hasTheBotJustStarted = true
|
||||
/* Key defined at the parameters at the session level. */
|
||||
if (bot.SESSION.parameters) {
|
||||
if (bot.SESSION.parameters.key !== undefined) {
|
||||
let key = bot.SESSION.parameters.key
|
||||
|
||||
process.env.KEY = key.name
|
||||
process.env.SECRET = key.code
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setValuesToUse(message) {
|
||||
@@ -143,6 +256,16 @@
|
||||
bot.VALUES_TO_USE.timeRange.finalDatetime = new Date((new Date()).valueOf() + ONE_YEAR_IN_MILISECONDS)
|
||||
break
|
||||
}
|
||||
case 'Fordward Testing Session': {
|
||||
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date()
|
||||
bot.VALUES_TO_USE.timeRange.finalDatetime = new Date((new Date()).valueOf() + ONE_YEAR_IN_MILISECONDS)
|
||||
break
|
||||
}
|
||||
case 'Paper Trading Session': {
|
||||
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date()
|
||||
bot.VALUES_TO_USE.timeRange.finalDatetime = new Date((new Date()).valueOf() + ONE_YEAR_IN_MILISECONDS)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
let tradingSystem = bot.DEFINITION.tradingSystem
|
||||
@@ -155,15 +278,109 @@
|
||||
/* Base Asset and Initial Balances. */
|
||||
{
|
||||
if (tradingSystem.parameters.baseAsset !== undefined) {
|
||||
let code
|
||||
try {
|
||||
code = JSON.parse(tradingSystem.parameters.baseAsset.code);
|
||||
let code = tradingSystem.parameters.baseAsset.code
|
||||
|
||||
if (code.name !== undefined) {
|
||||
bot.VALUES_TO_USE.baseAsset = code.name;
|
||||
}
|
||||
|
||||
if (bot.VALUES_TO_USE.baseAsset === 'BTC') {
|
||||
if (code.initialBalance !== undefined) {
|
||||
bot.VALUES_TO_USE.initialBalanceA = code.initialBalance;
|
||||
bot.VALUES_TO_USE.initialBalanceB = 0
|
||||
}
|
||||
if (code.minimumBalance !== undefined) {
|
||||
bot.VALUES_TO_USE.minimumBalanceA = code.minimumBalance;
|
||||
bot.VALUES_TO_USE.minimumBalanceB = 0
|
||||
}
|
||||
if (code.maximumBalance !== undefined) {
|
||||
bot.VALUES_TO_USE.maximumBalanceA = code.maximumBalance;
|
||||
bot.VALUES_TO_USE.maximumBalanceB = 0
|
||||
}
|
||||
} else {
|
||||
if (code.initialBalance !== undefined) {
|
||||
bot.VALUES_TO_USE.initialBalanceB = code.initialBalance;
|
||||
bot.VALUES_TO_USE.initialBalanceA = 0
|
||||
}
|
||||
if (code.minimumBalance !== undefined) {
|
||||
bot.VALUES_TO_USE.minimumBalanceB = code.minimumBalance;
|
||||
bot.VALUES_TO_USE.minimumBalanceA = 0
|
||||
}
|
||||
if (code.maximumBalance !== undefined) {
|
||||
bot.VALUES_TO_USE.maximumBalanceB = code.maximumBalance;
|
||||
bot.VALUES_TO_USE.maximumBalanceA = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Time Period */
|
||||
if (tradingSystem.parameters.timePeriod !== undefined) {
|
||||
bot.VALUES_TO_USE.timePeriod = tradingSystem.parameters.timePeriod.code
|
||||
}
|
||||
|
||||
/* Slippage */
|
||||
if (tradingSystem.parameters.slippage !== undefined) {
|
||||
if (tradingSystem.parameters.slippage.code !== undefined) {
|
||||
|
||||
let code = tradingSystem.parameters.slippage.code
|
||||
|
||||
if (code.positionRate !== undefined) {
|
||||
bot.VALUES_TO_USE.slippage.positionRate = code.positionRate
|
||||
}
|
||||
if (code.stopLoss !== undefined) {
|
||||
bot.VALUES_TO_USE.slippage.stopLoss = code.stopLoss
|
||||
}
|
||||
if (code.takeProfit !== undefined) {
|
||||
bot.VALUES_TO_USE.slippage.takeProfit = code.takeProfit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fee Structure */
|
||||
if (tradingSystem.parameters.feeStructure !== undefined) {
|
||||
if (tradingSystem.parameters.feeStructure.code !== undefined) {
|
||||
|
||||
let code = tradingSystem.parameters.feeStructure.code
|
||||
|
||||
if (code.maker !== undefined) {
|
||||
bot.VALUES_TO_USE.feeStructure.maker = code.maker
|
||||
}
|
||||
if (code.taker !== undefined) {
|
||||
bot.VALUES_TO_USE.feeStructure.taker = code.taker
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Time Range */
|
||||
if (tradingSystem.parameters.timeRange !== undefined) {
|
||||
if (tradingSystem.parameters.timeRange.code !== undefined) {
|
||||
|
||||
let code = tradingSystem.parameters.timeRange.code
|
||||
if (code.initialDatetime !== undefined) {
|
||||
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date(code.initialDatetime)
|
||||
}
|
||||
if (code.finalDatetime !== undefined) {
|
||||
bot.VALUES_TO_USE.timeRange.finalDatetime = new Date(code.finalDatetime)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Applying Session Level Parameters */
|
||||
if (bot.SESSION !== undefined) {
|
||||
if (bot.SESSION.parameters !== undefined) {
|
||||
|
||||
/* Base Asset and Initial Balances. */
|
||||
{
|
||||
if (bot.SESSION.parameters.baseAsset !== undefined) {
|
||||
let code = bot.SESSION.parameters.baseAsset.code
|
||||
|
||||
if (code.name !== undefined) {
|
||||
bot.VALUES_TO_USE.baseAsset = code.name;
|
||||
}
|
||||
|
||||
if (bot.VALUES_TO_USE.baseAsset === 'BTC') {
|
||||
if (bot.VALUES_TO_USE.baseAsset === 'BTC') {
|
||||
if (code.initialBalance !== undefined) {
|
||||
bot.VALUES_TO_USE.initialBalanceA = code.initialBalance;
|
||||
bot.VALUES_TO_USE.initialBalanceB = 0
|
||||
@@ -190,121 +407,6 @@
|
||||
bot.VALUES_TO_USE.maximumBalanceA = 0
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
tradingSystem.parameters.baseAsset.error = err.message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Time Period */
|
||||
if (tradingSystem.parameters.timePeriod !== undefined) {
|
||||
bot.VALUES_TO_USE.timePeriod = tradingSystem.parameters.timePeriod.code
|
||||
}
|
||||
|
||||
/* Slippage */
|
||||
if (tradingSystem.parameters.slippage !== undefined) {
|
||||
if (tradingSystem.parameters.slippage.code !== undefined) {
|
||||
try {
|
||||
let code = JSON.parse(tradingSystem.parameters.slippage.code)
|
||||
|
||||
if (code.positionRate !== undefined) {
|
||||
bot.VALUES_TO_USE.slippage.positionRate = code.positionRate
|
||||
}
|
||||
if (code.stopLoss !== undefined) {
|
||||
bot.VALUES_TO_USE.slippage.stopLoss = code.stopLoss
|
||||
}
|
||||
if (code.takeProfit !== undefined) {
|
||||
bot.VALUES_TO_USE.slippage.takeProfit = code.takeProfit
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
tradingSystem.parameters.slippage.error = err.message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fee Structure */
|
||||
if (tradingSystem.parameters.feeStructure !== undefined) {
|
||||
if (tradingSystem.parameters.feeStructure.code !== undefined) {
|
||||
try {
|
||||
let code = JSON.parse(tradingSystem.parameters.feeStructure.code)
|
||||
|
||||
if (code.maker !== undefined) {
|
||||
bot.VALUES_TO_USE.feeStructure.maker = code.maker
|
||||
}
|
||||
if (code.taker !== undefined) {
|
||||
bot.VALUES_TO_USE.feeStructure.taker = code.taker
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
tradingSystem.parameters.feeStructure.error = err.message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Time Range */
|
||||
if (tradingSystem.parameters.timeRange !== undefined) {
|
||||
if (tradingSystem.parameters.timeRange.code !== undefined) {
|
||||
try {
|
||||
let code = JSON.parse(tradingSystem.parameters.timeRange.code)
|
||||
if (code.initialDatetime !== undefined) {
|
||||
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date(code.initialDatetime)
|
||||
}
|
||||
if (code.finalDatetime !== undefined) {
|
||||
bot.VALUES_TO_USE.timeRange.finalDatetime = new Date(code.finalDatetime)
|
||||
}
|
||||
} catch (err) {
|
||||
tradingSystem.parameters.timeRange.error = err.message
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Applying Session Level Parameters */
|
||||
if (bot.SESSION !== undefined) {
|
||||
if (bot.SESSION.parameters !== undefined) {
|
||||
|
||||
/* Base Asset and Initial Balances. */
|
||||
{
|
||||
if (bot.SESSION.parameters.baseAsset !== undefined) {
|
||||
let code
|
||||
try {
|
||||
code = JSON.parse(bot.SESSION.parameters.baseAsset.code);
|
||||
|
||||
if (code.name !== undefined) {
|
||||
bot.VALUES_TO_USE.baseAsset = code.name;
|
||||
}
|
||||
|
||||
if (bot.VALUES_TO_USE.baseAsset === 'BTC') {
|
||||
if (code.initialBalance !== undefined) {
|
||||
bot.VALUES_TO_USE.initialBalanceA = code.initialBalance;
|
||||
bot.VALUES_TO_USE.initialBalanceB = 0
|
||||
}
|
||||
if (code.minimumBalance !== undefined) {
|
||||
bot.VALUES_TO_USE.minimumBalanceA = code.minimumBalance;
|
||||
bot.VALUES_TO_USE.minimumBalanceB = 0
|
||||
}
|
||||
if (code.maximumBalance !== undefined) {
|
||||
bot.VALUES_TO_USE.maximumBalanceA = code.maximumBalance;
|
||||
bot.VALUES_TO_USE.maximumBalanceB = 0
|
||||
}
|
||||
} else {
|
||||
if (code.initialBalance !== undefined) {
|
||||
bot.VALUES_TO_USE.initialBalanceB = code.initialBalance;
|
||||
bot.VALUES_TO_USE.initialBalanceA = 0
|
||||
}
|
||||
if (code.minimumBalance !== undefined) {
|
||||
bot.VALUES_TO_USE.minimumBalanceB = code.minimumBalance;
|
||||
bot.VALUES_TO_USE.minimumBalanceA = 0
|
||||
}
|
||||
if (code.maximumBalance !== undefined) {
|
||||
bot.VALUES_TO_USE.maximumBalanceB = code.maximumBalance;
|
||||
bot.VALUES_TO_USE.maximumBalanceA = 0
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
parentLogger.write(MODULE_NAME, "[WARN] initialize -> startLiveTrading -> Invalid Base Asset Value -> err = " + err.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,21 +418,17 @@
|
||||
/* Slippage */
|
||||
if (bot.SESSION.parameters.slippage !== undefined) {
|
||||
if (bot.SESSION.parameters.slippage.code !== undefined) {
|
||||
try {
|
||||
let code = JSON.parse(bot.SESSION.parameters.slippage.code)
|
||||
|
||||
if (code.positionRate !== undefined) {
|
||||
bot.VALUES_TO_USE.slippage.positionRate = code.positionRate
|
||||
}
|
||||
if (code.stopLoss !== undefined) {
|
||||
bot.VALUES_TO_USE.slippage.stopLoss = code.stopLoss
|
||||
}
|
||||
if (code.takeProfit !== undefined) {
|
||||
bot.VALUES_TO_USE.slippage.takeProfit = code.takeProfit
|
||||
}
|
||||
let code = bot.SESSION.parameters.slippage.code
|
||||
|
||||
} catch (err) {
|
||||
parentLogger.write(MODULE_NAME, "[WARN] initialize -> startLiveTrading -> Invalid Slippage Value -> err = " + err.stack);
|
||||
if (code.positionRate !== undefined) {
|
||||
bot.VALUES_TO_USE.slippage.positionRate = code.positionRate
|
||||
}
|
||||
if (code.stopLoss !== undefined) {
|
||||
bot.VALUES_TO_USE.slippage.stopLoss = code.stopLoss
|
||||
}
|
||||
if (code.takeProfit !== undefined) {
|
||||
bot.VALUES_TO_USE.slippage.takeProfit = code.takeProfit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -338,18 +436,14 @@
|
||||
/* Fee Structure */
|
||||
if (bot.SESSION.parameters.feeStructure !== undefined) {
|
||||
if (bot.SESSION.parameters.feeStructure.code !== undefined) {
|
||||
try {
|
||||
let code = JSON.parse(bot.SESSION.parameters.feeStructure.code)
|
||||
|
||||
if (code.maker !== undefined) {
|
||||
bot.VALUES_TO_USE.feeStructure.maker = code.maker
|
||||
}
|
||||
if (code.taker !== undefined) {
|
||||
bot.VALUES_TO_USE.feeStructure.taker = code.taker
|
||||
}
|
||||
let code = bot.SESSION.parameters.feeStructure.code
|
||||
|
||||
} catch (err) {
|
||||
parentLogger.write(MODULE_NAME, "[WARN] initialize -> startLiveTrading -> Invalid Fee Structure Value -> err = " + err.stack);
|
||||
if (code.maker !== undefined) {
|
||||
bot.VALUES_TO_USE.feeStructure.maker = code.maker
|
||||
}
|
||||
if (code.taker !== undefined) {
|
||||
bot.VALUES_TO_USE.feeStructure.taker = code.taker
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -357,16 +451,13 @@
|
||||
/* Time Range */
|
||||
if (bot.SESSION.parameters.timeRange !== undefined) {
|
||||
if (bot.SESSION.parameters.timeRange.code !== undefined) {
|
||||
try {
|
||||
let code = JSON.parse(bot.SESSION.parameters.timeRange.code)
|
||||
if (code.initialDatetime !== undefined) {
|
||||
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date(code.initialDatetime)
|
||||
}
|
||||
if (code.finalDatetime !== undefined) {
|
||||
bot.VALUES_TO_USE.timeRange.finalDatetime = new Date(code.finalDatetime)
|
||||
}
|
||||
} catch (err) {
|
||||
parentLogger.write(MODULE_NAME, "[WARN] initialize -> startLiveTrading -> Invalid Time Range Value -> err = " + err.stack);
|
||||
|
||||
let code = bot.SESSION.parameters.timeRange.code
|
||||
if (code.initialDatetime !== undefined) {
|
||||
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date(code.initialDatetime)
|
||||
}
|
||||
if (code.finalDatetime !== undefined) {
|
||||
bot.VALUES_TO_USE.timeRange.finalDatetime = new Date(code.finalDatetime)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -375,7 +466,76 @@
|
||||
}
|
||||
}
|
||||
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE)
|
||||
function setUpSocialBots() {
|
||||
|
||||
if (bot.SESSION.socialBots !== undefined) {
|
||||
if (bot.SESSION.socialBots.bots !== undefined) {
|
||||
for (let i = 0; i < bot.SESSION.socialBots.bots.length; i++) {
|
||||
let socialBot = bot.SESSION.socialBots.bots[i]
|
||||
if (socialBot.type === "Telegram Bot") {
|
||||
let code = socialBot.code
|
||||
socialBot.botInstance = setUpTelegramBot(code.botToken, code.chatId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function announce(announcement) {
|
||||
if (bot.SESSION.socialBots.bots !== undefined) {
|
||||
for (let i = 0; i < bot.SESSION.socialBots.bots.length; i++) {
|
||||
let socialBot = bot.SESSION.socialBots.bots[i]
|
||||
try {
|
||||
let code = JSON.parse(announcement.code)
|
||||
if (code.botId === undefined) {
|
||||
code.botId = socialBot.id
|
||||
}
|
||||
if (socialBot.type === code.botType && socialBot.id === code.botId) {
|
||||
if (socialBot.type === "Telegram Bot") {
|
||||
if (announcement.formulaValue !== undefined) {
|
||||
socialBot.botInstance.telegramAPI.sendMessage(socialBot.botInstance.chatId, announcement.formulaValue)
|
||||
} else {
|
||||
socialBot.botInstance.telegramAPI.sendMessage(socialBot.botInstance.chatId, code.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
parentLogger.write(MODULE_NAME, "[WARN] initialize -> setUpSocialBots -> announce -> err = " + err.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bot.SESSION.socialBots.announce = announce
|
||||
}
|
||||
}
|
||||
|
||||
function setUpTelegramBot(botToken, chatId) {
|
||||
/* Telegram Bot Initialization */
|
||||
try {
|
||||
const Telegraf = require('telegraf')
|
||||
let telegramBot
|
||||
telegramBot = new Telegraf(botToken)
|
||||
telegramBot.start((ctx) => ctx.reply('Hi! I am a Telegram Bot powered by Superalgos'))
|
||||
telegramBot.help((ctx) => ctx.reply('Send me a sticker'))
|
||||
telegramBot.on('sticker', (ctx) => ctx.reply('??'))
|
||||
telegramBot.hears('hi', (ctx) => ctx.reply('Hey there'))
|
||||
telegramBot.launch()
|
||||
|
||||
const Telegram = require('telegraf/telegram')
|
||||
let telegramAPI
|
||||
telegramAPI = new Telegram(botToken)
|
||||
telegramAPI.sendMessage(chatId, bot.SESSION.type + " '" + bot.SESSION.name + "' was Started.")
|
||||
|
||||
let botInstance = {
|
||||
telegramBot: telegramBot,
|
||||
telegramAPI: telegramAPI,
|
||||
chatId: chatId
|
||||
}
|
||||
return botInstance
|
||||
} catch (err) {
|
||||
parentLogger.write(MODULE_NAME, "[WARN] initialize -> setUpTelegramBot -> err = " + err.stack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack);
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@
|
||||
year = pYear;
|
||||
|
||||
if (bot.SESSION !== undefined && pOwner.type === "Trading Engine") {
|
||||
sessionPath = bot.SESSION.id + "/"
|
||||
sessionPath = bot.SESSION.folderName + "/"
|
||||
}
|
||||
|
||||
if (owner.dataSetSection === "Month") {
|
||||
|
||||
Generated
+47
@@ -24,6 +24,11 @@
|
||||
"resolved": "https://registry.npmjs.org/@superalgos/mqservice/-/mqservice-0.0.17.tgz",
|
||||
"integrity": "sha512-mxg2AtfFJ78n/p+JK/o6nTrnR+ZPlBNcq7k+6Epnl1t63ldrcm98WOgIQZaNezPPf0E7gSjVX3p+uZO1Ass0kA=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "12.7.12",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.12.tgz",
|
||||
"integrity": "sha512-KPYGmfD0/b1eXurQ59fXD1GBzhSQfz6/lKBxkaHX9dKTzjXbK68Zt7yGUxUsCS1jeTy/8aL+d9JEr+S54mpkWQ=="
|
||||
},
|
||||
"ajv": {
|
||||
"version": "6.10.2",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz",
|
||||
@@ -458,6 +463,11 @@
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
|
||||
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
|
||||
},
|
||||
"node-ipc": {
|
||||
"version": "9.1.1",
|
||||
"resolved": "https://registry.npmjs.org/node-ipc/-/node-ipc-9.1.1.tgz",
|
||||
@@ -572,6 +582,11 @@
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"sandwich-stream": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/sandwich-stream/-/sandwich-stream-2.0.2.tgz",
|
||||
"integrity": "sha512-jLYV0DORrzY3xaz/S9ydJL6Iz7essZeAfnAavsJ+zsJGZ1MOnsS52yRjU3uF3pJa/lla7+wisp//fxOwOH8SKQ=="
|
||||
},
|
||||
"semver": {
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||
@@ -652,6 +667,38 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"telegraf": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/telegraf/-/telegraf-3.32.0.tgz",
|
||||
"integrity": "sha512-5ZHiovyuG1rVLygJjaqf57wDt8e1nijAinKXCxN1tyUZ4BcrkZW/z5rVTEXA+KegpFbWxKKv3KnJwUJrKDqD0Q==",
|
||||
"requires": {
|
||||
"@types/node": "12.7.12",
|
||||
"debug": "4.1.1",
|
||||
"node-fetch": "2.6.0",
|
||||
"sandwich-stream": "2.0.2",
|
||||
"telegram-typings": "3.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||
"requires": {
|
||||
"ms": "2.1.2"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"telegram-typings": {
|
||||
"version": "3.6.1",
|
||||
"resolved": "https://registry.npmjs.org/telegram-typings/-/telegram-typings-3.6.1.tgz",
|
||||
"integrity": "sha512-njVv1EAhIZnmQVLocZEADYUyqA1WIXuVcDYlsp+mXua/XB0pxx+PKtMSPeZ/EE4wPWTw9h/hA9ASTT6yQelkiw=="
|
||||
},
|
||||
"text-hex": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"axios": "^0.19.0",
|
||||
"dotenv": "^8.0.0",
|
||||
"node-ipc": "^9.1.1",
|
||||
"telegraf": "^3.32.0",
|
||||
"winston": "^3.2.1"
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ if (global.TASK_NODE !== undefined) {
|
||||
|
||||
}
|
||||
else { // I use this section to debug in standalone mode.
|
||||
let argument = '{"type":"Task","name":"Runs Backtests","bot":{"type":"Trading Engine","code":{"team":"AAMasters","bot":"AAJason","repo":"AAJason-Trading-Engine-Bot"},"processes":[{"type":"Process","subType":"Trading Engine Process","name":"Multi Period","code":{"process":"Multi-Period"},"session":{"type":"Backtesting Session","name":"10 Minutes","id":"121202ea-6735-4bf3-8a95-aaa55f00f6e7"},"id":"3f483482-d8a1-4755-ba50-7cac6296fa5f"}],"id":"25fe9099-b53d-4757-8a63-3f8a15875f33"},"id":"5b21d2d2-0f52-4408-83eb-ddaa844ec58c"}'
|
||||
let argument = '{"type":"Task","name":"Runs Backtests","bot":{"type":"Trading Engine","code":{"team":"AAMasters","bot":"AAJason","repo":"AAJason-Trading-Engine-Bot"},"processes":[{"type":"Process","subType":"Trading Engine Process","name":"Multi Period","code":{"process":"Multi-Period"},"session":{"type":"Backtesting Session","name":"Backtest 01","code":{"folderName":"Backtest-01"},"parameters":{"type":"Parameters","name":"Parameters","baseAsset":{"type":"Base Asset","name":"Base Asset","code":{"name":"BTC","initialBalance":0.001,"minimumBalance":0.0001,"maximumBalance":1},"id":"666f6f10-2f17-4f5e-951c-b532bdb574d2"},"timeRange":{"type":"Time Range","name":"Time Range","code":{"initialDatetime":"2019-09-24T00:00:00.000Z","finalDatetime":"2019-09-27T00:00:00.000Z"},"id":"172958dd-b268-4444-8163-70979538ea6e"},"timePeriod":{"type":"Time Period","name":"Time Period","code":"10-min","id":"37ee839d-9a7c-410c-9251-c33b8f1b99f7"},"slippage":{"type":"Slippage","name":"Slippage","code":{"positionRate":0.1,"stopLoss":0.1,"takeProfit":0.1},"id":"86ebd973-6ad9-4070-aece-a87623f24c2e"},"feeStructure":{"type":"Fee Structure","name":"Fee Structure","code":{"maker":0.15,"taker":0.25},"id":"a0ec3f6f-6047-4740-87fe-393b1c714adb"},"key":{"type":"Exchange Account Key","name":"New Key","code":"Paste your exchange API secret key here and the put the key name as this key object title. Secret keys are filtered out and NOT exported when using the SHARE menu option on any object at your workspace. Secret keys ARE downloaded when using the download button.","id":"368f879d-e363-47c7-b55e-7b927d896b20"},"id":"09db5e1e-a7e8-468c-ad70-0d2ab1c8b8b8"},"layerManager":{"type":"Layer Manager","name":"New Layer Manager","layers":[{"type":"Layer","name":"Live","code":{"product":"Live-Trading-History"},"id":"0ec05e1c-230b-44a1-9f2c-fba0ea2ff9e2"},{"type":"Layer","name":"Trades","code":{"product":"Simulation-Trades"},"id":"6326e03a-96c0-4d21-b877-f2c6a0419fc5"},{"type":"Layer","name":"Strategies","code":{"product":"Simulation-Strategies"},"id":"bda1e06c-e569-4bd5-95fb-90154aafb003"},{"type":"Layer","name":"Simulation","code":{"product":"Trading-Simulation"},"id":"d58d8cd2-f125-4f0c-b241-08e2af8ac4be"},{"type":"Layer","name":"Formulas & Conditions","code":{"product":"Simulation-Conditions"},"id":"15dfeca0-acd9-40d3-afe0-4805654bf0d0"}],"id":"884c4dd7-4beb-43fb-bda5-d6097d58ae09"},"socialBots":{"type":"Social Bots","name":"New Social Bots","bots":[],"id":"281eb022-cf9f-4ac2-978b-c8358bee8fec"},"id":"121202ea-6735-4bf3-8a95-aaa55f00f6e7"},"id":"3f483482-d8a1-4755-ba50-7cac6296fa5f"}],"id":"25fe9099-b53d-4757-8a63-3f8a15875f33"},"id":"5b21d2d2-0f52-4408-83eb-ddaa844ec58c"}'
|
||||
/* charly argument = '{"type":"Task","name":"Brings Trades Records from the Exchange","bot":{"type":"Sensor","name":"Charly","processes":[{"type":"Process","name":"Live Trades","code":{"team":"AAMasters","bot":"AACharly","process":"Live-Trades"},"id":"5846ebc7-1979-4a80-9cc7-94bb4b8659dc"},{"type":"Process","name":"Hole Fixing","code":{"team":"AAMasters","bot":"AACharly","process":"Hole-Fixing"},"id":"31fc4f05-75d4-419a-9fb0-73e25e856f15"}]},"id":"5bfef4dc-54c1-44db-ace6-1ab27a86746e"}'
|
||||
// olivia argument = '{"type":"Task","name":"Generates 1 min to 24 hs Candles & Volumes","bot":{"type":"Indicator","name":"Olivia","processes":[{"type":"Process","name":"Daily","code":{"team":"AAMasters","bot":"AAOlivia","process":"Multi-Period-Daily"},"id":"68cc8e1b-e94a-477e-82d0-15ecc9f1b9e2"},{"type":"Process","name":"Market","code":{"team":"AAMasters","bot":"AAOlivia","process":"Multi-Period-Market"},"id":"e1ac5e3d-d491-4e90-baf4-d4e5b71a8b1a"}]},"id":"efe36e05-75ea-41b5-8d92-c6b27635c834"}'
|
||||
// bruce argument = ' {"type":"Task","name":"Converts Trades into 1 min Candles & Volumes","bot":{"type":"Indicator","name":"Bruce","processes":[{"type":"Process","name":"New Process","code":{"team":"AAMasters","bot":"AABruce","process":"Single-Period-Daily"},"id":"e184744f-5de0-41c1-ad4c-36960f4ced90"}]},"id":"42758590-a7bd-4712-a5c9-80a3a820c5b3"}'
|
||||
@@ -112,7 +112,7 @@ process.on('message', message => {
|
||||
There are some process that might no be able to end grafully, for example the ones schedulle to process information in a future day or month.
|
||||
In order to be sure that the process will be terminated, we schedulle one forced exit in 2 minutes from now.
|
||||
*/
|
||||
console.log('[INFO] Task Server -> server -> process.on -> Executing order received from Task Manager to Stop this Task. Nodejs process will be exited in less than 1 minutes.')
|
||||
console.log('[INFO] Task Server -> server -> process.on -> Executing order received from Task Manager to Stop this Task. Nodejs process will be exited in less than 1 minute.')
|
||||
setTimeout(global.EXIT_NODE_PROCESS, 60000);
|
||||
}
|
||||
});
|
||||
@@ -166,7 +166,7 @@ function bootLoader() {
|
||||
let event = {
|
||||
seconds: (new Date()).getSeconds()
|
||||
}
|
||||
global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Heartbeat', event)
|
||||
global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Heartbeat', event)
|
||||
}
|
||||
|
||||
for (let processIndex = 0; processIndex < global.TASK_NODE.bot.processes.length; processIndex++) {
|
||||
@@ -185,7 +185,7 @@ function bootLoader() {
|
||||
}
|
||||
|
||||
if (global.TASK_NODE.bot.processes[processIndex].code.process === undefined) {
|
||||
console.log("[INFO] Task Server -> server -> bootLoader -> Parameter 'process' is undefined. This process will not be executed. -> Process = " + global.TASK_NODE.bot.processes[processIndex].name);
|
||||
console.log("[INFO] Task Server -> server -> bootLoader -> Parameter 'process' at object Process is undefined. This process will not be executed. -> Process = " + global.TASK_NODE.bot.processes[processIndex].name);
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user