Missing Time Machines

This commit is contained in:
Luis Fernando Molina committed 2020-09-14 15:16:55 +02:00
1 parent aa915c9baf
commit 11da081248
9 files changed
+162 -27

No files matched your search

+1 -1
View File
@@ -144,7 +144,7 @@ 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', false, true, true, true)
let sessionReference = findNodeInNodeMesh(layer.definition, 'Session Reference', undefined, false, true, true, true)
if (sessionReference !== undefined) {
session = sessionReference.referenceParent
@@ -1,11 +1,12 @@
function newChartingSpaceFunctions() {
thisObject = {
addAllDataMineLayers: addAllDataMineLayers
addAllMineLayers: addAllMineLayers,
addMissingTimeMachines: addMissingTimeMachines
}
return thisObject
function addAllDataMineLayers(node, functionLibraryUiObjectsFromNodes) {
function addAllMineLayers(node, functionLibraryUiObjectsFromNodes) {
/* Validations to see if we can do this or not. */
if (node.payload === undefined) { return }
@@ -47,4 +48,117 @@ function newChartingSpaceFunctions() {
}
}
}
function addMissingTimeMachines(node, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter) {
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === 'Network') {
let networkNode = rootNode
scanNetworkNode(networkNode)
}
}
function scanNetworkNode(networkNode) {
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')
scanSessionArray(backtestingSessionsArray)
scanSessionArray(fordwardTestingSessionsArray)
scanSessionArray(paperTradingSessionsArray)
scanSessionArray(liveTradingSessionsArray)
function scanSessionArray(sessionsArray) {
for (let i = 0; i < sessionsArray.length; i++) {
let session = sessionsArray[i]
if (isMissingChildren(node, session, true) === true) {
let mineProducts
let timeMachine = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Time Machine')
timeMachine.payload.referenceParent = session
timeMachine.name = session.name
timeMachine.payload.floatingObject.collapseToggle()
/*
We need to create a Timeline Chart for each Data Mine Indicators.
*/
mineProducts = nodeBranchToArray(networkNode, 'Data Mine Products')
for (let j = 0; j < mineProducts.length; j++) {
let mineProduct = mineProducts[j]
let timelineChart = functionLibraryUiObjectsFromNodes.addUIObject(timeMachine, 'Timeline Chart')
timelineChart.name = mineProduct.name
timelineChart.layersManager.payload.referenceParent = mineProduct
timelineChart.payload.floatingObject.collapseToggle()
timelineChart.layersManager.payload.floatingObject.collapseToggle()
let menu = timelineChart.layersManager.payload.uiObject.menu
menu.internalClick('Add All Mine Layers')
menu.internalClick('Add All Mine Layers')
}
mineProducts = nodeBranchToArray(networkNode, 'Trading Mine Products')
for (let j = 0; j < mineProducts.length; j++) {
let mineProduct = mineProducts[j]
/*
The mine products found so far, belongs to any session. To filer all the sessions
that are not the one we are interested in, we do the following:
*/
if (mineProduct.payload.parentNode === undefined) { continue }
if (mineProduct.payload.parentNode.payload.referenceParent === undefined) { continue }
if (mineProduct.payload.parentNode.payload.parentNode.payload.referenceParent === undefined) { continue }
if (mineProduct.payload.parentNode.payload.parentNode.payload.referenceParent.id !== session.id) { continue }
/*
At the current version of Superalgos, beta 6, there is only one Trading Mine,
with only one bot, and it has so many data products that we want to put them
in 3 different timeline charts. So we will create 3 charts, connect them,
and delete from each one 1/3 of the layers. We do all that next:
*/
for (let k = 0; k < 3; k++) {
let timelineChart = functionLibraryUiObjectsFromNodes.addUIObject(timeMachine, 'Timeline Chart')
timelineChart.layersManager.payload.referenceParent = mineProduct
timelineChart.payload.floatingObject.collapseToggle()
timelineChart.layersManager.payload.floatingObject.collapseToggle()
let menu = timelineChart.layersManager.payload.uiObject.menu
menu.internalClick('Add All Mine Layers')
menu.internalClick('Add All Mine Layers')
switch (k) {
case 0: {
timelineChart.name = 'Trading Engine'
deleteNodeByName('Trading System')
deleteNodeByName('Objects')
break
}
case 1: {
timelineChart.name = 'Trading System'
deleteNodeByName('Trading Engine')
deleteNodeByName('Objects')
break
}
case 2: {
timelineChart.name = 'Objects'
deleteNodeByName('Trading Engine')
deleteNodeByName('Trading System')
break
}
}
function deleteNodeByName(nodeName) {
let nodeToDelete = findNodeInNodeMesh(timelineChart.layersManager, undefined, nodeName, true, true, false, false)
if (nodeToDelete === undefined) { return }
functionLibraryNodeDeleter.deleteUIObject(nodeToDelete, rootNodes)
}
}
}
}
}
}
}
}
}
@@ -41,6 +41,7 @@ function newDataStorageFunctions() {
let bot = botArray[i]
let botProducts = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Bot Products')
botProducts.name = bot.name
botProducts.payload.floatingObject.collapseToggle()
asymetricalFolderStructureCloning(
bot,
@@ -80,7 +81,7 @@ function newDataStorageFunctions() {
}
function addMissingSessionReferences(node, rootNodes, functionLibraryUiObjectsFromNodes) {
let networkNode = findNodeInNodeMesh(node, 'Network Node', true, false, true, false)
let networkNode = findNodeInNodeMesh(node, 'Network Node', undefined, true, false, true, false)
if (networkNode === undefined) { return }
let backtestingSessionsArray = nodeBranchToArray(networkNode, 'Backtesting Session')
@@ -103,8 +104,10 @@ function newDataStorageFunctions() {
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)
let marketTradingTasks = findNodeInNodeMesh(session, 'Market Trading Tasks', undefined, true, false, true, false)
sessionReference.singleMarketTradingData.payload.referenceParent = marketTradingTasks.payload.referenceParent
timelineChart.payload.floatingObject.collapseToggle()
timelineChart.singleMarketTradingData.payload.floatingObject.collapseToggle()
}
}
}
@@ -493,7 +493,7 @@ function newTaskFunctions() {
let task = functionLibraryUiObjectsFromNodes.addUIObject(taskManager, 'Task')
if (tradingSystem !== undefined) {
task.name = tradingSystem.name + ' ' + bot.name
task.name = tradingSystem.name
} else {
task.name = bot.name
}
@@ -558,7 +558,7 @@ function newTaskFunctions() {
function addSession(sessionType) {
session = functionLibraryUiObjectsFromNodes.addUIObject(processInstance, sessionType)
session.name = task.name + ' ' + session.type
session.name = task.name
let config = JSON.parse(session.config)
config.folderName = session.name.split(" ").join("-")
session.config = JSON.stringify(config)
+7 -2
View File
@@ -740,9 +740,14 @@ function newWorkspace() {
functionLibraryDataMineFunctions.addAllDataMineDataDependencies(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Data Mine Layers':
case 'Add All Mine Layers':
{
functionLibraryChartingSpaceFunctions.addAllDataMineLayers(payload.node, functionLibraryUiObjectsFromNodes)
functionLibraryChartingSpaceFunctions.addAllMineLayers(payload.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Time Machines':
{
functionLibraryChartingSpaceFunctions.addMissingTimeMachines(payload.node, thisObject.workspaceNode.rootNodes,functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
}
break
case 'Play Tutorial':
+1
View File
@@ -309,6 +309,7 @@ function newUiObject() {
function invisiblePhysics() {
thisObject.menu.invisiblePhysics()
childrenRunningPhysics()
thisObject.uiObjectTitle.physics()
}
function physics() {
+13 -13
View File
@@ -205,49 +205,49 @@ function newLayer() {
}
/* Here we validate that we have all the needed information */
if (findNodeInNodeMesh(thisObject.definition, 'Data Product', false, true, true, true) === undefined) {
if (findNodeInNodeMesh(thisObject.definition, 'Data Product', undefined, false, true, true, true) === undefined) {
thisObject.payload.uiObject.setErrorMessage('Data Product not Found')
return
}
if (findNodeInNodeMesh(thisObject.definition, 'Market', false, true, true, true) === undefined) {
if (findNodeInNodeMesh(thisObject.definition, 'Market', undefined, false, true, true, true) === undefined) {
thisObject.payload.uiObject.setErrorMessage('Market not Found')
return
}
thisObject.productDefinition = findNodeInNodeMesh(thisObject.definition, 'Product Definition', false, true, true, true)
thisObject.productDefinition = findNodeInNodeMesh(thisObject.definition, 'Product Definition', undefined, false, true, true, true)
if (thisObject.productDefinition === undefined) {
thisObject.payload.uiObject.setErrorMessage('Product Definition not Found')
return
}
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Sensor Bot', false, true, true, true)
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Sensor Bot', undefined, false, true, true, true)
if (thisObject.bot === undefined) {
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Indicator Bot', false, true, true, true)
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Indicator Bot', undefined, false, true, true, true)
}
if (thisObject.bot === undefined) {
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Trading Bot', false, true, true, true)
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Trading Bot', undefined, false, true, true, true)
}
if (thisObject.bot === undefined) {
thisObject.payload.uiObject.setErrorMessage('Bot not Found')
return
}
thisObject.dataMine = findNodeInNodeMesh(thisObject.definition, 'Data Mine', false, true, true, true)
thisObject.dataMine = findNodeInNodeMesh(thisObject.definition, 'Data Mine', undefined, false, true, true, true)
if (thisObject.dataMine === undefined) {
thisObject.dataMine = findNodeInNodeMesh(thisObject.definition, 'Trading Mine', false, true, true, true)
thisObject.dataMine = findNodeInNodeMesh(thisObject.definition, 'Trading Mine', undefined, 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', false, true, true, true)
thisObject.exchange = findNodeInNodeMesh(thisObject.definition, 'Crypto Exchange', undefined, 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', false, true, true, true)
thisObject.baseAsset = findNodeInNodeMesh(thisObject.definition, 'Market Base Asset', undefined, false, true, true, true)
if (thisObject.baseAsset !== undefined) {
thisObject.baseAsset = thisObject.baseAsset.referenceParent
}
@@ -256,7 +256,7 @@ function newLayer() {
return
}
thisObject.quotedAsset = findNodeInNodeMesh(thisObject.definition, 'Market Quoted Asset', false, true, true, true)
thisObject.quotedAsset = findNodeInNodeMesh(thisObject.definition, 'Market Quoted Asset', undefined, false, true, true, true)
if (thisObject.quotedAsset !== undefined) {
thisObject.quotedAsset = thisObject.quotedAsset.referenceParent
}
@@ -265,13 +265,13 @@ function newLayer() {
return
}
thisObject.plotterModule = findNodeInNodeMesh(thisObject.definition, 'Plotter Module', false, true, true, true)
thisObject.plotterModule = findNodeInNodeMesh(thisObject.definition, 'Plotter Module', undefined, 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', false, true, true, true)
thisObject.networkNode = findNodeInNodeMesh(thisObject.definition, 'Network Node', undefined, false, true, true, true)
if (thisObject.networkNode === undefined) {
thisObject.payload.uiObject.setErrorMessage('Network Node not Found')
return
+2
View File
@@ -40,3 +40,5 @@ function nodeBranchToArray(node, nodeType) {
}
}
}
+15 -5
View File
@@ -1,7 +1,8 @@
function findNodeInNodeMesh(node, nodeType, connectedViaPayload, findInChildren, findInParents, findInReferenceParents) {
function findNodeInNodeMesh(node, nodeType, nodeName, connectedViaPayload, findInChildren, findInParents, findInReferenceParents) {
/*
This function scans a node mesh for a certain node type and
returns the first instance found.
returns the first instance found. Please specify either nodeType
or nodeName.
*/
let nodeFound
scanNodeMesh(node)
@@ -14,9 +15,18 @@ function findNodeInNodeMesh(node, nodeType, connectedViaPayload, findInChildren,
let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type)
if (nodeDefinition === undefined) { return }
if (startingNode.type === nodeType) {
nodeFound = startingNode
return
if (nodeType !== undefined) {
if (startingNode.type === nodeType) {
nodeFound = startingNode
return
}
}
if (nodeName !== undefined) {
if (startingNode.name === nodeName) {
nodeFound = startingNode
return
}
}
/* We scan through this node children */