From ef251bee801842faf8c00de20b02e227074a8d0e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 29 Jan 2021 14:25:43 +0100 Subject: [PATCH 1/3] docs.reindex command improved, more responsive UI while reindexing --- .../UI/Spaces/Design-Space/Workspace.js | 34 ++-- .../UI/Spaces/Docs-Space/CommandInterface.js | 6 +- .../UI/Spaces/Docs-Space/SearchEngine.js | 174 +++++++++++------- 3 files changed, 133 insertions(+), 81 deletions(-) diff --git a/Projects/Superalgos/UI/Spaces/Design-Space/Workspace.js b/Projects/Superalgos/UI/Spaces/Design-Space/Workspace.js index 50527b2d0..b86c5b947 100644 --- a/Projects/Superalgos/UI/Spaces/Design-Space/Workspace.js +++ b/Projects/Superalgos/UI/Spaces/Design-Space/Workspace.js @@ -108,17 +108,19 @@ function newWorkspace() { UI.projects.superalgos.utilities.statusBar.changeStatus("Setting up Docs Search Engine...") setTimeout(theEnd, 100) function theEnd() { - UI.projects.superalgos.spaces.docsSpace.searchEngine.setUpSearchEngine() + UI.projects.superalgos.spaces.docsSpace.searchEngine.setUpSearchEngine(onIndexingFinished) - setupEventsServerClients() - runTasksAndSessions() - thisObject.enabled = true - UI.projects.superalgos.spaces.cockpitSpace.initializePosition() - CAN_SPACES_DRAW = true + function onIndexingFinished() { + setupEventsServerClients() + runTasksAndSessions() + thisObject.enabled = true + UI.projects.superalgos.spaces.cockpitSpace.initializePosition() + CAN_SPACES_DRAW = true - thisObject.isInitialized = true - savingWorkspaceIntervalId = setInterval(saveWorkspace, 60000) - UI.projects.superalgos.utilities.statusBar.changeStatus("Displaying the UI...") + thisObject.isInitialized = true + savingWorkspaceIntervalId = setInterval(saveWorkspace, 60000) + UI.projects.superalgos.utilities.statusBar.changeStatus("Displaying the UI...") + } } } } catch (err) { @@ -368,12 +370,14 @@ function newWorkspace() { workingAtTask = 0 function takeAction() { - UI.projects.superalgos.spaces.docsSpace.reset() - UI.projects.superalgos.spaces.docsSpace.searchEngine.setUpSearchEngine() // The docs needs to index the loaded workspace. - UI.projects.superalgos.spaces.floatingSpace.inMapMode = false - thisObject.isInitialized = true - saveWorkspace() - runTasksAndSessions() + UI.projects.superalgos.spaces.docsSpace.reset() + UI.projects.superalgos.spaces.docsSpace.searchEngine.setUpSearchEngine(onIndexingFinished) // The docs needs to index the loaded workspace. + function onIndexingFinished() { + UI.projects.superalgos.spaces.floatingSpace.inMapMode = false + thisObject.isInitialized = true + saveWorkspace() + runTasksAndSessions() + } } break } diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index 864371019..d039c7372 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -468,9 +468,11 @@ function newSuperalgosDocsCommmandInterface() { setTimeout(startReindexingProcess, 100) function startReindexingProcess() { - UI.projects.superalgos.spaces.docsSpace.searchEngine.setUpSearchEngine() + UI.projects.superalgos.spaces.docsSpace.searchEngine.setUpSearchEngine(onFinish) - UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Message - Reindexing Done') + function onFinish() { + UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Message - Reindexing Done') + } } } diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js b/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js index 8b6c3659d..101ce7823 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js @@ -16,7 +16,10 @@ function newSuperalgosDocsSearchEngine() { thisObject.docsIndex = undefined } - function setUpSearchEngine() { + function setUpSearchEngine(callbackFunction) { + + let totalAsyncCallsMade = 0 + let totalAsyncCallsFinished = 0 setUpWorkspaceSchemas() thisObject.docsIndex = [] @@ -26,82 +29,125 @@ function newSuperalgosDocsSearchEngine() { let documentIndex - /* Search in Nodes */ - for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsNodeSchema.length; i++) { - documentIndex = { - phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. - docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsNodeSchema[i], - category: 'Node', - project: project + totalAsyncCallsMade++ + setTimeout(searchInNodes, 0) + totalAsyncCallsMade++ + setTimeout(searchInConcepts, 0) + totalAsyncCallsMade++ + setTimeout(searchInNTopics, 0) + totalAsyncCallsMade++ + setTimeout(searchInTutorials, 0) + totalAsyncCallsMade++ + setTimeout(searchInReviews, 0) + totalAsyncCallsMade++ + setTimeout(searchInBooks, 0) + totalAsyncCallsMade++ + setTimeout(searchInWorkspaces, 0) + + function searchInNodes() { + /* Search in Nodes */ + for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsNodeSchema.length; i++) { + documentIndex = { + phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. + docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsNodeSchema[i], + category: 'Node', + project: project + } + indexDocument(documentIndex) + thisObject.docsIndex.push(documentIndex) } - indexDocument(documentIndex) - thisObject.docsIndex.push(documentIndex) + asyncCallFinished() } - /* Search in Concepts */ - for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsConceptSchema.length; i++) { - documentIndex = { - phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. - docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsConceptSchema[i], - category: 'Concept', - project: project + function searchInConcepts() { + /* Search in Concepts */ + for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsConceptSchema.length; i++) { + documentIndex = { + phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. + docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsConceptSchema[i], + category: 'Concept', + project: project + } + indexDocument(documentIndex) + thisObject.docsIndex.push(documentIndex) } - indexDocument(documentIndex) - thisObject.docsIndex.push(documentIndex) + asyncCallFinished() } - /* Search in Topics */ - for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsTopicSchema.length; i++) { - documentIndex = { - phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. - docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsTopicSchema[i], - category: 'Topic', - project: project + function searchInNTopics() { + /* Search in Topics */ + for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsTopicSchema.length; i++) { + documentIndex = { + phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. + docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsTopicSchema[i], + category: 'Topic', + project: project + } + indexDocument(documentIndex) + thisObject.docsIndex.push(documentIndex) } - indexDocument(documentIndex) - thisObject.docsIndex.push(documentIndex) + asyncCallFinished() } - /* Search in Tutorials */ - for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema.length; i++) { - documentIndex = { - phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. - docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema[i], - category: 'Tutorial', - project: project + function searchInTutorials() { + /* Search in Tutorials */ + for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema.length; i++) { + documentIndex = { + phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. + docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema[i], + category: 'Tutorial', + project: project + } + indexDocument(documentIndex) + thisObject.docsIndex.push(documentIndex) } - indexDocument(documentIndex) - thisObject.docsIndex.push(documentIndex) + asyncCallFinished() } - /* Search in Reviews */ - for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema.length; i++) { - documentIndex = { - phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. - docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema[i], - category: 'Review', - project: project + function searchInReviews() { + /* Search in Reviews */ + for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema.length; i++) { + documentIndex = { + phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. + docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema[i], + category: 'Review', + project: project + } + indexDocument(documentIndex) + thisObject.docsIndex.push(documentIndex) } - indexDocument(documentIndex) - thisObject.docsIndex.push(documentIndex) + asyncCallFinished() } - /* Search in Books */ - for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema.length; i++) { - documentIndex = { - phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. - docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema[i], - category: 'Book', - project: project + function searchInBooks() { + /* Search in Books */ + for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema.length; i++) { + documentIndex = { + phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. + docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema[i], + category: 'Book', + project: project + } + indexDocument(documentIndex) + thisObject.docsIndex.push(documentIndex) } - indexDocument(documentIndex) - thisObject.docsIndex.push(documentIndex) + asyncCallFinished() } - /* Search in Workspace */ - for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.workspaceSchema.length; i++) { - documentIndex = { - phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. - docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.workspaceSchema[i], - category: 'Workspace', - project: project + function searchInWorkspaces() { + /* Search in Workspace */ + for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.workspaceSchema.length; i++) { + documentIndex = { + phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. + docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.workspaceSchema[i], + category: 'Workspace', + project: project + } + indexDocument(documentIndex) + thisObject.docsIndex.push(documentIndex) + } + asyncCallFinished() + } + + function asyncCallFinished() { + totalAsyncCallsFinished++ + if (totalAsyncCallsMade === totalAsyncCallsFinished) { + callbackFunction() } - indexDocument(documentIndex) - thisObject.docsIndex.push(documentIndex) } } From faff4a1b3a291a3bc75394a66683788fc4809704 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 29 Jan 2021 16:30:13 +0100 Subject: [PATCH 2/3] Bug Fixed Candle Panel Not Showing it's content. --- Projects/Superalgos/UI/Spaces/Panel-Space/PanelSpace.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Projects/Superalgos/UI/Spaces/Panel-Space/PanelSpace.js b/Projects/Superalgos/UI/Spaces/Panel-Space/PanelSpace.js index c8b2ee86f..d0a58ab2c 100644 --- a/Projects/Superalgos/UI/Spaces/Panel-Space/PanelSpace.js +++ b/Projects/Superalgos/UI/Spaces/Panel-Space/PanelSpace.js @@ -49,14 +49,16 @@ function newSuperalgosPanelSpace() { } case 'Plotter Panel': { - if (pParameters.panelNode.config.isLegacy !== true) { + let panelConfig = JSON.parse(pParameters.panelNode.config) + + if (panelConfig.isLegacy !== true) { panel = newPlotterPanel() panel.fitFunction = UI.projects.superalgos.spaces.chartingSpace.fitFunction panel.container.isVisibleFunction = UI.projects.superalgos.spaces.chartingSpace.isThisPointVisible panel.session = pSession panel.initialize(pParameters.panelNode) } else { - panel = getNewPlotterPanel(pParameters.mine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelNode.config.codeName) + panel = getNewPlotterPanel(pParameters.mine, pParameters.plotterCodeName, pParameters.moduleCodeName, panelConfig.codeName) panel.fitFunction = UI.projects.superalgos.spaces.chartingSpace.fitFunction panel.container.isVisibleFunction = UI.projects.superalgos.spaces.chartingSpace.isThisPointVisible panel.session = pSession From c1cddc688357a055ea8751b2ded34a43ebcd4dce Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 29 Jan 2021 18:30:12 +0100 Subject: [PATCH 3/3] Switch between Trading Sessions --- Projects/Superalgos/Schemas/AppSchema.json | 24 +++++++++++++++++ .../UI/Function-Libraries/ActionSwitch.js | 26 ++++++++++++++++++- .../UI/Function-Libraries/NodeDeleter.js | 1 - .../Function-Libraries/UiObjectsFromNodes.js | 7 ----- .../UI/Spaces/Floating-Space/FloatingLayer.js | 12 +++++++++ .../UI/Spaces/Floating-Space/UiObject.js | 2 +- .../Floating-Space/UiObjectConstructor.js | 12 +++++++++ 7 files changed, 74 insertions(+), 10 deletions(-) diff --git a/Projects/Superalgos/Schemas/AppSchema.json b/Projects/Superalgos/Schemas/AppSchema.json index d15025284..b509ef075 100644 --- a/Projects/Superalgos/Schemas/AppSchema.json +++ b/Projects/Superalgos/Schemas/AppSchema.json @@ -2839,6 +2839,12 @@ "relatedUiObject": "Trading Parameters", "actionFunction": "payload.executeAction" }, + { + "action": "Switch To Paper Trading", + "label": "Switch To Paper Trading", + "relatedUiObject": "Paper Trading Session", + "actionFunction": "payload.executeAction" + }, { "action": "Delete UI Object", "askConfirmation": true, @@ -10093,6 +10099,12 @@ "relatedUiObject": "Trading Parameters", "actionFunction": "payload.executeAction" }, + { + "action": "Switch To Backtesting", + "label": "Switch To Backtesting", + "relatedUiObject": "Backtesting Session", + "actionFunction": "payload.executeAction" + }, { "action": "Delete UI Object", "askConfirmation": true, @@ -10194,6 +10206,12 @@ "relatedUiObject": "Trading Parameters", "actionFunction": "payload.executeAction" }, + { + "action": "Switch To Live Trading", + "label": "Switch To Live Trading", + "relatedUiObject": "Live Trading Session", + "actionFunction": "payload.executeAction" + }, { "action": "Delete UI Object", "askConfirmation": true, @@ -10321,6 +10339,12 @@ "relatedUiObject": "Trading Parameters", "actionFunction": "payload.executeAction" }, + { + "action": "Switch To Forward Testing", + "label": "Switch To Forward Testing", + "relatedUiObject": "Forward Testing Session", + "actionFunction": "payload.executeAction" + }, { "action": "Delete UI Object", "askConfirmation": true, diff --git a/Projects/Superalgos/UI/Function-Libraries/ActionSwitch.js b/Projects/Superalgos/UI/Function-Libraries/ActionSwitch.js index 9fe670bcd..ab4716639 100644 --- a/Projects/Superalgos/UI/Function-Libraries/ActionSwitch.js +++ b/Projects/Superalgos/UI/Function-Libraries/ActionSwitch.js @@ -634,7 +634,7 @@ function newSuperalgosActionSwitch() { { let definition = getSchemaDocument(action.node) if (definition !== undefined) { - UI.projects.superalgos.spaces.docsSpace.openSpaceAreaAndNavigateTo(action.node.project,'Node', action.node.type) + UI.projects.superalgos.spaces.docsSpace.openSpaceAreaAndNavigateTo(action.node.project, 'Node', action.node.type) } } break @@ -678,6 +678,30 @@ function newSuperalgosActionSwitch() { UI.projects.superalgos.functionLibraries.workspaceFunctions.addMissingWorkspaceProjects(action.node, action.rootNodes) } break + case 'Switch To Forward Testing': + { + action.node.type = "Forward Testing Session" + UI.projects.superalgos.spaces.floatingSpace.uiObjectConstructor.createUiObject(true, action.node.payload) + } + break + case 'Switch To Live Trading': + { + action.node.type = "Live Trading Session" + UI.projects.superalgos.spaces.floatingSpace.uiObjectConstructor.createUiObject(true, action.node.payload) + } + break + case 'Switch To Paper Trading': + { + action.node.type = "Paper Trading Session" + UI.projects.superalgos.spaces.floatingSpace.uiObjectConstructor.createUiObject(true, action.node.payload) + } + break + case 'Switch To Backtesting': + { + action.node.type = "Backtesting Session" + UI.projects.superalgos.spaces.floatingSpace.uiObjectConstructor.createUiObject(true, action.node.payload) + } + break } } } diff --git a/Projects/Superalgos/UI/Function-Libraries/NodeDeleter.js b/Projects/Superalgos/UI/Function-Libraries/NodeDeleter.js index 864825d20..769966af1 100644 --- a/Projects/Superalgos/UI/Function-Libraries/NodeDeleter.js +++ b/Projects/Superalgos/UI/Function-Libraries/NodeDeleter.js @@ -156,7 +156,6 @@ function newSuperalgosFunctionLibraryNodeDeleter() { node.payload.targetPosition.x = undefined node.payload.targetPosition.y = undefined node.payload.visible = undefined - node.payload.subTitle = undefined node.payload.title = undefined node.payload.node = undefined node.payload.parentNode = undefined diff --git a/Projects/Superalgos/UI/Function-Libraries/UiObjectsFromNodes.js b/Projects/Superalgos/UI/Function-Libraries/UiObjectsFromNodes.js index bfd05f2d8..397e603ea 100644 --- a/Projects/Superalgos/UI/Function-Libraries/UiObjectsFromNodes.js +++ b/Projects/Superalgos/UI/Function-Libraries/UiObjectsFromNodes.js @@ -641,13 +641,6 @@ function newSuperalgosFunctionLibraryUiObjectsFromNodes() { } } - /* Setting the title */ - if (title !== undefined) { - payload.subTitle = title - } else { - payload.subTitle = uiObjectType - } - payload.visible = true payload.title = name payload.node = node diff --git a/Projects/Superalgos/UI/Spaces/Floating-Space/FloatingLayer.js b/Projects/Superalgos/UI/Spaces/Floating-Space/FloatingLayer.js index fe4400c63..6b722352f 100644 --- a/Projects/Superalgos/UI/Spaces/Floating-Space/FloatingLayer.js +++ b/Projects/Superalgos/UI/Spaces/Floating-Space/FloatingLayer.js @@ -210,6 +210,12 @@ function newFloatingLayer() { let newInvisibleArray = [] for (let i = 0; i < invisibleFloatingObjects.length; i++) { let floatingObject = invisibleFloatingObjects[i] + + if (floatingObject.payload === undefined) { + /* The floating object was replaced by another one. */ + invisibleFloatingObjects.splice(i, 1) + return + } collapsePhysics(floatingObject) @@ -227,6 +233,12 @@ function newFloatingLayer() { for (let i = 0; i < visibleFloatingObjects.length; i++) { let floatingObject = visibleFloatingObjects[i] + if (floatingObject.payload === undefined) { + /* The floating object was replaced by another one. */ + visibleFloatingObjects.splice(i, 1) + return + } + collapsePhysics(floatingObject) if (floatingObject.isParentCollapsed === true) { diff --git a/Projects/Superalgos/UI/Spaces/Floating-Space/UiObject.js b/Projects/Superalgos/UI/Spaces/Floating-Space/UiObject.js index e297e2ebe..baa359708 100644 --- a/Projects/Superalgos/UI/Spaces/Floating-Space/UiObject.js +++ b/Projects/Superalgos/UI/Spaces/Floating-Space/UiObject.js @@ -1679,7 +1679,7 @@ function newUiObject() { if (radius > 6) { const MAX_LABEL_LENGTH = 30 - label = thisObject.payload.subTitle + label = thisObject.payload.node.type label = addIndexNumber(label) if (label !== undefined) { diff --git a/Projects/Superalgos/UI/Spaces/Floating-Space/UiObjectConstructor.js b/Projects/Superalgos/UI/Spaces/Floating-Space/UiObjectConstructor.js index f90321a4d..53d8b71e0 100644 --- a/Projects/Superalgos/UI/Spaces/Floating-Space/UiObjectConstructor.js +++ b/Projects/Superalgos/UI/Spaces/Floating-Space/UiObjectConstructor.js @@ -25,10 +25,22 @@ function newUiObjectConstructor() { } function createUiObject(userAddingNew, payload) { + + /* + In case we are replacing an existing uiObject and floatingObject + */ + if (payload.floatingObject !== undefined) { + payload.floatingObject.finalize() + } + if (payload.uiObject !== undefined) { + payload.uiObject.finalize() + } + let floatingObject = newFloatingObject() floatingObject.fitFunction = UI.projects.superalgos.spaces.floatingSpace.fitIntoVisibleArea floatingObject.container.connectToParent(UI.projects.superalgos.spaces.floatingSpace.container, false, false, false, false, false, false, false, false) floatingObject.initialize('UI Object', payload) + payload.floatingObject = floatingObject /*