Trading Mine implementation

This commit is contained in:
Luis Fernando Molina committed 2020-09-13 20:06:12 +02:00
1 parent d62169462f
commit 79c2e0eadd
28 files changed
+1563 -384

No files matched your search

+1
View File
@@ -14,6 +14,7 @@ INTER_PROCESS_FILES_PATH=./Inter-Process-Files
STORAGE_PATH=./Data-Storage
PLOTTERS_PATH=./Legacy-Code
DATA_MINES_PATH=./Data-Mines
TRADING_MINES_PATH=./Trading-Mines
TRADING_SYSTEMS_PATH=./Trading-Systems
SUPER_SCRIPTS_PATH=./Super-Scripts
TRADING_ENGINES_PATH=./Trading-Engines
+643 -142
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -71,6 +71,7 @@ function newAppLoader() {
'Utilities/Folders.js',
'Utilities/Branches.js',
'Utilities/Meshes.js',
'Utilities/NodeChildren.js',
'Panels/LayersPanel.js',
'Panels/UpDownButton.js',
Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

+12 -1
View File
@@ -460,6 +460,7 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
let folder
let includedNames = {
includedDataMines: [],
includedTradingMines: [],
includedTradingSystems: [],
includedSuperScripts: [],
includedTradingEngines: []
@@ -477,7 +478,11 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
folder = process.env.TRADING_ENGINES_PATH + '/'
fs.readdir(folder, (err, files) => {
includedNames.includedTradingEngines = files
respondWithContent(JSON.stringify(includedNames), response)
folder = process.env.TRADING_MINES_PATH + '/'
fs.readdir(folder, (err, files) => {
includedNames.includedTradingMines = files
respondWithContent(JSON.stringify(includedNames), response)
})
})
})
})
@@ -610,6 +615,12 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
}
break
case 'TradingMines':
{
respondWithFile(process.env.TRADING_MINES_PATH + '/' + requestParameters[2], response)
}
break
case 'TradingSystems':
{
respondWithFile(process.env.TRADING_SYSTEMS_PATH + '/' + requestParameters[2], response)
+5 -2
View File
@@ -144,11 +144,14 @@ function newPlottersManager() {
A layer can be referencing a Data Product in two different branches of the Network hiriatchy.
In one of those braches we can get the Session node, at the other we Cannot.
*/
let sessionReference = findNodeInNodeMesh(layer.definition, 'Session Reference')
let sessionReference = findNodeInNodeMesh(layer.definition, 'Session Reference', false, true, true, true)
if (sessionReference !== undefined) {
session = sessionReference.referenceParent
if (session === undefined) {
logger.write('[ERROR] initializePlotter -> Sessioin is Undefined at Session Reference -> Plotter will not be loaded. ')
return
}
/* From the session we might be able to reach the Trading System or the Trading Engine */
if (session.tradingSystemReference !== undefined) {
tradingSystem = session.tradingSystemReference.referenceParent
@@ -1,7 +1,9 @@
function newDataStorageFunctions() {
thisObject = {
addAllDataProducts: addAllDataProducts,
addAllDataMineProducts: addAllDataMineProducts
addAllDataMineProducts: addAllDataMineProducts,
addAllTradingMineProducts: addAllTradingMineProducts,
addMissingSessionReferences: addMissingSessionReferences
}
return thisObject
@@ -26,12 +28,14 @@ function newDataStorageFunctions() {
we will create a Data Product. In case we find Product Definition Folders, we will recreate that structure
too, using in this case Data Product Folders.
*/
let dataMine = node.payload.referenceParent
scanBotArray(dataMine.sensorBots)
scanBotArray(dataMine.indicatorBots)
scanBotArray(dataMine.tradingBots)
let mine = node.payload.referenceParent
scanBotArray(mine.sensorBots)
scanBotArray(mine.indicatorBots)
scanBotArray(mine.tradingBots)
function scanBotArray(botArray) {
if (botArray === undefined) {return}
for (let i = 0; i < botArray.length; i++) {
let bot = botArray[i]
let botProducts = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Bot Products')
@@ -55,11 +59,53 @@ function newDataStorageFunctions() {
function addAllDataMineProducts(node, rootNodes, functionLibraryUiObjectsFromNodes) {
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === 'Data Mine') {
let dataMineProducts = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Data Mine Products')
dataMineProducts.payload.referenceParent = rootNode
}
}
}
function addAllTradingMineProducts(node, rootNodes, functionLibraryUiObjectsFromNodes) {
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === 'Trading Mine') {
let tradingMineProducts = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Trading Mine Products')
tradingMineProducts.payload.referenceParent = rootNode
}
}
}
function addMissingSessionReferences(node, rootNodes, functionLibraryUiObjectsFromNodes) {
let networkNode = findNodeInNodeMesh(node, 'Network Node', true, false, true, false)
if (networkNode === undefined) {return}
let backtestingSessionsArray = nodeBranchToArray(networkNode, 'Backtesting Session')
let fordwardTestingSessionsArray = nodeBranchToArray(networkNode, 'Fordward Testing Session')
let paperTradingSessionsArray = nodeBranchToArray(networkNode, 'Paper Trading Session')
let liveTradingSessionsArray = nodeBranchToArray(networkNode, 'Live Trading Session')
addMissingSession(backtestingSessionsArray)
addMissingSession(fordwardTestingSessionsArray)
addMissingSession(paperTradingSessionsArray)
addMissingSession(liveTradingSessionsArray)
function addMissingSession(sessionsArray) {
for (let i = 0; i < sessionsArray.length; i++) {
let session = sessionsArray[i]
if (isMissingChildren(node, session, true) === true) {
let sessionReference = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Session Reference')
sessionReference.payload.referenceParent = session
/*
Now I will connect the Session Reference child that is auto created with the market
where the Session was found.
*/
let marketTradingTasks = findNodeInNodeMesh(session, 'Market Trading Tasks', true, false, true, false)
sessionReference.singleMarketTradingData.payload.referenceParent = marketTradingTasks.payload.referenceParent
}
}
}
}
}
@@ -7,12 +7,13 @@ function newSessionFunctions() {
return thisObject
function runSession(node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, resume, callBackFunction) {
if (validations(node) !== true) {
let networkNode = validations(node)
if (networkNode === undefined) {
/* This means that the validations failed. */
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
let networkNode = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode
let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id)
node.payload.uiObject.run(eventsServerClient, callBackFunction)
@@ -113,12 +114,13 @@ function newSessionFunctions() {
}
function stopSession(node, functionLibraryProtocolNode, callBackFunction) {
if (validations(node) !== true) {
let networkNode = validations(node)
if (networkNode === undefined) {
/* This means that the validations failed. */
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
let networkNode = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode
let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id)
let key = node.name + '-' + node.type + '-' + node.id
@@ -148,21 +150,35 @@ function newSessionFunctions() {
return
}
if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
let taskManager = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode
if (taskManager.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs to be inside Mine Tasks.')
return
}
if (taskManager.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs to be inside Market Tasks.')
return
}
if (taskManager.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs to be inside Exchange Tasks.')
return
}
if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
if (taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs to be inside a Testing or Production Environment.')
return
}
if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
if (taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs to be inside a Network Node.')
return
}
let networkNode = taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode
if (node.payload.parentNode.payload.uiObject.isRunning !== true) {
node.payload.uiObject.setErrorMessage('Session needs a Process Instance parent to be running.')
return
@@ -187,6 +203,6 @@ function newSessionFunctions() {
node.payload.uiObject.setErrorMessage('Trading Engine Reference needs to reference a Trading Engine.')
return
}
return true
return networkNode
}
}
@@ -6,19 +6,42 @@ function newTaskFunctions() {
stopAllTasks: stopAllTasks,
runAllTaskManagers: runAllTaskManagers,
stopAllTaskManagers: stopAllTaskManagers,
runAllExchangeTasks: runAllExchangeTasks,
stopAllExchangeTasks: stopAllExchangeTasks
runAllExchangeDataTasks: runAllExchangeDataTasks,
stopAllExchangeDataTasks: stopAllExchangeDataTasks,
runAllExchangeTradingTasks: runAllExchangeTradingTasks,
stopAllExchangeTradingTasks: stopAllExchangeTradingTasks,
runAllMarketDataTasks: runAllMarketDataTasks,
stopAllMarketDataTasks: stopAllMarketDataTasks,
runAllMarketTradingTasks: runAllMarketTradingTasks,
stopAllMarketTradingTasks: stopAllMarketTradingTasks,
runAllDataMineTasks: runAllDataMineTasks,
stopAllDataMineTasks: stopAllDataMineTasks,
runAllTradingMineTasks: runAllTradingMineTasks,
stopAllTradingMineTasks: stopAllTradingMineTasks,
addMissingExchangeDataTasks: addMissingExchangeDataTasks,
addMissingMarketDataTasks: addMissingMarketDataTasks,
addMissingDataMineTasks: addMissingDataMineTasks,
addMissingExchangeTradingTasks: addMissingExchangeTradingTasks,
addMissingMarketTradingTasks: addMissingMarketTradingTasks,
addMissingTradingMineTasks: addMissingTradingMineTasks,
addAllTasks: addAllTasks
}
return thisObject
function runTask(node, functionLibraryProtocolNode, isDebugging, callBackFunction) {
if (validations(node) !== true) {
let networkNode = validations(node)
if (networkNode === undefined) {
/* This means that the validations failed. */
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
let networkNode = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode
let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id)
for (let i = 0; i < node.bot.processes.length; i++) {
@@ -31,8 +54,12 @@ function newTaskFunctions() {
'Indicator Bot Instance->Time Frames Filter->' +
'Trading Bot Instance->' +
'Sensor Process Instance->Indicator Process Instance->Trading Process Instance->' +
'Market Reference->Execution Started Event->' +
'Execution Started Event->' +
'Key Reference->Exchange Account Key->' +
'Task Manager->' +
'Data Mine Tasks->Trading Mine Tasks->' +
'Market Data Tasks->Market Trading Tasks->' +
'Exchange Data Tasks->Exchange Trading Tasks->' +
'Market->Exchange Markets->Crypto Exchange->' +
'Market Base Asset->Market Quoted Asset->Asset->' +
'Backtesting Session->Live Trading Session->Paper Trading Session->Fordward Testing Session->' +
@@ -42,8 +69,8 @@ function newTaskFunctions() {
'Output Dataset->Dataset Definition->Product Definition->' +
'Process Dependencies->' +
'Status Dependency->Status Report->Process Definition->' +
'Data Mine Data Dependencies->Bot Data Dependencies->' +
'Data Dependency Folder->Data Dependency Folder->Data Dependency Folder->Data Dependency Folder->Data Dependency Folder->' +
'Data Mine Data Dependencies->Bot Data Dependencies->' +
'Data Dependency Folder->Data Dependency Folder->Data Dependency Folder->Data Dependency Folder->Data Dependency Folder->' +
'Data Dependency->Dataset Definition->Product Definition->' +
'Record Definition->Record Property->Formula->' +
'Data Building Procedure->' +
@@ -56,10 +83,10 @@ function newTaskFunctions() {
'Execution Finished Event->' +
'Execution Started Event->Execution Finished Event->Process Definition->' +
'Sensor Bot->' +
'Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->' +
'Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->' +
'Indicator Bot->' +
'Trading Bot->' +
'Data Mine->'
'Data Mine->Trading Mine->'
let taskDefinition = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, taskLightingPath)
@@ -67,15 +94,17 @@ function newTaskFunctions() {
'Data Storage->Session Independent Data->Exchange Data Products->' +
'Single Market Data->' +
'Data Mine Products->Bot Products->' +
'Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->' +
'Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->' +
'Data Product->Product Definition->' +
'Data Mining->Testing Environment->Production Environment->' +
'Exchange Tasks->Crypto Exchange->' +
'Exchange Data Tasks->Exchange Trading Tasks->Crypto Exchange->' +
'Market Data Tasks->Market Trading Tasks->Market->' +
'Data Mine Tasks->Trading Mine Tasks->' +
'Task Manager->Task->' +
'Indicator Bot Instance->Sensor Bot Instance->Trading Bot Instance->' +
'Indicator Process Instance->Sensor Process Instance->Trading Process Instance->' +
'Paper Trading Session->Forward Testing Session->Backtesting Session->Live Trading Session->' +
'Market Reference->Market->' +
'Market->' +
'Process Definition->'
let networkDefinition = functionLibraryProtocolNode.getProtocolNode(networkNode.payload.parentNode, false, true, true, false, false, networkLightingPath)
@@ -99,12 +128,12 @@ function newTaskFunctions() {
}
function stopTask(node, functionLibraryProtocolNode, callBackFunction) {
if (validations(node) !== true) {
let networkNode = validations(node)
if (networkNode === undefined) {
/* This means that the validations failed. */
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
let networkNode = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode
let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id)
let event = {
@@ -139,27 +168,34 @@ function newTaskFunctions() {
return
}
if (node.payload.parentNode.payload.parentNode === undefined) {
let taskManager = node.payload.parentNode
if (taskManager.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Task needs to be inside Mine Tasks.')
return
}
if (taskManager.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Task needs to be inside Market Tasks.')
return
}
if (taskManager.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Task needs to be inside Exchange Tasks.')
return
}
if (node.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Task needs to be inside a Testing or Production Environment or a Data Mining node.')
if (taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Task needs to be inside a Data Mining, Testing or Production Environment.')
return
}
if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
if (taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Task needs to be inside a Network Node.')
return
}
if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Task needs to be inside a Network.')
return
}
let networkNode = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode
let networkNode = taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode
if (loadPropertyFromNodeConfig(networkNode.payload, 'host') === undefined) {
node.payload.uiObject.setErrorMessage('Network Node needs to have a valid Host property at its config.')
return
@@ -175,7 +211,7 @@ function newTaskFunctions() {
return
}
return true
return networkNode
}
function runAllTasks(taskManager, functionLibraryProtocolNode) {
@@ -215,9 +251,90 @@ function newTaskFunctions() {
menu.internalClick('Stop All Tasks')
}
}
function runAllExchangeTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.exchangeTasks.length; i++) {
let node = parent.exchangeTasks[i]
function runAllExchangeDataTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.exchangeDataTasks.length; i++) {
let node = parent.exchangeDataTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Run All Market Data Tasks')
menu.internalClick('Run All Market Data Tasks')
}
}
function stopAllExchangeDataTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.exchangeDataTasks.length; i++) {
let node = parent.exchangeDataTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Stop All Market Data Tasks')
menu.internalClick('Stop All Market Data Tasks')
}
}
function runAllExchangeTradingTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.exchangeTradingTasks.length; i++) {
let node = parent.exchangeTradingTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Run All Market Trading Tasks')
menu.internalClick('Run All Market Trading Tasks')
}
}
function stopAllExchangeTradingTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.exchangeTradingTasks.length; i++) {
let node = parent.exchangeTradingTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Stop All Market Trading Tasks')
menu.internalClick('Stop All Market Trading Tasks')
}
}
function runAllMarketDataTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.marketDataTasks.length; i++) {
let node = parent.marketDataTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Run All Data Mine Tasks')
menu.internalClick('Run All Data Mine Tasks')
}
}
function stopAllMarketDataTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.marketDataTasks.length; i++) {
let node = parent.marketDataTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Stop All Data Mine Tasks')
menu.internalClick('Stop All Data Mine Tasks')
}
}
function runAllMarketTradingTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.marketTradingTasks.length; i++) {
let node = parent.marketTradingTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Run All Trading Mine Tasks')
menu.internalClick('Run All Trading Mine Tasks')
}
}
function stopAllMarketTradingTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.marketTradingTasks.length; i++) {
let node = parent.marketTradingTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Stop All Trading Mine Tasks')
menu.internalClick('Stop All Trading Mine Tasks')
}
}
function runAllDataMineTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.dataMineTasks.length; i++) {
let node = parent.dataMineTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Run All Task Managers')
@@ -225,13 +342,205 @@ function newTaskFunctions() {
}
}
function stopAllExchangeTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.exchangeTasks.length; i++) {
let node = parent.exchangeTasks[i]
function stopAllDataMineTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.dataMineTasks.length; i++) {
let node = parent.dataMineTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Stop All Task Managers')
menu.internalClick('Stop All Task Managers')
}
}
function runAllTradingMineTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.tradingMineTasks.length; i++) {
let node = parent.tradingMineTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Run All Task Managers')
menu.internalClick('Run All Task Managers')
}
}
function stopAllTradingMineTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.tradingMineTasks.length; i++) {
let node = parent.tradingMineTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Stop All Task Managers')
menu.internalClick('Stop All Task Managers')
}
}
function addMissingExchangeDataTasks(node, rootNodes, functionLibraryUiObjectsFromNodes) {
addMissingExchangeTasks(node, rootNodes, 'Exchange Data Tasks', functionLibraryUiObjectsFromNodes)
}
function addMissingExchangeTradingTasks(node, rootNodes, functionLibraryUiObjectsFromNodes) {
addMissingExchangeTasks(node, rootNodes, 'Exchange Trading Tasks', functionLibraryUiObjectsFromNodes)
}
function addMissingExchangeTasks(node, rootNodes, newNodeType, functionLibraryUiObjectsFromNodes) {
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === 'Crypto Ecosystem') {
let cryptoEcosystem = rootNode
for (let j = 0; j < cryptoEcosystem.cryptoExchanges.length; j++) {
let cryptoExchanges = cryptoEcosystem.cryptoExchanges[j]
for (let k = 0; k < cryptoExchanges.exchanges.length; k++) {
let cryptoExchange = cryptoExchanges.exchanges[k]
if (isMissingChildren(node, cryptoExchange, true) === true) {
let exchangeDataTasks = functionLibraryUiObjectsFromNodes.addUIObject(node, newNodeType)
exchangeDataTasks.payload.referenceParent = cryptoExchange
}
}
}
}
}
}
function addMissingMarketDataTasks(node, rootNodes, functionLibraryUiObjectsFromNodes) {
addMissingMarketTasks(node, rootNodes, 'Market Data Tasks', functionLibraryUiObjectsFromNodes)
}
function addMissingMarketTradingTasks(node, rootNodes, functionLibraryUiObjectsFromNodes) {
addMissingMarketTasks(node, rootNodes, 'Market Trading Tasks', functionLibraryUiObjectsFromNodes)
}
function addMissingMarketTasks(node, rootNodes, newNodeType, functionLibraryUiObjectsFromNodes) {
if (node.payload === undefined) { return }
if (node.payload.referenceParent === undefined) { return }
if (node.payload.referenceParent.exchangeMarkets === undefined) { return }
let markets = node.payload.referenceParent.exchangeMarkets.markets
for (let i = 0; i < markets.length; i++) {
let market = markets[i]
if (isMissingChildren(node, market, true) === true) {
let marketDataTasks = functionLibraryUiObjectsFromNodes.addUIObject(node, newNodeType)
marketDataTasks.payload.referenceParent = market
}
}
}
function addMissingDataMineTasks(node, rootNodes, functionLibraryUiObjectsFromNodes) {
addMissingMineTasks(node, rootNodes, 'Data Mine', 'Data Mine Tasks', functionLibraryUiObjectsFromNodes)
}
function addMissingTradingMineTasks(node, rootNodes, functionLibraryUiObjectsFromNodes) {
addMissingMineTasks(node, rootNodes, 'Trading Mine', 'Trading Mine Tasks', functionLibraryUiObjectsFromNodes)
}
function addMissingMineTasks(node, rootNodes, rootNodeType, newNodeType, functionLibraryUiObjectsFromNodes) {
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === rootNodeType) {
let dataMine = rootNode
if (isMissingChildren(node, dataMine, true) === true) {
let dataMineTasks = functionLibraryUiObjectsFromNodes.addUIObject(node, newNodeType)
dataMineTasks.payload.referenceParent = dataMine
}
}
}
}
function addAllTasks(node, rootNodes, functionLibraryUiObjectsFromNodes) {
if (node.payload === undefined) { return }
if (node.payload.referenceParent === undefined) { return }
let dataMine = node.payload.referenceParent
let taskManager = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Task Manager')
addTasksForBotArray(dataMine.sensorBots)
addTasksForBotArray(dataMine.indicatorBots)
addTasksForBotArray(dataMine.tradingBots)
function addTasksForBotArray(botsArray) {
if (botsArray === undefined) { return }
for (let i = 0; i < botsArray.length; i++) {
let bot = botsArray[i]
let task = functionLibraryUiObjectsFromNodes.addUIObject(taskManager, 'Task')
task.name = bot.name
let botInstance
switch (bot.type) {
case 'Sensor Bot': {
botInstance = functionLibraryUiObjectsFromNodes.addUIObject(task, 'Sensor Bot Instance')
botInstance.name = bot.name
break
}
case 'Indicator Bot': {
botInstance = functionLibraryUiObjectsFromNodes.addUIObject(task, 'Indicator Bot Instance')
botInstance.name = bot.name
break
}
case 'Trading Bot': {
botInstance = functionLibraryUiObjectsFromNodes.addUIObject(task, 'Trading Bot Instance')
botInstance.name = bot.name
break
}
}
for (let j = 0; j < bot.processes.length; j++) {
let process = bot.processes[j]
let processInstance
switch (bot.type) {
case 'Sensor Bot': {
processInstance = functionLibraryUiObjectsFromNodes.addUIObject(botInstance, 'Sensor Process Instance')
processInstance.payload.referenceParent = process
break
}
case 'Indicator Bot': {
processInstance = functionLibraryUiObjectsFromNodes.addUIObject(botInstance, 'Indicator Process Instance')
processInstance.payload.referenceParent = process
break
}
case 'Trading Bot': {
processInstance = functionLibraryUiObjectsFromNodes.addUIObject(botInstance, 'Trading Process Instance')
processInstance.payload.referenceParent = process
if (node.payload.parentNode === undefined) { return }
if (node.payload.parentNode.payload === undefined) { return }
if (node.payload.parentNode.payload.parentNode === undefined) { return }
if (node.payload.parentNode.payload.parentNode.payload === undefined) { return }
if (node.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { return }
let environment = node.payload.parentNode.payload.parentNode.payload.parentNode
let session
switch (environment.type) {
case 'Testing Environment': {
addSession('Backtesting Session')
break
}
case 'Production Environment': {
addSession('Live Trading Session')
break
}
}
break
function addSession(sessionType) {
session = functionLibraryUiObjectsFromNodes.addUIObject(processInstance, sessionType)
session.name = task.name + ' ' + session.type
for (let m = 0; m < rootNodes.length; m++) {
let rootNode = rootNodes[m]
if (rootNode.type === 'Trading Engine' && rootNode.isIncluded === true) {
let tradingEngine = rootNode
session.tradingEngineReference.payload.referenceParent = tradingEngine
}
}
}
}
}
}
}
}
}
}
@@ -26,6 +26,19 @@ function newUiObjectsFromNodes() {
tasksToRun = []
sessionsToRun = []
removeNullRootNodes()
function removeNullRootNodes() {
for (let i = 0; i < node.rootNodes.length; i++) {
let rootNode = node.rootNodes[i]
if (rootNode === null) {
node.rootNodes.splice(i, 1)
removeNullRootNodes()
return
}
}
}
getIncludedNames()
function getIncludedNames() {
@@ -46,6 +59,7 @@ function newUiObjectsFromNodes() {
function addIncludedNodes(includedNames) {
let blobService = newFileStorage()
let includedDataMines = includedNames.includedDataMines
let includedTradingMines = includedNames.includedTradingMines
let includedTradingSystems = includedNames.includedTradingSystems
let includedSuperScripts = includedNames.includedSuperScripts
let includedTradingEngines = includedNames.includedTradingEngines
@@ -75,7 +89,36 @@ function newUiObjectsFromNodes() {
receivedNode.isIncluded = true
node.rootNodes.unshift(receivedNode)
totalIncluded++
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length + includedTradingEngines.length) {
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length + includedTradingEngines.length + includedTradingMines.length) {
addUserDefinedNodes()
}
}
}
for (let i = 0; i < includedTradingMines.length; i++) {
let name = includedTradingMines[i]
blobService.getFileFromHost('TradingMines' + '/' + name, onFileReceived, true)
function onFileReceived(err, text, response) {
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
console.log('Cannot load included Trading Mine ' + name + '. The workspace can not be loaded.')
return
}
let receivedNode = JSON.parse(text)
for (let i = 0; i < node.rootNodes.length; i++) {
let rootNode = node.rootNodes[i]
if (rootNode.type === 'Trading Mine') {
if (rootNode.config !== undefined) {
let config = JSON.parse(rootNode.config)
if (config.name === name) {
rootNodes.splice(i, 1)
}
}
}
}
receivedNode.isIncluded = true
node.rootNodes.unshift(receivedNode)
totalIncluded++
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length + includedTradingEngines.length + includedTradingMines.length) {
addUserDefinedNodes()
}
}
@@ -104,7 +147,7 @@ function newUiObjectsFromNodes() {
receivedNode.isIncluded = true
node.rootNodes.unshift(receivedNode)
totalIncluded++
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length + includedTradingEngines.length) {
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length + includedTradingEngines.length + includedTradingMines.length) {
addUserDefinedNodes()
}
}
@@ -133,7 +176,7 @@ function newUiObjectsFromNodes() {
receivedNode.isIncluded = true
node.rootNodes.unshift(receivedNode)
totalIncluded++
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length + includedTradingEngines.length) {
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length + includedTradingEngines.length + includedTradingMines.length) {
addUserDefinedNodes()
}
}
@@ -159,7 +202,7 @@ function newUiObjectsFromNodes() {
receivedNode.isIncluded = true
node.rootNodes.unshift(receivedNode)
totalIncluded++
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length + includedTradingEngines.length) {
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length + includedTradingEngines.length + includedTradingMines.length) {
addUserDefinedNodes()
}
}
+105 -10
View File
@@ -345,16 +345,16 @@ function newWorkspace() {
for (let j = 0; j < rootNode.networkNodes.length; j++) {
let networkNode = rootNode.networkNodes[j]
if (networkNode.dataMining !== undefined && networkNode.dataMining.payload !== undefined) {
networkNode.dataMining.payload.uiObject.menu.internalClick('Stop All Exchange Tasks')
networkNode.dataMining.payload.uiObject.menu.internalClick('Stop All Exchange Tasks')
networkNode.dataMining.payload.uiObject.menu.internalClick('Stop All Exchange Data Tasks')
networkNode.dataMining.payload.uiObject.menu.internalClick('Stop All Exchange Data Tasks')
}
if (networkNode.testingEnvironment !== undefined && networkNode.testingEnvironment.payload !== undefined) {
networkNode.testingEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Tasks')
networkNode.testingEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Tasks')
networkNode.testingEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Trading Tasks')
networkNode.testingEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Trading Tasks')
}
if (networkNode.productionEnvironment !== undefined && networkNode.productionEnvironment.payload !== undefined) {
networkNode.productionEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Tasks')
networkNode.productionEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Tasks')
networkNode.productionEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Trading Tasks')
networkNode.productionEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Trading Tasks')
}
}
}
@@ -591,14 +591,99 @@ function newWorkspace() {
functionLibraryTaskFunctions.stopAllTaskManagers(payload.node, functionLibraryProtocolNode)
}
break
case 'Run All Exchange Tasks':
case 'Run All Exchange Data Tasks':
{
functionLibraryTaskFunctions.runAllExchangeTasks(payload.node, functionLibraryProtocolNode)
functionLibraryTaskFunctions.runAllExchangeDataTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Stop All Exchange Tasks':
case 'Stop All Exchange Data Tasks':
{
functionLibraryTaskFunctions.stopAllExchangeTasks(payload.node, functionLibraryProtocolNode)
functionLibraryTaskFunctions.stopAllExchangeDataTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Run All Exchange Trading Tasks':
{
functionLibraryTaskFunctions.runAllExchangeTradingTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Stop All Exchange Trading Tasks':
{
functionLibraryTaskFunctions.stopAllExchangeTradingTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Run All Market Data Tasks':
{
functionLibraryTaskFunctions.runAllMarketDataTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Stop All Market Data Tasks':
{
functionLibraryTaskFunctions.stopAllMarketDataTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Run All Market Trading Tasks':
{
functionLibraryTaskFunctions.runAllMarketTradingTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Stop All Market Trading Tasks':
{
functionLibraryTaskFunctions.stopAllMarketTradingTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Run All Data Mine Tasks':
{
functionLibraryTaskFunctions.runAllDataMineTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Stop All Data Mine Tasks':
{
functionLibraryTaskFunctions.stopAllDataMineTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Run All Trading Mine Tasks':
{
functionLibraryTaskFunctions.runAllTradingMineTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Stop All Trading Mine Tasks':
{
functionLibraryTaskFunctions.stopAllTradingMineTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Add Missing Exchange Data Tasks':
{
functionLibraryTaskFunctions.addMissingExchangeDataTasks(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Market Data Tasks':
{
functionLibraryTaskFunctions.addMissingMarketDataTasks(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Data Mine Tasks':
{
functionLibraryTaskFunctions.addMissingDataMineTasks(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Exchange Trading Tasks':
{
functionLibraryTaskFunctions.addMissingExchangeTradingTasks(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Market Trading Tasks':
{
functionLibraryTaskFunctions.addMissingMarketTradingTasks(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Trading Mine Tasks':
{
functionLibraryTaskFunctions.addMissingTradingMineTasks(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Tasks':
{
functionLibraryTaskFunctions.addAllTasks(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Crypto Exchanges':
@@ -631,6 +716,16 @@ function newWorkspace() {
functionLibraryDataStorageFunctions.addAllDataMineProducts(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Trading Mine Products':
{
functionLibraryDataStorageFunctions.addAllTradingMineProducts(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Session References':
{
functionLibraryDataStorageFunctions.addMissingSessionReferences(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Data Dependencies':
{
functionLibraryDataMineFunctions.addAllDataDependencies(payload.node, functionLibraryUiObjectsFromNodes)
+1 -1
View File
@@ -299,7 +299,7 @@ function newCircularMenuItem() {
/* The first click ask for confirmation. */
if (temporaryStatus === STATUS_NO_ACTION_TAKEN_YET) {
setStatus(thisObject.confirmationLabel, UI_COLOR.GOLDEN_ORANGE, 20, STATUS_WAITING_CONFIRMATION)
setStatus(thisObject.confirmationLabel, UI_COLOR.GOLDEN_ORANGE, 100, STATUS_WAITING_CONFIRMATION)
return
}
/* A Click during confirmation executes the pre-defined action. */
+18 -15
View File
@@ -173,7 +173,7 @@ function newLayer() {
'Product Definition->' +
'Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->' +
'Sensor Bot->Indicator Bot->Trading Bot->' +
'Data Mine->' +
'Data Mine->Trading Mine->' +
'Dataset Definition->' +
'Record Definition->Record Property->Formula->' +
'Data Building Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' +
@@ -205,46 +205,49 @@ function newLayer() {
}
/* Here we validate that we have all the needed information */
if (findNodeInNodeMesh(thisObject.definition, 'Data Product') === undefined) {
if (findNodeInNodeMesh(thisObject.definition, 'Data Product', false, true, true, true) === undefined) {
thisObject.payload.uiObject.setErrorMessage('Data Product not Found')
return
}
if (findNodeInNodeMesh(thisObject.definition, 'Market') === undefined) {
if (findNodeInNodeMesh(thisObject.definition, 'Market', false, true, true, true) === undefined) {
thisObject.payload.uiObject.setErrorMessage('Market not Found')
return
}
thisObject.productDefinition = findNodeInNodeMesh(thisObject.definition, 'Product Definition')
thisObject.productDefinition = findNodeInNodeMesh(thisObject.definition, 'Product Definition', false, true, true, true)
if (thisObject.productDefinition === undefined) {
thisObject.payload.uiObject.setErrorMessage('Product Definition not Found')
return
}
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Sensor Bot')
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Sensor Bot', false, true, true, true)
if (thisObject.bot === undefined) {
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Indicator Bot')
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Indicator Bot', false, true, true, true)
}
if (thisObject.bot === undefined) {
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Trading Bot')
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Trading Bot', false, true, true, true)
}
if (thisObject.bot === undefined) {
thisObject.payload.uiObject.setErrorMessage('Bot not Found')
return
}
thisObject.dataMine = findNodeInNodeMesh(thisObject.definition, 'Data Mine')
thisObject.dataMine = findNodeInNodeMesh(thisObject.definition, 'Data Mine', false, true, true, true)
if (thisObject.dataMine === undefined) {
thisObject.payload.uiObject.setErrorMessage('Data Mine not Found')
return
thisObject.dataMine = findNodeInNodeMesh(thisObject.definition, 'Trading Mine', false, true, true, true)
if (thisObject.dataMine === undefined) {
thisObject.payload.uiObject.setErrorMessage('Data Mine or Trading Mine not Found')
return
}
}
thisObject.exchange = findNodeInNodeMesh(thisObject.definition, 'Crypto Exchange')
thisObject.exchange = findNodeInNodeMesh(thisObject.definition, 'Crypto Exchange', false, true, true, true)
if (thisObject.exchange === undefined) {
thisObject.payload.uiObject.setErrorMessage('Crypto Exchange not Found')
return
}
thisObject.baseAsset = findNodeInNodeMesh(thisObject.definition, 'Market Base Asset')
thisObject.baseAsset = findNodeInNodeMesh(thisObject.definition, 'Market Base Asset', false, true, true, true)
if (thisObject.baseAsset !== undefined) {
thisObject.baseAsset = thisObject.baseAsset.referenceParent
}
@@ -253,7 +256,7 @@ function newLayer() {
return
}
thisObject.quotedAsset = findNodeInNodeMesh(thisObject.definition, 'Market Quoted Asset')
thisObject.quotedAsset = findNodeInNodeMesh(thisObject.definition, 'Market Quoted Asset', false, true, true, true)
if (thisObject.quotedAsset !== undefined) {
thisObject.quotedAsset = thisObject.quotedAsset.referenceParent
}
@@ -262,13 +265,13 @@ function newLayer() {
return
}
thisObject.plotterModule = findNodeInNodeMesh(thisObject.definition, 'Plotter Module')
thisObject.plotterModule = findNodeInNodeMesh(thisObject.definition, 'Plotter Module', false, true, true, true)
if (thisObject.plotterModule === undefined) {
thisObject.payload.uiObject.setErrorMessage('Market Quoted Asset not Found')
return
}
thisObject.networkNode = findNodeInNodeMesh(thisObject.definition, 'Network Node')
thisObject.networkNode = findNodeInNodeMesh(thisObject.definition, 'Network Node', false, true, true, true)
if (thisObject.networkNode === undefined) {
thisObject.payload.uiObject.setErrorMessage('Network Node not Found')
return
+4
View File
@@ -3,11 +3,15 @@ function nodeBranchToArray(node, nodeType) {
This function scans a node branch for a certain node type and
return an array of with all the nodes of that type found.
*/
if (node === undefined) { return }
if (nodeType === undefined) { return }
let resultArray = []
scanNodeBranch(node, nodeType)
return resultArray
function scanNodeBranch(startingNode) {
if (startingNode === undefined) {return}
let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type)
if (nodeDefinition === undefined) { return }
+4 -3
View File
@@ -1,8 +1,9 @@
/*
This function scans a node hiriatchy recursively and creates a Map by Id of all the nodes of it.
*/
function getHiriarchyMap(rootNode) {
/*
This function scans a node hiriatchy recursively and creates a Map by Id of all the nodes of it.
*/
let hiriatchyMap = new Map()
evalNode(rootNode)
return hiriatchyMap
+40 -20
View File
@@ -1,10 +1,10 @@
function findNodeInNodeMesh(node, nodeType) {
function findNodeInNodeMesh(node, nodeType, connectedViaPayload, findInChildren, findInParents, findInReferenceParents) {
/*
This function scans a node mesh for a certain node type and
returns the first instance found.
*/
let nodeFound
scanNodeMesh(node, nodeType)
scanNodeMesh(node)
return nodeFound
function scanNodeMesh(startingNode) {
@@ -20,34 +20,54 @@ function findNodeInNodeMesh(node, nodeType) {
}
/* We scan through this node children */
if (nodeDefinition.properties !== undefined) {
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
if (findInChildren === true) {
if (nodeDefinition.properties !== undefined) {
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
switch (property.type) {
case 'node': {
scanNodeMesh(startingNode[property.name])
}
break
case 'array': {
let startingNodePropertyArray = startingNode[property.name]
if (startingNodePropertyArray !== undefined) {
for (let m = 0; m < startingNodePropertyArray.length; m++) {
scanNodeMesh(startingNodePropertyArray[m])
switch (property.type) {
case 'node': {
scanNodeMesh(startingNode[property.name])
}
break
case 'array': {
let startingNodePropertyArray = startingNode[property.name]
if (startingNodePropertyArray !== undefined) {
for (let m = 0; m < startingNodePropertyArray.length; m++) {
scanNodeMesh(startingNodePropertyArray[m])
}
}
break
}
break
}
}
}
}
/* We scan parents nodes. */
if (startingNode.parentNode !== undefined) {
scanNodeMesh(startingNode.parentNode)
if (findInParents === true) {
if (connectedViaPayload === true) {
if (startingNode.payload.parentNode !== undefined) {
scanNodeMesh(startingNode.payload.parentNode)
}
} else {
if (startingNode.parentNode !== undefined) {
scanNodeMesh(startingNode.parentNode)
}
}
}
/* We scan reference parents too. */
if (startingNode.referenceParent !== undefined) {
scanNodeMesh(startingNode.referenceParent)
if (findInReferenceParents === true) {
if (connectedViaPayload === true) {
if (startingNode.payload.referenceParent !== undefined) {
scanNodeMesh(startingNode.payload.referenceParent)
}
} else {
if (startingNode.referenceParent !== undefined) {
scanNodeMesh(startingNode.referenceParent)
}
}
}
}
}
+61
View File
@@ -0,0 +1,61 @@
function isMissingChildren(startingNode, checkNode, checkReferenceParent) {
/*
This functioin scan all the children of a node and returns true or false
depending if the checkNode is a missing children.
*/
if (startingNode === undefined) { return }
if (checkNode === undefined) { return }
let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type)
if (nodeDefinition === undefined) { return }
/* We scan through this node children */
if (nodeDefinition.properties !== undefined) {
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
switch (property.type) {
case 'node': {
let child = startingNode[property.name]
if (checkReferenceParent !== true) {
if (child.id === checkNode.id) {
return false
}
} else {
if (child.payload !== undefined) {
if (child.payload.referenceParent !== undefined) {
if (child.payload.referenceParent.id === checkNode.id) {
return false
}
}
}
}
}
break
case 'array': {
let startingNodePropertyArray = startingNode[property.name]
if (startingNodePropertyArray !== undefined) {
for (let m = 0; m < startingNodePropertyArray.length; m++) {
let arrayItem = startingNodePropertyArray[m]
if (checkReferenceParent !== true) {
if (arrayItem.id === checkNode.id) {
return false
}
} else {
if (arrayItem.payload !== undefined) {
if (arrayItem.payload.referenceParent !== undefined) {
if (arrayItem.payload.referenceParent.id === checkNode.id) {
return false
}
}
}
}
}
}
break
}
}
}
return true
}
}
+1 -1
View File
@@ -1 +1 @@
{"type":"Data Mine","name":"Masters","config":"{\n\"codeName\": \"Masters\"\n}","sensorBots":[{"type":"Sensor Bot","name":"Exchange Raw Data","config":"{\n\"codeName\": \"Exchange-Raw-Data\",\n\"repo\": \"Exchange-Raw-Data-Sensor-Bot\"\n}","processes":[{"type":"Process Definition","name":"Historic-Trades","config":"{\n \"codeName\": \"Historic-Trades\",\n \"description\": \"Retrieves and saves the historical trades in batches going backwards from the current time until reaching the begining of the market.\",\n \"startMode\": {\n \"noTime\": {\n \"run\": \"true\"\n },\n \"fixedInterval\": {\n \"run\": \"false\",\n \"interval\": 0\n }\n },\n \"deadWaitTime\": 0,\n \"normalWaitTime\": 60000,\n \"retryWaitTime\": 10000\n}","processOutput":{"type":"Process Output","name":"New Process Output","outputDatasets":[],"outputDatasetFolders":[],"id":"e3008f15-43ae-4452-9c28-bfbb6c1a5e84","savedPayload":{"position":{"x":13889.892304785908,"y":17976.7326423862},"targetPosition":{"x":13788.99537092664,"y":18353.285125876908},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":4,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"processDependencies":{"type":"Process Dependencies","name":"New Process Dependencies","statusDependencies":[{"type":"Status Dependency","name":"Self Reference","config":"{\n \"mainUtility\": \"Self Reference\"\n}","id":"f796022a-7871-4bde-bcc7-bcf2818f1eaf","savedPayload":{"position":{"x":14299.325525762739,"y":17993.12379366583},"targetPosition":{"x":13938.17907937083,"y":17993.12379366583},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Status Report","name":"New Status Report","id":"116834de-6646-4387-9f4b-4f711cea9235"}}}],"dataDependencies":[],"id":"1332b41e-7cd2-4e69-a40a-39ea47df67b5","savedPayload":{"position":{"x":13938.17907937083,"y":17993.12379366583},"targetPosition":{"x":13788.99537092664,"y":18353.285125876908},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":4,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"statusReport":{"type":"Status Report","name":"New Status Report","id":"116834de-6646-4387-9f4b-4f711cea9235","savedPayload":{"position":{"x":13983.913279342734,"y":18015.677405195172},"targetPosition":{"x":13788.99537092664,"y":18353.285125876908},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":4,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"executionStartedEvent":{"type":"Execution Started Event","name":"New Execution Started Event","id":"a9ea7169-fcd8-48c3-b0a9-b4e8941aa170","savedPayload":{"position":{"x":14026.312379860185,"y":18044.00757842793},"targetPosition":{"x":13788.99537092664,"y":18353.285125876908},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":4,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"executionFinishedEvent":{"type":"Execution Finished Event","name":"New Execution Finished Event","id":"51908884-c7a2-46ca-8a55-209070ae5fa6","savedPayload":{"position":{"x":14064.650920558077,"y":18077.62957624547},"targetPosition":{"x":13788.99537092664,"y":18353.285125876908},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":4,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"7a6a9399-474f-4a93-bcbd-28a594ef1943","savedPayload":{"position":{"x":14351.93363503598,"y":18425.400341491753},"targetPosition":{"x":13888.04337325749,"y":18696.024787447222},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":3,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Process Definition","name":"Historic-OHLCVs","config":"{\n \"codeName\": \"Historic-OHLCVs\",\n \"description\": \"Retrieves and saves historical maket data\",\n \"startMode\": {\n \"noTime\": {\n \"run\": \"true\"\n },\n \"fixedInterval\": {\n \"run\": \"false\",\n \"interval\": 0\n }\n },\n \"deadWaitTime\": 0,\n \"normalWaitTime\": 60000,\n \"retryWaitTime\": 10000\n}","processOutput":{"type":"Process Output","name":"New Process Output","outputDatasets":[],"outputDatasetFolders":[],"id":"dfe2556e-a765-4e38-9d30-7f91090c0069","savedPayload":{"position":{"x":14546.018334597831,"y":18039.39680205973},"targetPosition":{"x":14407.127481538195,"y":18558.43550715096},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"processDependencies":{"type":"Process Dependencies","name":"New Process Dependencies","statusDependencies":[{"type":"Status Dependency","name":"Exchange Raw Data HiLine truncated
{"type":"Data Mine","name":"Masters","config":"{\n\"codeName\": \"Masters\"\n}","sensorBots":[{"type":"Sensor Bot","name":"Exchange Raw Data","config":"{\n\"codeName\": \"Exchange-Raw-Data\",\n\"repo\": \"Exchange-Raw-Data-Sensor-Bot\"\n}","processes":[{"type":"Process Definition","name":"Historic-OHLCVs","config":"{\n \"codeName\": \"Historic-OHLCVs\",\n \"description\": \"Retrieves and saves historical maket data\",\n \"startMode\": {\n \"noTime\": {\n \"run\": \"true\"\n },\n \"fixedInterval\": {\n \"run\": \"false\",\n \"interval\": 0\n }\n },\n \"deadWaitTime\": 0,\n \"normalWaitTime\": 60000,\n \"retryWaitTime\": 10000\n}","processOutput":{"type":"Process Output","name":"New Process Output","outputDatasets":[],"outputDatasetFolders":[],"id":"dfe2556e-a765-4e38-9d30-7f91090c0069","savedPayload":{"position":{"x":14394.065488483304,"y":17915.680472646407},"targetPosition":{"x":14365.917539523816,"y":18452.02942841029},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"processDependencies":{"type":"Process Dependencies","name":"New Process Dependencies","statusDependencies":[{"type":"Status Dependency","name":"Exchange Raw Data Historic-OHLCVs","config":"{\n \"mainUtility\": \"Self Reference\"\n}","id":"ea39c98b-18e2-44ce-9f7f-86a8a76a688a","savedPayload":{"position":{"x":14950.521978667004,"y":17551.922605803902},"targetPosition":{"x":14658.34180198947,"y":18001.872486528806},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Status Report","name":"New Status Report","id":"181c7c34-7243-497a-9ddb-1b0067c6d66e"}}}],"dataDependencies":[],"dataMineDataDependencies":[],"id":"5c7fae5a-6da6-4864-a167-f2f21d578c72","savedPayload":{"position":{"x":14658.34180198947,"y":18001.872486528806},"targetPosition":{"x":14365.917539523816,"y":18452.02942841029},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"statusReport":{"type":"Status Report","name":"New Status Report","id":"181c7c34-7243-497a-9ddb-1b0067c6d66e","savedPayload":{"position":{"x":14844.267046631352,"y":18208.28341869284},"targetPosition":{"x":14365.917539523816,"y":18452.02942841029},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"executionStartedEvent":{"type":"Execution Started Event","name":"","id":"957e7e3a-b167-40be-93b5-9ba4ceff56e5","savedPayload":{"position":{"x":14902.323166689097,"y":18479.728138885595},"targetPosition":{"x":14365.917539523816,"y":18452.02942841029},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"executionFinishedEvent":{"type":"Execution Finished Event","name":"New Execution Finished Event","id":"fe40a546-43ee-49df-908a-7e72f598f0cd","savedPayload":{"position":{"x":14816.975392575445,"y":18744.108408280114},"targetPosition":{"x":14365.917539523816,"y":18452.02942841029},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"5eb11d6a-022e-4f60-97c4-d6cf90b249dc","savedPayload":{"position":{"x":14365.917539523816,"y":18452.02942841029},"targetPosition":{"x":13888.04337325749,"y":18696.024787447222},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"products":[{"type":"Product Definition","name":"Trades","config":"{\n\"codeName\": \"Trades\"\n}","datasets":[{"type":"Dataset Definition","name":"Trades","config":"{\n\"codeName\": \"Trades\"\n}","id":"fbb7c17e-a909-4fa2-b3c5-eb8ca86297c4","savedPayload":{"position":{"x":14683.236895595232,"y":18570.836403251822},"targetPosition":{"x":14417.90131386714,"y":18612.93655296852},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}}],"id":"38dbb942-a15b-450b-a867-02a94030965f","savedPayload":{"position":{"x":14417.90131386714,"y":18612.93655296852},"targetPosition":{"x":13888.04337325749,"y":18696.024787447222},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Product Definition","name":"Candles","config":"{\n\"codeName\": \"Candles\"\n}","datasets":[{"type":"Dataset Definition","name":"One-Min","config":"{\n\"codeName\": \"One-Min\"\n}","id":"1c3696e4-c28e-4744-9100-706d6dce0c3c","savedPayload":{"position":{"x":14682.8226429Line truncated
+22 -13
View File
@@ -96,33 +96,42 @@
}
let botNode = global.FIND_NODE_IN_NODE_MESH(outputDatasetNode, 'Indicator Bot')
if (botNode === undefined) {
if (botNode === undefined) {
botNode = global.FIND_NODE_IN_NODE_MESH(outputDatasetNode, 'Trading Bot')
}
if (botNode === undefined) {
logger.write(MODULE_NAME, "[ERROR] start -> Product Definition not attached to a Bot. Product Definition = " );
logger.write(MODULE_NAME, "[ERROR] start -> Product Definition not attached to a Bot. Product Definition = ");
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return
}
if (botNode.config.codeName === undefined) {
logger.write(MODULE_NAME, "[ERROR] start -> Bot witn no codeName defined." );
logger.write(MODULE_NAME, "[ERROR] start -> Bot witn no codeName defined.");
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return
}
let dataMineNode = global.FIND_NODE_IN_NODE_MESH(outputDatasetNode, 'Data Mine')
if (dataMineNode === undefined) {
logger.write(MODULE_NAME, "[ERROR] start -> Bot not attached to a Data Mine.");
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return
}
if (dataMineNode.config.codeName === undefined) {
logger.write(MODULE_NAME, "[ERROR] start -> Data Mine witn no codeName defined." );
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return
}
let tradingMineNode = global.FIND_NODE_IN_NODE_MESH(outputDatasetNode, 'Trading Mine')
if (tradingMineNode === undefined) {
logger.write(MODULE_NAME, "[ERROR] start -> Bot not attached to a Data Mine or a Trading Mine.");
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return
} else {
if (tradingMineNode.config.codeName === undefined) {
logger.write(MODULE_NAME, "[ERROR] start -> Trading Mine witn no codeName defined.");
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return
}
}
} else {
if (dataMineNode.config.codeName === undefined) {
logger.write(MODULE_NAME, "[ERROR] start -> Data Mine witn no codeName defined.");
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return
}
}
}
return true
}
+1 -1
View File
@@ -64,7 +64,7 @@ exports.newDataSet = function newDataSet(BOT, logger) {
}
if (thisObject.node.parentNode.parentNode.parentNode === undefined) {
logger.write(MODULE_NAME, "[ERROR] initialize -> Bot not attached to a Data Mine. Bot = " + JSON.stringify(thisObject.node.parentNode.parentNode));
logger.write(MODULE_NAME, "[ERROR] initialize -> Bot not attached to a Data Mine or Trading Mine. Bot = " + JSON.stringify(thisObject.node.parentNode.parentNode));
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return
}
+2 -2
View File
@@ -36,7 +36,7 @@
}
/* This bot is not ready for taking its code from the UI, then we need to load it from its repo. */
let filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.codeName
let filePath = bot.dataMine + "/" + "bots" + "/" + bot.processNode.referenceParent.parentNode.config.repo + "/" + pProcessConfig.codeName
filePath += "/User.Bot.js"
fileStorage.getTextFile(filePath, onBotDownloaded);
@@ -54,7 +54,7 @@
USER_BOT_MODULE = {}
USER_BOT_MODULE.newUserBot = eval(text); // TODO This needs to be changed function
filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo;
filePath = bot.dataMine + "/" + "bots" + "/" + bot.processNode.referenceParent.parentNode.config.repo
filePath += "/Commons.js"
fileStorage.getTextFile(filePath, onCommonsDownloaded);
+41 -41
View File
@@ -57,8 +57,7 @@
processThisDependsOn = bot.processNode.referenceParent.executionStartedEvent.referenceParent.parentNode
name = processThisDependsOn.name
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true)
{ logger.write(MODULE_NAME, "[INFO] initialize -> " + currentProcessKey + " based on the Data Mine depends on " + name); }
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] initialize -> " + currentProcessKey + " based on the Data Mine depends on " + name); }
}
}
}
@@ -72,8 +71,7 @@
processThisDependsOn = bot.processNode.executionStartedEvent.referenceParent.parentNode
name = processThisDependsOn.name
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true)
{ logger.write(MODULE_NAME, "[INFO] initialize -> " + currentProcessKey + " based on the User's Task depends on " + name); }
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] initialize -> " + currentProcessKey + " based on the User's Task depends on " + name); }
}
}
}
@@ -99,48 +97,50 @@
for (let i = 0; i < network.networkNodes.length; i++) {
let networkNode = network.networkNodes[i]
if (networkNode.dataMining !== undefined) {
for (let j = 0; j < networkNode.dataMining.exchangeTasks.length; j++) {
let exchangeTasks = networkNode.dataMining.exchangeTasks[j]
for (let k = 0; k < exchangeTasks.taskManagers.length; k++) {
let taskManager = exchangeTasks.taskManagers[k]
for (let m = 0; m < taskManager.tasks.length; m++) {
let task = taskManager.tasks[m]
if (task.bot !== undefined) {
for (let n = 0; n < task.bot.processes.length; n++) {
let process = task.bot.processes[n]
if (process.marketReference !== undefined) {
if (process.marketReference.referenceParent !== undefined) {
let market = process.marketReference.referenceParent
let currentProcessMarket = bot.processNode.marketReference.referenceParent
for (let j = 0; j < networkNode.dataMining.exchangeDataTasks.length; j++) {
let exchangeTasks = networkNode.dataMining.exchangeDataTasks[j]
for (let p = 0; p < exchangeTasks.marketDataTasks.length; p++) {
let marketTasks = exchangeTasks.marketDataTasks[p]
if (marketTasks.referenceParent === undefined) { continue }
if (marketTasks.referenceParent.id !== global.MARKET_NODE.id) { continue }
for (let q = 0; q < marketTasks.dataMineTasks.length; q++) {
let mineTasks = marketTasks.dataMineTasks[q]
for (let k = 0; k < mineTasks.taskManagers.length; k++) {
let taskManager = mineTasks.taskManagers[k]
for (let m = 0; m < taskManager.tasks.length; m++) {
let task = taskManager.tasks[m]
if (task.bot !== undefined) {
for (let n = 0; n < task.bot.processes.length; n++) {
let process = task.bot.processes[n]
if (process.referenceParent !== undefined) {
let processDefinition = process.referenceParent
if (processThisDependsOn.id === processDefinition.id) {
/*
We found where the task that runs the process definition
we are waiting for is located on the network.
*/
thisObject.networkNode = networkNode
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) {
logger.write(MODULE_NAME,
"[INFO] initialize -> Connecting to Websockets Server " + networkNode.name +
" -> host = " + networkNode.config.host +
' -> port = ' + networkNode.config.webSocketsPort + '.');
}
if (currentProcessMarket.id === market.id) {
if (process.referenceParent !== undefined) {
let processDefinition = process.referenceParent
if (processThisDependsOn.id === processDefinition.id) {
eventServerClient = EVENT_SERVER_CLIENT.newEventsServerClient(networkNode.config.host, networkNode.config.webSocketsPort)
eventServerClient.initialize(onConnected)
/* We found where the task that runs the process definition we are waiting for is located on the network. */
thisObject.networkNode = networkNode
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) {
logger.write(MODULE_NAME,
"[INFO] initialize -> Connecting to Websockets Server " + networkNode.name +
" -> host = " + networkNode.config.host +
' -> port = ' + networkNode.config.webSocketsPort + '.'); }
eventServerClient = EVENT_SERVER_CLIENT.newEventsServerClient(networkNode.config.host, networkNode.config.webSocketsPort)
eventServerClient.initialize(onConnected)
function onConnected() {
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) {
logger.write(MODULE_NAME, "[INFO] initialize -> Connected to Websockets Server " + networkNode.name +
" -> host = " + networkNode.config.host +
' -> port = ' + networkNode.config.webSocketsPort + '.'); }
callBackFunction(global.DEFAULT_OK_RESPONSE);
return
function onConnected() {
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) {
logger.write(MODULE_NAME, "[INFO] initialize -> Connected to Websockets Server " + networkNode.name +
" -> host = " + networkNode.config.host +
' -> port = ' + networkNode.config.webSocketsPort + '.');
}
callBackFunction(global.DEFAULT_OK_RESPONSE);
return
}
return
}
}
}
+2 -2
View File
@@ -59,7 +59,7 @@
return
}
} else {
logger.write(MODULE_NAME, "[ERROR] raiseEvents -> Bot not attached to a Data Mine. Bot = " + JSON.stringify(botNode));
logger.write(MODULE_NAME, "[ERROR] raiseEvents -> Bot not attached to a Data Mine or Trading Mine. Bot = " + JSON.stringify(botNode));
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return
}
@@ -142,7 +142,7 @@
throw (global.DEFAULT_FAIL_RESPONSE);
}
} else {
logger.write(MODULE_NAME, "[ERROR] raiseEvents -> Bot not attached to a Data Mine. Bot = " + JSON.stringify(botNode));
logger.write(MODULE_NAME, "[ERROR] raiseEvents -> Bot not attached to a Data Mine or Trading Mine. Bot = " + JSON.stringify(botNode));
throw (global.DEFAULT_FAIL_RESPONSE);
}
} else {
+10 -14
View File
@@ -140,7 +140,7 @@
const FILE_STORAGE = require('./FileStorage.js');
let fileStorage = FILE_STORAGE.newFileStorage();
let filePath = global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + '/bots/' + global.TASK_NODE.bot.config.repo + '/this.bot.config.json';
let filePath = global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + '/bots/' + processInstance.referenceParent.parentNode.config.repo + '/this.bot.config.json';
fileStorage.getTextFile(filePath, onFileReceived);
@@ -183,11 +183,11 @@
/* Simplifying the access to basic info */
botConfig.dataMine = global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName
botConfig.exchange = global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.parentNode.parentNode.name
botConfig.exchangeNode = global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.parentNode.parentNode
botConfig.exchange = global.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name
botConfig.exchangeNode = global.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode
botConfig.market = {
baseAsset: global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.baseAsset.referenceParent.config.codeName,
quotedAsset: global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.quotedAsset.referenceParent.config.codeName
baseAsset: global.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName,
quotedAsset: global.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName
}
botConfig.uiStartDate = global.TASK_NODE.bot.config.startDate
botConfig.config = global.TASK_NODE.bot.config
@@ -210,16 +210,12 @@
botConfig.marketTimeFrames = global.TASK_NODE.bot.timeFramesFilter.config.marketTimeFrames
}
if (botConfig.processNode) {
if (botConfig.processNode.marketReference) {
if (botConfig.processNode.marketReference.keyReference !== undefined) {
if (botConfig.processNode.marketReference.keyReference.referenceParent !== undefined) {
let key = botConfig.processNode.marketReference.keyReference.referenceParent
if (global.TASK_NODE.keyReference !== undefined) {
if (global.TASK_NODE.keyReference.referenceParent !== undefined) {
let key = global.TASK_NODE.keyReference.referenceParent
botConfig.KEY = key.config.codeName
botConfig.SECRET = key.config.secret
}
}
botConfig.KEY = key.config.codeName
botConfig.SECRET = key.config.secret
}
}
+2 -2
View File
@@ -34,7 +34,7 @@
return
}
let filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.codeName
let filePath = bot.dataMine + "/" + "bots" + "/" + bot.processNode.referenceParent.parentNode.config.repo + "/" + pProcessConfig.codeName
filePath += "/User.Bot.js"
fileStorage.getTextFile(filePath, onBotDownloaded);
@@ -56,7 +56,7 @@
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo;
filePath = bot.dataMine + "/" + "bots" + "/" + bot.processNode.referenceParent.parentNode.config.repo;
filePath += "/Commons.js"
fileStorage.getTextFile(filePath, onCommonsDownloaded);
+88 -41
View File
@@ -20,7 +20,7 @@
finalize: finalize,
load: load,
save: save,
asyncSave: asyncSave,
asyncSave: asyncSave,
status: undefined
};
@@ -111,50 +111,97 @@
for (let i = 0; i < network.networkNodes.length; i++) {
let networkNode = network.networkNodes[i]
if (checkThisBranch(networkNode.dataMining) === true) { return }
if (checkThisBranch(networkNode.testingEnvironment) === true) { return }
if (checkThisBranch(networkNode.productionEnvironment) === true) { return }
if (checkThisDataBranch(networkNode.dataMining) === true) { return }
if (checkThisTradingBranch(networkNode.testingEnvironment) === true) { return }
if (checkThisTradingBranch(networkNode.productionEnvironment) === true) { return }
function checkThisBranch(branch) {
function checkThisDataBranch(branch) {
if (branch === undefined) { return }
for (let j = 0; j < branch.exchangeTasks.length; j++) {
let exchangeTasks = branch.exchangeTasks[j]
for (let k = 0; k < exchangeTasks.taskManagers.length; k++) {
let taskManager = exchangeTasks.taskManagers[k]
for (let m = 0; m < taskManager.tasks.length; m++) {
let task = taskManager.tasks[m]
if (task.bot !== undefined) {
for (let n = 0; n < task.bot.processes.length; n++) {
let process = task.bot.processes[n]
if (process.marketReference !== undefined) {
if (process.marketReference.referenceParent !== undefined) {
let market = process.marketReference.referenceParent
let currentProcessMarket = bot.processNode.marketReference.referenceParent
if (currentProcessMarket.id === market.id) {
if (process.referenceParent !== undefined) {
let processDefinition = process.referenceParent
if (processThisDependsOn.id === processDefinition.id) {
if (process.type === 'Trading Process Instance') {
if (process.session !== undefined) {
if (bot.processNode.session.id !== process.session.id) {
continue
}
} else {
continue
}
}
/* We found where the task that runs the process definition this status report depends on and where it is located on the network. */
thisObject.networkNode = networkNode
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] initialize -> Retrieving status report from " + networkNode.name + " -> host = " + networkNode.config.host + ' -> port = ' + networkNode.config.webPort + '.'); }
fileStorage = FILE_STORAGE.newFileStorage(logger, networkNode.config.host, networkNode.config.webPort);
callBackFunction(global.DEFAULT_OK_RESPONSE);
return true
for (let j = 0; j < branch.exchangeDataTasks.length; j++) {
let exchangeTasks = branch.exchangeDataTasks[j]
for (let p = 0; p < exchangeTasks.marketDataTasks.length; p++) {
let marketTasks = exchangeTasks.marketDataTasks[p]
if (marketTasks.referenceParent === undefined) { continue }
if (marketTasks.referenceParent.id !== global.MARKET_NODE.id) { continue }
for (let q = 0; q < marketTasks.dataMineTasks.length; q++) {
let mineTasks = marketTasks.dataMineTasks[q]
for (let k = 0; k < mineTasks.taskManagers.length; k++) {
let taskManager = mineTasks.taskManagers[k]
for (let m = 0; m < taskManager.tasks.length; m++) {
let task = taskManager.tasks[m]
if (task.bot === undefined) { continue }
for (let n = 0; n < task.bot.processes.length; n++) {
let process = task.bot.processes[n]
if (process.referenceParent === undefined) { continue }
let processDefinition = process.referenceParent
if (processThisDependsOn.id === processDefinition.id) {
if (process.type === 'Trading Process Instance') {
if (process.session !== undefined) {
if (bot.processNode.session.id !== process.session.id) {
continue
}
} else {
continue
}
}
/*
We found where the task that runs the process definition this status report depends on
and where it is located on the network.
*/
thisObject.networkNode = networkNode
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] initialize -> Retrieving status report from " + networkNode.name + " -> host = " + networkNode.config.host + ' -> port = ' + networkNode.config.webPort + '.'); }
fileStorage = FILE_STORAGE.newFileStorage(logger, networkNode.config.host, networkNode.config.webPort);
callBackFunction(global.DEFAULT_OK_RESPONSE);
return true
}
}
}
}
}
}
}
}
function checkThisTradingBranch(branch) {
if (branch === undefined) { return }
for (let j = 0; j < branch.exchangeTradingTasks.length; j++) {
let exchangeTasks = branch.exchangeTradingTasks[j]
for (let p = 0; p < exchangeTasks.marketTradingTasks.length; p++) {
let marketTasks = exchangeTasks.marketTradingTasks[p]
if (marketTasks.referenceParent === undefined) { continue }
if (marketTasks.referenceParent.id !== global.MARKET_NODE.id) { continue }
for (let q = 0; q < marketTasks.tradingMineTasks.length; q++) {
let mineTasks = marketTasks.tradingMineTasks[q]
for (let k = 0; k < mineTasks.taskManagers.length; k++) {
let taskManager = mineTasks.taskManagers[k]
for (let m = 0; m < taskManager.tasks.length; m++) {
let task = taskManager.tasks[m]
if (task.bot === undefined) { continue }
for (let n = 0; n < task.bot.processes.length; n++) {
let process = task.bot.processes[n]
if (process.referenceParent === undefined) { continue }
let processDefinition = process.referenceParent
if (processThisDependsOn.id === processDefinition.id) {
if (process.type === 'Trading Process Instance') {
if (process.session !== undefined) {
if (bot.processNode.session.id !== process.session.id) {
continue
}
} else {
continue
}
}
/*
We found where the task that runs the process definition this status report depends on
and where it is located on the network.
*/
thisObject.networkNode = networkNode
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] initialize -> Retrieving status report from " + networkNode.name + " -> host = " + networkNode.config.host + ' -> port = ' + networkNode.config.webPort + '.'); }
fileStorage = FILE_STORAGE.newFileStorage(logger, networkNode.config.host, networkNode.config.webPort);
callBackFunction(global.DEFAULT_OK_RESPONSE);
return true
}
}
}
@@ -355,7 +402,7 @@
let response = await fileStorage.asyncCreateTextFile(filePath, fileContent + '\n', true)
if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) {
throw(response.err)
throw (response.err)
}
/* All good, lets emit the event that means data has been updated. */
+34 -22
View File
@@ -482,73 +482,85 @@ function bootLoader() {
/* Validate that the minimun amount of input required are defined. */
if (global.TASK_NODE.bot.processes[processIndex].marketReference === undefined) {
console.log("[WARN] Task Server -> server -> bootLoader -> Process Instance without a Market Reference. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
if (global.TASK_NODE.parentNode === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Task without a Task Manager. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent === undefined) {
console.log("[WARN] Task Server -> server -> bootLoader -> Market Reference without a Reference Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].marketReference) + ", bot = " + global.TASK_NODE.bot.name);
if (global.TASK_NODE.parentNode.parentNode === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Task Manager without Mine Tasks. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.parentNode === undefined) {
console.log("[WARN] Task Server -> server -> bootLoader -> Market without a Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent));
if (global.TASK_NODE.parentNode.parentNode.parentNode === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Mine Tasks without Market Tasks. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.parentNode.parentNode === undefined) {
console.log("[WARN] Task Server -> server -> bootLoader -> Exchange Markets without a Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.parentNode));
if (global.TASK_NODE.parentNode.parentNode.parentNode.referenceParent === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Market Tasks without a Market. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.baseAsset === undefined) {
console.log("[WARN] Task Server -> server -> bootLoader -> Market without a Base Asset. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent));
global.MARKET_NODE = global.TASK_NODE.parentNode.parentNode.parentNode.referenceParent
if (global.MARKET_NODE.parentNode === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Market without a Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.quotedAsset === undefined) {
console.log("[WARN] Task Server -> server -> bootLoader -> Market without a Quoted Asset. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent));
if (global.MARKET_NODE.parentNode.parentNode === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Exchange Markets without a Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE.parentNode));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.baseAsset.referenceParent === undefined) {
console.log("[WARN] Task Server -> server -> bootLoader -> Base Asset without a Reference Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.baseAsset));
if (global.MARKET_NODE.baseAsset === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Market without a Base Asset. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.quotedAsset.referenceParent === undefined) {
console.log("[WARN] Task Server -> server -> bootLoader -> Quoted Asset without a Reference Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].marketReference.referenceParent.quotedAsset));
if (global.MARKET_NODE.quotedAsset === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Market without a Quoted Asset. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE));
continue
}
if (global.MARKET_NODE.baseAsset.referenceParent === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Base Asset without a Reference Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE.baseAsset));
continue
}
if (global.MARKET_NODE.quotedAsset.referenceParent === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Quoted Asset without a Reference Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE.quotedAsset));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].referenceParent === undefined) {
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]));
console.log("[ERROR] 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("[WARN] Task Server -> server -> bootLoader -> Process Definition without parent Bot Definition. -> Process Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent));
console.log("[ERROR] 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("[WARN] Task Server -> server -> bootLoader -> Bot Definition without parent Data Mine. -> Bot Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode));
console.log("[ERROR] Task Server -> server -> bootLoader -> Bot Definition without parent Data Mine. -> Bot Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName === undefined) {
console.log("[WARN] Task Server -> server -> bootLoader -> Process Definition without a codeName defined. -> Process Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent));
console.log("[ERROR] 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.config.codeName === undefined) {
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));
console.log("[ERROR] 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.config.codeName === undefined) {
console.log("[WARN] Task Server -> server -> bootLoader -> Data Mine without a codeName defined. -> Data Mine Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode));
console.log("[ERROR] Task Server -> server -> bootLoader -> Data Mine without a codeName defined. -> Data Mine Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode));
continue
}