From c85511158a5c6a3bc8292cd5841cf2ade3ef558f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 5 Jun 2020 11:20:46 +0200 Subject: [PATCH 01/48] Update SplashScreen.js --- SplashScreen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SplashScreen.js b/SplashScreen.js index 34b7c9589..6e7dfa436 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -125,7 +125,7 @@ function newSplashScreen () { fontSize = 35 - title = 'Beta 5' + title = 'Beta 6' titlePoint = { x: thisObject.container.frame.width / 2 - title.length / 2 * fontSize * FONT_ASPECT_RATIO - 20, From a20077f0b333fdef8d90229460e94874602251e5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 10 Jun 2020 12:21:53 +0200 Subject: [PATCH 02/48] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 41b4da779..36b781cf1 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -41,6 +41,7 @@ function newSessionFunctions () { lightingPath = '' + 'Trading Engine->' + + 'Dynamic Indicators->Indicator Function->Formula->' + 'Episode->Current->Last->Previous->' + 'Episode Counters->Episode Statistics->' + 'Periods->Positions->Hits->Fails->' + @@ -63,7 +64,7 @@ function newSessionFunctions () { lightingPath = '' + 'Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + 'Parameters->' + - 'Base Asset->Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->' + + 'Base Asset->Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->User Defined Parameters->' + 'Exchange Account Asset->Asset->' + 'Social Bots->Telegram Bot->' From df7e2acefb22e7222895024aed70cf98d8fd02bc Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 10 Jun 2020 14:09:34 +0200 Subject: [PATCH 03/48] Run Errors implemented --- FloatingSpace/UiObject.js | 72 ++++++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 16 deletions(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 00740dcd9..1ce03c594 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -33,6 +33,7 @@ function newUiObject () { showAvailabilityToReferenceAttach: showAvailabilityToReferenceAttach, highlight: highlight, setErrorMessage: setErrorMessage, + resetErrorMessage: resetErrorMessage, setValue: setValue, setPercentage: setPercentage, setStatus: setStatus, @@ -107,6 +108,7 @@ function newUiObject () { let currentStatus = '' let rightDragging = false + let eventSubscriptionIdOnError let eventSubscriptionIdOnRunning let eventSubscriptionIdOnStopped let lastHeartBeat @@ -178,6 +180,9 @@ function newUiObject () { if (eventSubscriptionIdOnStopped !== undefined) { eventsServerClient.stopListening(key, eventSubscriptionIdOnStopped, 'UiObject') } + if (eventSubscriptionIdOnError !== undefined) { + eventsServerClient.stopListening(key, eventSubscriptionIdOnError, 'UiObject') + } } } @@ -710,6 +715,11 @@ function newUiObject () { } } + function resetErrorMessage () { + errorMessage = undefined + hasError = false + } + function setValue (value, counter) { if (value !== undefined) { currentValue = value @@ -760,6 +770,7 @@ function newUiObject () { function run (pEventsServerClient, callBackFunction) { finalizeEventsServerClient() + resetErrorMessage() eventsServerClient = pEventsServerClient /* We setup the circular progress bar. */ @@ -772,7 +783,12 @@ function newUiObject () { thisObject.circularProgressBar.fitFunction = thisObject.fitFunction thisObject.circularProgressBar.container = thisObject.container - /* We will wait to hear the Running event in order to confirm the execution was really started */ + setupRunningEventListener(callBackFunction) + setupErrorEventListener(callBackFunction) + } + + function setupRunningEventListener (callBackFunction) { + /* We will wait to hear the Running event in order to confirm the execution was really started */ let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id eventsServerClient.listenToEvent(key, 'Running', undefined, 'UiObject', onResponse, onRunning) @@ -813,6 +829,24 @@ function newUiObject () { stop(callBackFunction, event) } + function setupErrorEventListener (callBackFunction) { + let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id + eventsServerClient.listenToEvent(key, 'Error', undefined, key, onResponse, onError) + + function onResponse (message) { + eventSubscriptionIdOnError = message.eventSubscriptionId + } + + function onError (message) { + setErrorMessage(message.event.errorMessage, 10) + + let event = { + type: 'Secondary Action Already Executed' + } + completeStop(callBackFunction, event) + } + } + function stop (callBackFunction, event) { /* We will wait to the event that the execution was terminated in order to call back the menu item */ let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id @@ -823,23 +857,29 @@ function newUiObject () { } function onStopped () { - if (thisObject.payload === undefined) { return } - if (callBackFunction !== undefined) { - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, event) - } - - if (thisObject.circularProgressBar !== undefined) { - thisObject.circularProgressBar.finalize() - thisObject.circularProgressBar = undefined - } - thisObject.isRunning = false - hasValue = false - hasPercentage = false - hasStatus = false - lastHeartBeat = undefined + completeStop(callBackFunction, event) } } + function completeStop (callBackFunction, event) { + if (thisObject.payload === undefined) { return } + if (callBackFunction !== undefined) { + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, event) + } + + if (thisObject.circularProgressBar !== undefined) { + thisObject.circularProgressBar.finalize() + thisObject.circularProgressBar = undefined + } + thisObject.isRunning = false + hasValue = false + hasPercentage = false + hasStatus = false + lastHeartBeat = undefined + + finalizeEventsServerClient() + } + function iconPhysics () { icon = canvas.designSpace.iconByUiObjectType.get(thisObject.payload.node.type) let nodeDefinition = getNodeDefinition(thisObject.payload.node) @@ -1291,7 +1331,7 @@ function newUiObject () { position = canvas.floatingSpace.transformPointToMap(position) } - let radius = thisObject.container.frame.radius * 3.5 + let radius = thisObject.container.frame.radius * 2.5 /* Label Text */ let labelPoint let fontSize = thisObject.payload.floatingObject.currentFontSize * 3 / 4 From 211adb1a67d567df3f702e0a1ee323b76f39e906 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 10 Jun 2020 15:15:34 +0200 Subject: [PATCH 04/48] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 36b781cf1..bc8d5c971 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -64,7 +64,7 @@ function newSessionFunctions () { lightingPath = '' + 'Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + 'Parameters->' + - 'Base Asset->Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->User Defined Parameters->' + + 'Session Base Asset->Session Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->User Defined Parameters->' + 'Exchange Account Asset->Asset->' + 'Social Bots->Telegram Bot->' From 4cfcba058983dda107d03d8fd1eac9dcd098c100 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 12 Jun 2020 10:06:37 +0200 Subject: [PATCH 05/48] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index bc8d5c971..8f6dc483a 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -47,6 +47,8 @@ function newSessionFunctions () { 'Periods->Positions->Hits->Fails->' + 'Profit Loss->Hit Ratio->Days->ROI->Anualized Rate Of Return->User Defined Statistic->' + 'Formula->' + + 'Candle->' + + 'Begin->End->Open->Close->Min->Max->Index->' + 'Balance->Base Asset->Quoted Asset->' + 'Distance To Event->' + 'Trigger On->Trigger Off->Take Position->Close Position->Next Phase->Move To Phase->' + From c79f2f2ce9ab8a60dbc879a9742f144dd137a34e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 14 Jun 2020 13:09:28 +0200 Subject: [PATCH 06/48] Update UiObject.js --- FloatingSpace/UiObject.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 1ce03c594..0e9f16202 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -732,6 +732,12 @@ function newUiObject () { } } + function resetValue () { + currentValue = undefined + hasValue = false + valueCounter = 0 + } + function setPercentage (percentage, counter) { if (percentage !== undefined) { currentPercentage = percentage @@ -744,6 +750,12 @@ function newUiObject () { } } + function resetPercentage () { + currentPercentage = undefined + hasPercentage = false + percentageCounter = 0 + } + function setStatus (status, counter) { if (status !== undefined) { currentStatus = status @@ -756,6 +768,12 @@ function newUiObject () { } } + function resetStatus () { + currentStatus = undefined + hasStatus = false + statusCounter = 0 + } + function heartBeat () { lastHeartBeat = new Date() thisObject.isRunning = true @@ -771,6 +789,9 @@ function newUiObject () { function run (pEventsServerClient, callBackFunction) { finalizeEventsServerClient() resetErrorMessage() + resetPercentage() + resetValue() + resetStatus() eventsServerClient = pEventsServerClient /* We setup the circular progress bar. */ From 31d10d09e07c86ce020e5d6c74e846a13fece918 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 15 Jun 2020 16:14:38 +0200 Subject: [PATCH 07/48] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 8f6dc483a..5c72a28a7 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -24,7 +24,7 @@ function newSessionFunctions () { 'Parameters->' + 'Base Asset->Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->' + 'Exchange Account Asset->Asset->' + - 'Strategy->' + + 'Trading Strategy->' + 'Trigger Stage->Trigger On Event->Trigger Off Event->Take Position Event->' + 'Announcement->Formula->' + 'Open Stage->Initial Definition->Open Execution->' + From 1ed6a48488e14b4e0aeda3a72e7e6df3a1aa2bdb Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 16 Jun 2020 12:16:40 +0200 Subject: [PATCH 08/48] Plotting Modules --- ChartingSpace/PlottersManager.js | 1 + FloatingSpace/UiObject.js | 9 ++++--- Plotting/NodesErrors.js | 36 +++++++++++++++++++++++++ Plotting/NodesHighlights.js | 33 +++++++++++++++++++++++ Plotting/NodesProgress.js | 32 ++++++++++++++++++++++ Plotting/NodesRunning.js | 36 +++++++++++++++++++++++++ Plotting/NodesStatus.js | 32 ++++++++++++++++++++++ Plotting/NodesValues.js | 32 ++++++++++++++++++++++ Plotter.js => Plotting/Plotter.js | 8 +++--- Utilities/RecursiveEvalNode.js | 45 +++++++++++++++++++++++++++++++ 10 files changed, 258 insertions(+), 6 deletions(-) create mode 100644 Plotting/NodesErrors.js create mode 100644 Plotting/NodesHighlights.js create mode 100644 Plotting/NodesProgress.js create mode 100644 Plotting/NodesRunning.js create mode 100644 Plotting/NodesStatus.js create mode 100644 Plotting/NodesValues.js rename Plotter.js => Plotting/Plotter.js (99%) create mode 100644 Utilities/RecursiveEvalNode.js diff --git a/ChartingSpace/PlottersManager.js b/ChartingSpace/PlottersManager.js index e660e48de..8348a4d7a 100644 --- a/ChartingSpace/PlottersManager.js +++ b/ChartingSpace/PlottersManager.js @@ -199,6 +199,7 @@ function newPlottersManager () { connector.panels = [] if (product !== undefined) { + /* Here we setup the panels associated with this plotter */ for (let i = 0; i < plotterModule.panels.length; i++) { let panel = plotterModule.panels[i] diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 0e9f16202..412af7968 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -20,7 +20,7 @@ function newUiObject () { formulaEditor: undefined, uiObjectTitle: undefined, circularProgressBar: undefined, - isExecuting: undefined, + isRunningAtBackend: undefined, isRunning: undefined, shortcutKey: undefined, isShowing: undefined, @@ -35,8 +35,11 @@ function newUiObject () { setErrorMessage: setErrorMessage, resetErrorMessage: resetErrorMessage, setValue: setValue, + resetValue: resetValue, setPercentage: setPercentage, + resetPercentage: resetPercentage, setStatus: setStatus, + resetStatus: resetStatus, physics: physics, invisiblePhysics: invisiblePhysics, drawBackground: drawBackground, @@ -1817,7 +1820,7 @@ function newUiObject () { if (icon !== undefined) { if (icon.canDrawIcon === true) { let additionalImageSize = 0 - if (thisObject.isExecuting === true || isReadyToReferenceAttach === true || isReadyToChainAttach === true) { additionalImageSize = 20 } + if (thisObject.isRunningAtBackend === true || isReadyToReferenceAttach === true || isReadyToChainAttach === true) { additionalImageSize = 20 } let totalImageSize = additionalImageSize + thisObject.payload.floatingObject.currentImageSize if (canvas.floatingSpace.inMapMode === true) { totalImageSize = canvas.floatingSpace.transformImagesizeToMap(totalImageSize) @@ -1843,7 +1846,7 @@ function newUiObject () { if (executingIcon !== undefined) { if (executingIcon.canDrawIcon === true) { - if (thisObject.isExecuting === true) { + if (thisObject.isRunningAtBackend === true) { const DISTANCE_FROM_CENTER = thisObject.container.frame.radius / 3 + 50 const EXECUTING_ICON_SIZE = 20 + thisObject.container.frame.radius / 6 diff --git a/Plotting/NodesErrors.js b/Plotting/NodesErrors.js new file mode 100644 index 000000000..db636c80a --- /dev/null +++ b/Plotting/NodesErrors.js @@ -0,0 +1,36 @@ +function newNodesErrors () { + const MODULE_NAME = 'Nodes Errors' + const logger = newWebDebugLog() + logger.fileName = MODULE_NAME + + let thisObject = { + onRecordChange: onRecordChange, + initialize: initialize, + finalize: finalize + } + + let rootNode + return thisObject + + function finalize () { + rootNode = undefined + } + + function initialize (pRootNode) { + rootNode = pRootNode + } + + function onRecordChange (currentRecord) { + evalNode(rootNode, currentRecord.array, 0, applyError) + } + + function applyError (node, errorMessage) { + if (node.payload === undefined) { return } + if (node.payload.uiObject === undefined) { return } + if (errorMessage === '') { + node.payload.uiObject.resetErrorMessage(errorMessage) + } else { + node.payload.uiObject.setErrorMessage(errorMessage) + } + } +} diff --git a/Plotting/NodesHighlights.js b/Plotting/NodesHighlights.js new file mode 100644 index 000000000..d1dcca65b --- /dev/null +++ b/Plotting/NodesHighlights.js @@ -0,0 +1,33 @@ +function newNodesHighlights () { + const MODULE_NAME = 'Nodes Highlights' + const logger = newWebDebugLog() + logger.fileName = MODULE_NAME + + let thisObject = { + onRecordChange: onRecordChange, + initialize: initialize, + finalize: finalize + } + + let rootNode + return thisObject + + function finalize () { + rootNode = undefined + } + + function initialize (pRootNode) { + rootNode = pRootNode + } + + function onRecordChange (currentRecord) { + evalNode(rootNode, currentRecord.array, 0, applyHighlight) + } + + function applyHighlight (node, value) { + if (value !== 1) { return } + if (node.payload === undefined) { return } + if (node.payload.uiObject === undefined) { return } + node.payload.uiObject.highlight() + } +} diff --git a/Plotting/NodesProgress.js b/Plotting/NodesProgress.js new file mode 100644 index 000000000..03992cc11 --- /dev/null +++ b/Plotting/NodesProgress.js @@ -0,0 +1,32 @@ +function newNodesProgress () { + const MODULE_NAME = 'Nodes Progress' + const logger = newWebDebugLog() + logger.fileName = MODULE_NAME + + let thisObject = { + onRecordChange: onRecordChange, + initialize: initialize, + finalize: finalize + } + + let rootNode + return thisObject + + function finalize () { + rootNode = undefined + } + + function initialize (pRootNode) { + rootNode = pRootNode + } + + function onRecordChange (currentRecord) { + evalNode(rootNode, currentRecord.array, 0, applyProgress) + } + + function applyProgress (node, value) { + if (node.payload === undefined) { return } + if (node.payload.uiObject === undefined) { return } + node.payload.uiObject.setPercentage(node, value) + } +} diff --git a/Plotting/NodesRunning.js b/Plotting/NodesRunning.js new file mode 100644 index 000000000..630e372fe --- /dev/null +++ b/Plotting/NodesRunning.js @@ -0,0 +1,36 @@ +function newNodesRunning () { + const MODULE_NAME = 'Nodes Running' + const logger = newWebDebugLog() + logger.fileName = MODULE_NAME + + let thisObject = { + onRecordChange: onRecordChange, + initialize: initialize, + finalize: finalize + } + + let rootNode + return thisObject + + function finalize () { + rootNode = undefined + } + + function initialize (pRootNode) { + rootNode = pRootNode + } + + function onRecordChange (currentRecord) { + evalNode(rootNode, currentRecord.array, 0, applyExecution) + } + + function applyExecution (node, value) { + if (node.payload === undefined) { return } + if (node.payload.uiObject === undefined) { return } + if (value === 1) { + node.payload.uiObject.isRunningAtBackend = true + } else { + node.payload.uiObject.isRunningAtBackend = false + } + } +} diff --git a/Plotting/NodesStatus.js b/Plotting/NodesStatus.js new file mode 100644 index 000000000..cab163268 --- /dev/null +++ b/Plotting/NodesStatus.js @@ -0,0 +1,32 @@ +function newNodesStatus () { + const MODULE_NAME = 'Nodes Status' + const logger = newWebDebugLog() + logger.fileName = MODULE_NAME + + let thisObject = { + onRecordChange: onRecordChange, + initialize: initialize, + finalize: finalize + } + + let rootNode + return thisObject + + function finalize () { + rootNode = undefined + } + + function initialize (pRootNode) { + rootNode = pRootNode + } + + function onRecordChange (currentRecord) { + evalNode(rootNode, currentRecord.array, 0, applyStatus) + } + + function applyStatus (node, status) { + if (node.payload === undefined) { return } + if (node.payload.uiObject === undefined) { return } + node.payload.uiObject.setStatus(node, status) + } +} diff --git a/Plotting/NodesValues.js b/Plotting/NodesValues.js new file mode 100644 index 000000000..5418ff340 --- /dev/null +++ b/Plotting/NodesValues.js @@ -0,0 +1,32 @@ +function newNodesValues () { + const MODULE_NAME = 'Nodes Values' + const logger = newWebDebugLog() + logger.fileName = MODULE_NAME + + let thisObject = { + onRecordChange: onRecordChange, + initialize: initialize, + finalize: finalize + } + + let rootNode + return thisObject + + function finalize () { + rootNode = undefined + } + + function initialize (pRootNode) { + rootNode = pRootNode + } + + function onRecordChange (currentRecord) { + evalNode(rootNode, currentRecord.array, 0, applyValue) + } + + function applyValue (node, value) { + if (node.payload === undefined) { return } + if (node.payload.uiObject === undefined) { return } + node.payload.uiObject.setValue(value) + } +} diff --git a/Plotter.js b/Plotting/Plotter.js similarity index 99% rename from Plotter.js rename to Plotting/Plotter.js index ca72ed893..094b0eb65 100644 --- a/Plotter.js +++ b/Plotting/Plotter.js @@ -245,7 +245,9 @@ function newPlotter () { function draw () { try { thisObject.container.frame.draw() - plotChart() + if (productDefinition.referenceParent.shapes !== undefined) { + plotShapes() + } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] draw -> err = ' + err.stack) } } @@ -489,7 +491,7 @@ function newPlotter () { } } - function plotChart () { + function plotShapes () { try { /* Clean the pannel at places where there is no record. */ let currentRecord = { @@ -792,7 +794,7 @@ function newPlotter () { logged = false } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] plotChart -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] plotShapes -> err = ' + err.stack) } } } diff --git a/Utilities/RecursiveEvalNode.js b/Utilities/RecursiveEvalNode.js new file mode 100644 index 000000000..8e4a0f6a9 --- /dev/null +++ b/Utilities/RecursiveEvalNode.js @@ -0,0 +1,45 @@ +/* +This function scans a node hiriatchy recursively. At each node it calls the callback +provided with the corresponfing value of the array. +*/ + +function evalNode (node, array, index, callback) { + if (node === undefined) { return } + if (array === undefined) { return } + if (index === undefined) { return } + if (callback === undefined) { return } + + callback(node, array[index]) + + /* Now we go down through all this node children */ + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition === undefined) { return } + + if (nodeDefinition.properties !== undefined) { + let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + if (property.name !== previousPropertyName) { + if (node[property.name] !== undefined) { + evalNode(node[property.name], array, index + 1, callback) + } + previousPropertyName = property.name + } + break + } + case 'array': { + if (node[property.name] !== undefined) { + let nodePropertyArray = node[property.name] + for (let m = 0; m < nodePropertyArray.length; m++) { + evalNode(nodePropertyArray[m], array, index + 1, callback) + } + } + break + } + } + } + } +} From 6796745980c7c585fed3dde52a2cdbf3d47dcace Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 16 Jun 2020 19:21:38 +0200 Subject: [PATCH 09/48] highlights and values working --- ChartingSpace/PlottersManager.js | 165 ++++++++++++++++++++--------- DesignSpace/Workspace/Workspace.js | 11 ++ Panels/Layer.js | 9 +- Panels/PlotterPanel.js | 4 +- Plotting/NodesErrors.js | 27 +++-- Plotting/NodesHighlights.js | 21 ++-- Plotting/NodesValues.js | 25 +++-- Plotting/Plotter.js | 19 +--- Utilities/HiriarchyMap.js | 47 ++++++++ Utilities/RecursiveEvalNode.js | 45 -------- 10 files changed, 233 insertions(+), 140 deletions(-) create mode 100644 Utilities/HiriarchyMap.js delete mode 100644 Utilities/RecursiveEvalNode.js diff --git a/ChartingSpace/PlottersManager.js b/ChartingSpace/PlottersManager.js index 8348a4d7a..f9ac303a5 100644 --- a/ChartingSpace/PlottersManager.js +++ b/ChartingSpace/PlottersManager.js @@ -137,11 +137,25 @@ function newPlottersManager () { let exchange = layer.definition.referenceParent.parentNode.referenceParent.parentNode.parentNode let plotterModule = layer.definition.referenceParent.referenceParent.referenceParent let session + let tradingSystem + let tradingEngine + /* + 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. + */ if (layer.definition.referenceParent.parentNode.parentNode !== undefined) { if (layer.definition.referenceParent.parentNode.parentNode.type === 'Session Reference') { if (layer.definition.referenceParent.parentNode.parentNode.referenceParent !== undefined) { session = layer.definition.referenceParent.parentNode.parentNode.referenceParent + + /* From the session we might be able to reach the Trading System or the Trading Engine */ + if (session.tradingSystemReference !== undefined) { + tradingSystem = session.tradingSystemReference.referenceParent + } + if (session.tradingEngineReference !== undefined) { + tradingEngine = session.tradingEngineReference.referenceParent + } } } } @@ -169,67 +183,97 @@ function newPlottersManager () { ) function onProductStorageInitialized (err) { - try { - if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { + if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { /* Now we have all the initial data loaded and ready to be delivered to the new instance of the plotter. */ - let plotter + let plotter - if (plotterModule.config.isLegacy !== true) { - plotter = newPlotter() - } else { - plotter = getNewPlotter(dataMine.config.codeName, plotterModule.parentNode.config.codeName, plotterModule.config.codeName) + if (plotterModule.config.isLegacy !== true) { + plotter = newPlotter() + } else { + plotter = getNewPlotter(dataMine.config.codeName, plotterModule.parentNode.config.codeName, plotterModule.config.codeName) + } + + plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) + plotter.container.frame.position.x = thisObject.container.frame.width / 2 - plotter.container.frame.width / 2 + plotter.container.frame.position.y = thisObject.container.frame.height / 2 - plotter.container.frame.height / 2 + plotter.fitFunction = thisObject.fitFunction + plotter.initialize(storage, datetime, timeFrame, coordinateSystem, onPlotterInizialized, product) + + function onPlotterInizialized () { + let connector = { + layer: layer, + plotter: plotter, + storage: storage } + /* Let the Plotter listen to the event of Cursor Files loaded, so that it can react recalculating if needed. */ + plotter.onDailyFileLoadedPlotterEventsSubscriptionId = storage.eventHandler.listenToEvent('Daily File Loaded', plotter.onDailyFileLoaded) + /* Lets load now this plotter panels. */ + connector.panels = [] - plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) - plotter.container.frame.position.x = thisObject.container.frame.width / 2 - plotter.container.frame.width / 2 - plotter.container.frame.position.y = thisObject.container.frame.height / 2 - plotter.container.frame.height / 2 - plotter.fitFunction = thisObject.fitFunction - plotter.initialize(storage, datetime, timeFrame, coordinateSystem, onPlotterInizialized, product) + if (product !== undefined) { + /* Here we setup the panels associated with this plotter */ + for (let i = 0; i < plotterModule.panels.length; i++) { + let panel = plotterModule.panels[i] - function onPlotterInizialized () { - try { - let connector = { - layer: layer, - plotter: plotter, - storage: storage - } - /* Let the Plotter listen to the event of Cursor Files loaded, so that it can react recalculating if needed. */ - plotter.onDailyFileLoadedPlotterEventsSubscriptionId = storage.eventHandler.listenToEvent('Daily File Loaded', plotter.onDailyFileLoaded) - /* Lets load now this plotter panels. */ - connector.panels = [] - - if (product !== undefined) { - /* Here we setup the panels associated with this plotter */ - for (let i = 0; i < plotterModule.panels.length; i++) { - let panel = plotterModule.panels[i] - - let parameters = { - dataMine: dataMine.config.codeName, - plotterCodeName: plotterModule.parentNode.config.codeName, - moduleCodeName: plotterModule.config.codeName, - panelNode: panel - } - - let owner = thisObject.payload.node.payload.parentNode.id // Panels are owned by the time machine. - let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, owner, layer.session) - let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle) - - /* Connect Panel to the Plotter via an Event. */ - connector.plotter.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', plotterPanel.onRecordChange) - connector.panels.push(plotterPanelHandle) - } - - connector.layer.panels = connector.panels + let parameters = { + dataMine: dataMine.config.codeName, + plotterCodeName: plotterModule.parentNode.config.codeName, + moduleCodeName: plotterModule.config.codeName, + panelNode: panel } - thisObject.connectors.push(connector) - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initializePlotter -> onProductStorageInitialized -> onPlotterInizialized -> err = ' + err.stack) } + let owner = thisObject.payload.node.payload.parentNode.id // Panels are owned by the time machine. + let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, owner, layer.session) + let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle) + + /* Connect Panel to the Plotter via an Event. */ + connector.plotter.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', plotterPanel.onRecordChange) + connector.panels.push(plotterPanelHandle) + } + connector.layer.panels = connector.panels + + /* + Next we will check the different types of Plotting related to connecting to an existing node branch. + */ + if (plotterModule.nodesHighlights !== undefined) { + connector.nodesHighlights = newNodesHighlights() + switch (plotterModule.config.connectTo) { + case 'Trading System': + connector.nodesHighlights.initialize(tradingSystem) + break + case 'Trading Engine': + connector.nodesHighlights.initialize(tradingEngine) + break + } + connector.nodesHighlights.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesHighlights.onRecordChange) + } + if (plotterModule.nodesValues !== undefined) { + connector.nodesValues = newNodesValues() + switch (plotterModule.config.connectTo) { + case 'Trading System': + connector.nodesValues.initialize(tradingSystem) + break + case 'Trading Engine': + connector.nodesValues.initialize(tradingEngine) + break + } + connector.nodesValues.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesValues.onRecordChange) + } + if (plotterModule.nodesErrors !== undefined) { + connector.nodesErrors = newNodesErrors() + switch (plotterModule.config.connectTo) { + case 'Trading System': + connector.nodesErrors.initialize(tradingSystem) + break + case 'Trading Engine': + connector.nodesErrors.initialize(tradingEngine) + break + } + connector.nodesErrors.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesErrors.onRecordChange) } } + thisObject.connectors.push(connector) } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initializePlotter -> onProductStorageInitialized -> err = ' + err.stack) } } } } catch (err) { @@ -263,8 +307,8 @@ function newPlottersManager () { for (let j = 0; j < connector.panels.length; j++) { canvas.panelsSpace.destroyPanel(connector.panels[j]) } - /* Finally the Storage Objects */ - + /* Finally the Storage Objects */ + finalizeNodesPlotting(connector) if (connector.plotter.finalize !== undefined) { connector.plotter.container.eventHandler.stopListening(connector.plotter.onRecordChangeEventsSubscriptionId) connector.plotter.container.finalize() @@ -278,6 +322,21 @@ function newPlottersManager () { } } + function finalizeNodesPlotting (connector) { + if (connector.nodesHighlights !== undefined) { + connector.plotter.container.eventHandler.stopListening(connector.nodesHighlights.onRecordChangeEventsSubscriptionId) + connector.nodesHighlights.finalize() + } + if (connector.nodesValues !== undefined) { + connector.plotter.container.eventHandler.stopListening(connector.nodesValues.onRecordChangeEventsSubscriptionId) + connector.nodesValues.finalize() + } + if (connector.nodesErrors !== undefined) { + connector.plotter.container.eventHandler.stopListening(connector.nodesErrors.onRecordChangeEventsSubscriptionId) + connector.nodesErrors.finalize() + } + } + function setTimeFrame (pTimeFrame) { timeFrame = pTimeFrame for (let i = 0; i < thisObject.connectors.length; i++) { diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 4882502b8..4cd40ff89 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -14,6 +14,7 @@ function newWorkspace () { replaceWorkspaceByLoadingOne: replaceWorkspaceByLoadingOne, save: saveWorkspace, getHierarchyHeads: getHierarchyHeads, + getHierarchyHeadsById: getHierarchyHeadsById, getNodeThatIsOnFocus: getNodeThatIsOnFocus, getNodeByShortcutKey: getNodeByShortcutKey, stopAllRunningTasks: stopAllRunningTasks, @@ -355,6 +356,16 @@ function newWorkspace () { return nodes } + function getHierarchyHeadsById (nodeId) { + let hiriatchyHeads = getHierarchyHeads() + for (let i = 0; i < hiriatchyHeads.length; i++) { + let hiriatchyHead = hiriatchyHeads[i] + if (hiriatchyHead.id === nodeId) { + return hiriatchyHead + } + } + } + function replaceWorkspaceByLoadingOne (name) { let blobService = newFileStorage() blobService.getFileFromHost('LoadWorkspace' + '/' + name, onFileReceived, true) diff --git a/Panels/Layer.js b/Panels/Layer.js index c1ac56823..1aa9e003f 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -157,6 +157,7 @@ function newLayer () { 'Session Reference->Session Independent Data->Session Based Data->Exchange Sessions->Session Based Data->Data Storage->Network Node->' + 'Data Storage->Network Node->' + 'Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + + 'Trading System Reference->Trading Engine Reference->Trading System->Trading Engine->' + 'Market->Market Base Asset->Asset->' + 'Market Quoted Asset->Asset->' + 'Exchange Markets->Crypto Exchange->' + @@ -173,12 +174,13 @@ function newLayer () { 'Polygon->Polygon Condition->Polygon Body->Style->Style Condition->Style->' + 'Polygon Border->Style->Style Condition->Style->' + 'Polygon Vertex->Point->' + - 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' + 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' + + 'Nodes Highlights->Nodes Values->Nodes Errors->Nodes Status->Nodes Progress->Nodes Running->' thisObject.definition = functionLibraryProtocolNode.getProtocolNode(thisObject.payload.node, false, true, true, false, false, lightingPath) /* Here we validate that we have all the needed information */ - if (thisObject.definition.referenceParent === undefined) { return } - if (thisObject.definition.referenceParent.parentNode === undefined) { return } + if (thisObject.definition.referenceParent === undefined) { return } // Data Product + if (thisObject.definition.referenceParent.parentNode === undefined) { return } // Single Market Data if (thisObject.definition.referenceParent.parentNode.referenceParent === undefined) { return } if (thisObject.definition.referenceParent.parentNode.referenceParent.parentNode === undefined) { return } if (thisObject.definition.referenceParent.parentNode.referenceParent.parentNode.parentNode === undefined) { return } @@ -223,7 +225,6 @@ function newLayer () { } thisObject.plotterModule = thisObject.definition.referenceParent.referenceParent.referenceParent - thisObject.exchangeIcon = getIcon(thisObject.exchange) if (thisObject.plotterModule.config.icon !== undefined) { diff --git a/Panels/PlotterPanel.js b/Panels/PlotterPanel.js index 14f1fe5ba..3e03dbd86 100644 --- a/Panels/PlotterPanel.js +++ b/Panels/PlotterPanel.js @@ -100,9 +100,7 @@ function newPlotterPanel () { const PANEL_HEIGHT = UI_PANEL.HEIGHT.NORMAL if (currentRecord === undefined) { return } - if (currentRecord.data === undefined) { return } - - let record = currentRecord.data + let record = currentRecord /* First we execute code if provided. */ if (panelNode.javascriptCode !== undefined) { diff --git a/Plotting/NodesErrors.js b/Plotting/NodesErrors.js index db636c80a..a331041d6 100644 --- a/Plotting/NodesErrors.js +++ b/Plotting/NodesErrors.js @@ -8,29 +8,38 @@ function newNodesErrors () { initialize: initialize, finalize: finalize } - - let rootNode + let hiriarchyMap return thisObject function finalize () { - rootNode = undefined + hiriarchyMap = undefined } function initialize (pRootNode) { - rootNode = pRootNode + let rootNode = canvas.designSpace.workspace.getHierarchyHeadsById(pRootNode.id) + hiriarchyMap = getHiriarchyMap(rootNode) } function onRecordChange (currentRecord) { - evalNode(rootNode, currentRecord.array, 0, applyError) + if (currentRecord === undefined) { return } + let array = currentRecord.errors + if (array === undefined) { return } + for (let i = 0; i < array.length; i++) { + let arrayItem = array[0] + let nodeId = arrayItem[0] + let value = arrayItem[1] + applyValue(nodeId, value) + } } - function applyError (node, errorMessage) { + function applyValue (nodeId, value) { + let node = hiriarchyMap.get(nodeId) if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } - if (errorMessage === '') { - node.payload.uiObject.resetErrorMessage(errorMessage) + if (value === '') { + node.payload.uiObject.resetErrorMessage() } else { - node.payload.uiObject.setErrorMessage(errorMessage) + node.payload.uiObject.setErrorMessage(value) } } } diff --git a/Plotting/NodesHighlights.js b/Plotting/NodesHighlights.js index d1dcca65b..e63d7da99 100644 --- a/Plotting/NodesHighlights.js +++ b/Plotting/NodesHighlights.js @@ -9,23 +9,32 @@ function newNodesHighlights () { finalize: finalize } - let rootNode + let hiriarchyMap return thisObject function finalize () { - rootNode = undefined + hiriarchyMap = undefined } function initialize (pRootNode) { - rootNode = pRootNode + let rootNode = canvas.designSpace.workspace.getHierarchyHeadsById(pRootNode.id) + hiriarchyMap = getHiriarchyMap(rootNode) } function onRecordChange (currentRecord) { - evalNode(rootNode, currentRecord.array, 0, applyHighlight) + if (currentRecord === undefined) { return } + let array = currentRecord.highlights + if (array === undefined) { return } + for (let i = 0; i < array.length; i++) { + let arrayItem = array[0] + let nodeId = arrayItem[0] + let value = arrayItem[1] + applyValue(nodeId, value) + } } - function applyHighlight (node, value) { - if (value !== 1) { return } + function applyValue (nodeId, value) { + let node = hiriarchyMap.get(nodeId) if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } node.payload.uiObject.highlight() diff --git a/Plotting/NodesValues.js b/Plotting/NodesValues.js index 5418ff340..23559cfc3 100644 --- a/Plotting/NodesValues.js +++ b/Plotting/NodesValues.js @@ -9,24 +9,37 @@ function newNodesValues () { finalize: finalize } - let rootNode + let hiriarchyMap return thisObject function finalize () { - rootNode = undefined + hiriarchyMap = undefined } function initialize (pRootNode) { - rootNode = pRootNode + let rootNode = canvas.designSpace.workspace.getHierarchyHeadsById(pRootNode.id) + hiriarchyMap = getHiriarchyMap(rootNode) } function onRecordChange (currentRecord) { - evalNode(rootNode, currentRecord.array, 0, applyValue) + if (currentRecord === undefined) { return } + let array = currentRecord.values + if (array === undefined) { return } + for (let i = 0; i < array.length; i++) { + let arrayItem = array[0] + let nodeId = arrayItem[0] + let value = arrayItem[1] + applyValue(nodeId, value) + } } - function applyValue (node, value) { + function applyValue (nodeId, value) { + let node = hiriarchyMap.get(nodeId) if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } - node.payload.uiObject.setValue(value) + if (value === true) { value = 'true' } + if (value === false) { value = 'false' } + node.payload.uiObject.setValue(value, 30) } } + diff --git a/Plotting/Plotter.js b/Plotting/Plotter.js index 094b0eb65..6c4bd2009 100644 --- a/Plotting/Plotter.js +++ b/Plotting/Plotter.js @@ -245,9 +245,7 @@ function newPlotter () { function draw () { try { thisObject.container.frame.draw() - if (productDefinition.referenceParent.shapes !== undefined) { - plotShapes() - } + plot() } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] draw -> err = ' + err.stack) } } @@ -491,13 +489,10 @@ function newPlotter () { } } - function plotShapes () { + function plot () { try { /* Clean the pannel at places where there is no record. */ - let currentRecord = { - data: undefined - } - thisObject.container.eventHandler.raiseEvent('Current Record Changed', currentRecord) + thisObject.container.eventHandler.raiseEvent('Current Record Changed', undefined) for (let i = 0; i < records.length; i++) { let record = records[i] @@ -541,11 +536,7 @@ function newPlotter () { let atMousePosition = false if (userPositionDate >= record.begin && userPositionDate <= record.end) { atMousePosition = true - - let currentRecord = { - data: record - } - thisObject.container.eventHandler.raiseEvent('Current Record Changed', currentRecord) + thisObject.container.eventHandler.raiseEvent('Current Record Changed', record) } /* If there is code we execute it now. */ @@ -794,7 +785,7 @@ function newPlotter () { logged = false } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] plotShapes -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] plot -> err = ' + err.stack) } } } diff --git a/Utilities/HiriarchyMap.js b/Utilities/HiriarchyMap.js new file mode 100644 index 000000000..e27ec1614 --- /dev/null +++ b/Utilities/HiriarchyMap.js @@ -0,0 +1,47 @@ +/* +This function scans a node hiriatchy recursively and creates a Map by Id of all the nodes of it. +*/ + +function getHiriarchyMap (rootNode) { + let hiriatchyMap = new Map() + evalNode(rootNode) + return hiriatchyMap + + function evalNode (node) { + if (node === undefined) { return } + + hiriatchyMap.set(node.id, node) + + /* Now we go down through all this node children */ + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition === undefined) { return } + + if (nodeDefinition.properties !== undefined) { + let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + if (property.name !== previousPropertyName) { + if (node[property.name] !== undefined) { + evalNode(node[property.name]) + } + previousPropertyName = property.name + } + break + } + case 'array': { + if (node[property.name] !== undefined) { + let nodePropertyArray = node[property.name] + for (let m = 0; m < nodePropertyArray.length; m++) { + evalNode(nodePropertyArray[m]) + } + } + break + } + } + } + } + } +} diff --git a/Utilities/RecursiveEvalNode.js b/Utilities/RecursiveEvalNode.js deleted file mode 100644 index 8e4a0f6a9..000000000 --- a/Utilities/RecursiveEvalNode.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -This function scans a node hiriatchy recursively. At each node it calls the callback -provided with the corresponfing value of the array. -*/ - -function evalNode (node, array, index, callback) { - if (node === undefined) { return } - if (array === undefined) { return } - if (index === undefined) { return } - if (callback === undefined) { return } - - callback(node, array[index]) - - /* Now we go down through all this node children */ - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) - if (nodeDefinition === undefined) { return } - - if (nodeDefinition.properties !== undefined) { - let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. - for (let i = 0; i < nodeDefinition.properties.length; i++) { - let property = nodeDefinition.properties[i] - - switch (property.type) { - case 'node': { - if (property.name !== previousPropertyName) { - if (node[property.name] !== undefined) { - evalNode(node[property.name], array, index + 1, callback) - } - previousPropertyName = property.name - } - break - } - case 'array': { - if (node[property.name] !== undefined) { - let nodePropertyArray = node[property.name] - for (let m = 0; m < nodePropertyArray.length; m++) { - evalNode(nodePropertyArray[m], array, index + 1, callback) - } - } - break - } - } - } - } -} From 283fe59ec183f88856f430db89caeb12c5b28b67 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 16 Jun 2020 20:41:08 +0200 Subject: [PATCH 10/48] All Plotting Working --- ChartingSpace/PlottersManager.js | 48 ++++++++++++++++++++++++++++++++ FloatingSpace/UiObject.js | 23 +++++++++++++-- Plotting/NodesProgress.js | 25 +++++++++++++---- Plotting/NodesRunning.js | 35 ++++++++++++++--------- Plotting/NodesStatus.js | 25 +++++++++++++---- 5 files changed, 128 insertions(+), 28 deletions(-) diff --git a/ChartingSpace/PlottersManager.js b/ChartingSpace/PlottersManager.js index f9ac303a5..844a42987 100644 --- a/ChartingSpace/PlottersManager.js +++ b/ChartingSpace/PlottersManager.js @@ -271,6 +271,42 @@ function newPlottersManager () { } connector.nodesErrors.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesErrors.onRecordChange) } + if (plotterModule.nodesRunning !== undefined) { + connector.nodesRunning = newNodesRunning() + switch (plotterModule.config.connectTo) { + case 'Trading System': + connector.nodesRunning.initialize(tradingSystem) + break + case 'Trading Engine': + connector.nodesRunning.initialize(tradingEngine) + break + } + connector.nodesRunning.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesRunning.onRecordChange) + } + if (plotterModule.nodesStatus !== undefined) { + connector.nodesStatus = newNodesStatus() + switch (plotterModule.config.connectTo) { + case 'Trading System': + connector.nodesStatus.initialize(tradingSystem) + break + case 'Trading Engine': + connector.nodesStatus.initialize(tradingEngine) + break + } + connector.nodesStatus.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesStatus.onRecordChange) + } + if (plotterModule.nodesProgress !== undefined) { + connector.nodesProgress = newNodesProgress() + switch (plotterModule.config.connectTo) { + case 'Trading System': + connector.nodesProgress.initialize(tradingSystem) + break + case 'Trading Engine': + connector.nodesProgress.initialize(tradingEngine) + break + } + connector.nodesProgress.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesProgress.onRecordChange) + } } thisObject.connectors.push(connector) } @@ -335,6 +371,18 @@ function newPlottersManager () { connector.plotter.container.eventHandler.stopListening(connector.nodesErrors.onRecordChangeEventsSubscriptionId) connector.nodesErrors.finalize() } + if (connector.nodesStatus !== undefined) { + connector.plotter.container.eventHandler.stopListening(connector.nodesStatus.onRecordChangeEventsSubscriptionId) + connector.nodesStatus.finalize() + } + if (connector.nodesProgress !== undefined) { + connector.plotter.container.eventHandler.stopListening(connector.Progress.onRecordChangeEventsSubscriptionId) + connector.Progress.finalize() + } + if (connector.nodesRunning !== undefined) { + connector.plotter.container.eventHandler.stopListening(connector.nodesRunning.onRecordChangeEventsSubscriptionId) + connector.nodesRunning.finalize() + } } function setTimeFrame (pTimeFrame) { diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 412af7968..cde2688e8 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -20,7 +20,6 @@ function newUiObject () { formulaEditor: undefined, uiObjectTitle: undefined, circularProgressBar: undefined, - isRunningAtBackend: undefined, isRunning: undefined, shortcutKey: undefined, isShowing: undefined, @@ -32,6 +31,7 @@ function newUiObject () { getReadyToReferenceAttach: getReadyToReferenceAttach, showAvailabilityToReferenceAttach: showAvailabilityToReferenceAttach, highlight: highlight, + runningAtBackend: runningAtBackend, setErrorMessage: setErrorMessage, resetErrorMessage: resetErrorMessage, setValue: setValue, @@ -71,6 +71,9 @@ function newUiObject () { let isHighlighted let highlightCounter = 0 + let isRunningAtBackend + let runningAtBackendCounter = 0 + let hasError let errorMessageCounter = 0 @@ -321,6 +324,7 @@ function newUiObject () { iconPhysics() highlightPhisycs() + runningAtBackendPhisycs() errorMessagePhisycs() valuePhisycs() percentagePhisycs() @@ -672,6 +676,14 @@ function newUiObject () { } } + function runningAtBackendPhisycs () { + runningAtBackendCounter-- + if (runningAtBackendCounter < 0) { + runningAtBackendCounter = 0 + isRunningAtBackend = false + } + } + function errorMessagePhisycs () { errorMessageCounter-- if (errorMessageCounter < 0) { @@ -709,6 +721,11 @@ function newUiObject () { highlightCounter = 30 } + function runningAtBackend () { + isRunningAtBackend = true + runningAtBackendCounter = 5 + } + function setErrorMessage (message, duration) { if (message !== undefined) { errorMessage = message @@ -1820,7 +1837,7 @@ function newUiObject () { if (icon !== undefined) { if (icon.canDrawIcon === true) { let additionalImageSize = 0 - if (thisObject.isRunningAtBackend === true || isReadyToReferenceAttach === true || isReadyToChainAttach === true) { additionalImageSize = 20 } + if (isRunningAtBackend === true || isReadyToReferenceAttach === true || isReadyToChainAttach === true) { additionalImageSize = 20 } let totalImageSize = additionalImageSize + thisObject.payload.floatingObject.currentImageSize if (canvas.floatingSpace.inMapMode === true) { totalImageSize = canvas.floatingSpace.transformImagesizeToMap(totalImageSize) @@ -1846,7 +1863,7 @@ function newUiObject () { if (executingIcon !== undefined) { if (executingIcon.canDrawIcon === true) { - if (thisObject.isRunningAtBackend === true) { + if (isRunningAtBackend === true) { const DISTANCE_FROM_CENTER = thisObject.container.frame.radius / 3 + 50 const EXECUTING_ICON_SIZE = 20 + thisObject.container.frame.radius / 6 diff --git a/Plotting/NodesProgress.js b/Plotting/NodesProgress.js index 03992cc11..627a4e1e5 100644 --- a/Plotting/NodesProgress.js +++ b/Plotting/NodesProgress.js @@ -9,24 +9,37 @@ function newNodesProgress () { finalize: finalize } - let rootNode + let hiriarchyMap return thisObject function finalize () { - rootNode = undefined + hiriarchyMap = undefined } function initialize (pRootNode) { - rootNode = pRootNode + let rootNode = canvas.designSpace.workspace.getHierarchyHeadsById(pRootNode.id) + hiriarchyMap = getHiriarchyMap(rootNode) } function onRecordChange (currentRecord) { - evalNode(rootNode, currentRecord.array, 0, applyProgress) + if (currentRecord === undefined) { return } + let array = currentRecord.progress + if (array === undefined) { return } + for (let i = 0; i < array.length; i++) { + let arrayItem = array[0] + let nodeId = arrayItem[0] + let value = arrayItem[1] + applyValue(nodeId, value) + } } - function applyProgress (node, value) { + function applyValue (nodeId, value) { + let node = hiriarchyMap.get(nodeId) if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } - node.payload.uiObject.setPercentage(node, value) + if (value === true) { value = 'true' } + if (value === false) { value = 'false' } + node.payload.uiObject.setPercentage(value, 30) } } + diff --git a/Plotting/NodesRunning.js b/Plotting/NodesRunning.js index 630e372fe..2be348875 100644 --- a/Plotting/NodesRunning.js +++ b/Plotting/NodesRunning.js @@ -9,28 +9,37 @@ function newNodesRunning () { finalize: finalize } - let rootNode + let hiriarchyMap return thisObject function finalize () { - rootNode = undefined + hiriarchyMap = undefined } function initialize (pRootNode) { - rootNode = pRootNode + let rootNode = canvas.designSpace.workspace.getHierarchyHeadsById(pRootNode.id) + hiriarchyMap = getHiriarchyMap(rootNode) } function onRecordChange (currentRecord) { - evalNode(rootNode, currentRecord.array, 0, applyExecution) - } - - function applyExecution (node, value) { - if (node.payload === undefined) { return } - if (node.payload.uiObject === undefined) { return } - if (value === 1) { - node.payload.uiObject.isRunningAtBackend = true - } else { - node.payload.uiObject.isRunningAtBackend = false + if (currentRecord === undefined) { return } + let array = currentRecord.running + if (array === undefined) { return } + for (let i = 0; i < array.length; i++) { + let arrayItem = array[0] + let nodeId = arrayItem[0] + let value = arrayItem[1] + applyValue(nodeId, value) } } + + function applyValue (nodeId, value) { + let node = hiriarchyMap.get(nodeId) + if (node.payload === undefined) { return } + if (node.payload.uiObject === undefined) { return } + if (value === true) { value = 'true' } + if (value === false) { value = 'false' } + node.payload.uiObject.runningAtBackend() + } } + diff --git a/Plotting/NodesStatus.js b/Plotting/NodesStatus.js index cab163268..d95e8cef2 100644 --- a/Plotting/NodesStatus.js +++ b/Plotting/NodesStatus.js @@ -9,24 +9,37 @@ function newNodesStatus () { finalize: finalize } - let rootNode + let hiriarchyMap return thisObject function finalize () { - rootNode = undefined + hiriarchyMap = undefined } function initialize (pRootNode) { - rootNode = pRootNode + let rootNode = canvas.designSpace.workspace.getHierarchyHeadsById(pRootNode.id) + hiriarchyMap = getHiriarchyMap(rootNode) } function onRecordChange (currentRecord) { - evalNode(rootNode, currentRecord.array, 0, applyStatus) + if (currentRecord === undefined) { return } + let array = currentRecord.status + if (array === undefined) { return } + for (let i = 0; i < array.length; i++) { + let arrayItem = array[0] + let nodeId = arrayItem[0] + let value = arrayItem[1] + applyValue(nodeId, value) + } } - function applyStatus (node, status) { + function applyValue (nodeId, value) { + let node = hiriarchyMap.get(nodeId) if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } - node.payload.uiObject.setStatus(node, status) + if (value === true) { value = 'true' } + if (value === false) { value = 'false' } + node.payload.uiObject.setStatus(value, 30) } } + From 8e778eade055e8db755a03ba626024b66320d1c0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 17 Jun 2020 14:13:21 +0200 Subject: [PATCH 11/48] Record Values Working --- ChartingSpace/PlottersManager.js | 33 +++++++++++------ FloatingSpace/UiObject.js | 2 +- Panels/Layer.js | 2 +- Plotting/RecordValues.js | 62 ++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 12 deletions(-) create mode 100644 Plotting/RecordValues.js diff --git a/ChartingSpace/PlottersManager.js b/ChartingSpace/PlottersManager.js index 844a42987..2d3b9c35a 100644 --- a/ChartingSpace/PlottersManager.js +++ b/ChartingSpace/PlottersManager.js @@ -131,7 +131,7 @@ function newPlottersManager () { baseAsset: baseAsset, quotedAsset: quotedAsset } - let product = layer.definition.referenceParent.referenceParent + let productDefinition = layer.definition.referenceParent.referenceParent let bot = layer.definition.referenceParent.referenceParent.parentNode let dataMine = layer.definition.referenceParent.referenceParent.parentNode.parentNode let exchange = layer.definition.referenceParent.parentNode.referenceParent.parentNode.parentNode @@ -171,7 +171,7 @@ function newPlottersManager () { dataMine, bot, session, - product, + productDefinition, exchange, market, datetime, @@ -197,7 +197,7 @@ function newPlottersManager () { plotter.container.frame.position.x = thisObject.container.frame.width / 2 - plotter.container.frame.width / 2 plotter.container.frame.position.y = thisObject.container.frame.height / 2 - plotter.container.frame.height / 2 plotter.fitFunction = thisObject.fitFunction - plotter.initialize(storage, datetime, timeFrame, coordinateSystem, onPlotterInizialized, product) + plotter.initialize(storage, datetime, timeFrame, coordinateSystem, onPlotterInizialized, productDefinition) function onPlotterInizialized () { let connector = { @@ -210,7 +210,7 @@ function newPlottersManager () { /* Lets load now this plotter panels. */ connector.panels = [] - if (product !== undefined) { + if (productDefinition !== undefined) { /* Here we setup the panels associated with this plotter */ for (let i = 0; i < plotterModule.panels.length; i++) { let panel = plotterModule.panels[i] @@ -235,7 +235,7 @@ function newPlottersManager () { /* Next we will check the different types of Plotting related to connecting to an existing node branch. */ - if (plotterModule.nodesHighlights !== undefined) { + if (plotterModule.nodesHighlights !== undefined && plotterModule.config.connectTo !== undefined) { connector.nodesHighlights = newNodesHighlights() switch (plotterModule.config.connectTo) { case 'Trading System': @@ -247,7 +247,7 @@ function newPlottersManager () { } connector.nodesHighlights.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesHighlights.onRecordChange) } - if (plotterModule.nodesValues !== undefined) { + if (plotterModule.nodesValues !== undefined && plotterModule.config.connectTo !== undefined) { connector.nodesValues = newNodesValues() switch (plotterModule.config.connectTo) { case 'Trading System': @@ -259,7 +259,7 @@ function newPlottersManager () { } connector.nodesValues.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesValues.onRecordChange) } - if (plotterModule.nodesErrors !== undefined) { + if (plotterModule.nodesErrors !== undefined && plotterModule.config.connectTo !== undefined) { connector.nodesErrors = newNodesErrors() switch (plotterModule.config.connectTo) { case 'Trading System': @@ -271,7 +271,7 @@ function newPlottersManager () { } connector.nodesErrors.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesErrors.onRecordChange) } - if (plotterModule.nodesRunning !== undefined) { + if (plotterModule.nodesRunning !== undefined && plotterModule.config.connectTo !== undefined) { connector.nodesRunning = newNodesRunning() switch (plotterModule.config.connectTo) { case 'Trading System': @@ -283,7 +283,7 @@ function newPlottersManager () { } connector.nodesRunning.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesRunning.onRecordChange) } - if (plotterModule.nodesStatus !== undefined) { + if (plotterModule.nodesStatus !== undefined && plotterModule.config.connectTo !== undefined) { connector.nodesStatus = newNodesStatus() switch (plotterModule.config.connectTo) { case 'Trading System': @@ -295,7 +295,7 @@ function newPlottersManager () { } connector.nodesStatus.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesStatus.onRecordChange) } - if (plotterModule.nodesProgress !== undefined) { + if (plotterModule.nodesProgress !== undefined && plotterModule.config.connectTo !== undefined) { connector.nodesProgress = newNodesProgress() switch (plotterModule.config.connectTo) { case 'Trading System': @@ -307,6 +307,15 @@ function newPlottersManager () { } connector.nodesProgress.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesProgress.onRecordChange) } + /* + Another type of plotting is with Record Values. This method uses the record definition to find the target node + and from there is looks into its children all based on the Record Definition configuration. + */ + if (plotterModule.recordValues !== undefined) { + connector.recordValues = newRecordValues() + connector.recordValues.initialize(tradingSystem, tradingEngine, productDefinition) + connector.recordValues.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.recordValues.onRecordChange) + } } thisObject.connectors.push(connector) } @@ -383,6 +392,10 @@ function newPlottersManager () { connector.plotter.container.eventHandler.stopListening(connector.nodesRunning.onRecordChangeEventsSubscriptionId) connector.nodesRunning.finalize() } + if (connector.recordValues !== undefined) { + connector.plotter.container.eventHandler.stopListening(connector.recordValues.onRecordChangeEventsSubscriptionId) + connector.recordValues.finalize() + } } function setTimeFrame (pTimeFrame) { diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index cde2688e8..5203cbeaf 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -1432,7 +1432,7 @@ function newUiObject () { label = currentValue if (!isNaN(label)) { if (currentValue.toFixed !== undefined) { - label = dynamicDecimals(currentValue, 2) + label = dynamicDecimals(currentValue) } } diff --git a/Panels/Layer.js b/Panels/Layer.js index 1aa9e003f..45efdedbc 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -175,7 +175,7 @@ function newLayer () { 'Polygon Border->Style->Style Condition->Style->' + 'Polygon Vertex->Point->' + 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' + - 'Nodes Highlights->Nodes Values->Nodes Errors->Nodes Status->Nodes Progress->Nodes Running->' + 'Nodes Highlights->Nodes Values->Nodes Errors->Nodes Status->Nodes Progress->Nodes Running->Record Values->' thisObject.definition = functionLibraryProtocolNode.getProtocolNode(thisObject.payload.node, false, true, true, false, false, lightingPath) /* Here we validate that we have all the needed information */ diff --git a/Plotting/RecordValues.js b/Plotting/RecordValues.js new file mode 100644 index 000000000..b66ba150f --- /dev/null +++ b/Plotting/RecordValues.js @@ -0,0 +1,62 @@ +function newRecordValues () { + const MODULE_NAME = 'Record Values' + const logger = newWebDebugLog() + logger.fileName = MODULE_NAME + + let thisObject = { + onRecordChange: onRecordChange, + initialize: initialize, + finalize: finalize + } + + let tradingSystem + let tradingEngine + let productDefinition + let productTargetNode + let propertyTargetNodeMap = new Map() + return thisObject + + function finalize () { + tradingSystem = undefined + tradingEngine = undefined + productDefinition = undefined + productTargetNode = undefined + propertyTargetNodeMap = undefined + } + + function initialize (pTradingSystem, pTradingEngine, pProductDefinition) { + tradingSystem = canvas.designSpace.workspace.getHierarchyHeadsById(pTradingSystem.id) + tradingEngine = canvas.designSpace.workspace.getHierarchyHeadsById(pTradingEngine.id) + productDefinition = pProductDefinition + productTargetNode = eval(productDefinition.config.nodePath) + + for (let i = 0; i < productDefinition.record.properties.length; i++) { + let property = productDefinition.record.properties[i] + if (property.config.nodePath !== undefined) { + let propertyRoot = eval(property.config.nodePath) + propertyTargetNodeMap.set(property.id, propertyRoot) + } else { + propertyTargetNodeMap.set(property.id, productTargetNode) + } + } + } + + function onRecordChange (currentRecord) { + if (currentRecord === undefined) { return } + for (let i = 0; i < productDefinition.record.properties.length; i++) { + let property = productDefinition.record.properties[i] + let value = currentRecord[property.config.codeName] + let targetNode = propertyTargetNodeMap.get(property.id) + applyValue(targetNode[property.config.codeName], value) + } + } + + function applyValue (node, value) { + if (node === undefined) { return } + if (node.payload === undefined) { return } + if (node.payload.uiObject === undefined) { return } + if (value === true) { value = 'true' } + if (value === false) { value = 'false' } + node.payload.uiObject.setValue(value, 30) + } +} From f1b14f3996505c2fcea1648508e35329360c2236 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 18 Jun 2020 11:08:34 +0200 Subject: [PATCH 12/48] bug fixed --- Plotting/NodesErrors.js | 2 +- Plotting/NodesHighlights.js | 8 +++----- Plotting/NodesProgress.js | 2 +- Plotting/NodesRunning.js | 2 +- Plotting/NodesStatus.js | 2 +- Plotting/NodesValues.js | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Plotting/NodesErrors.js b/Plotting/NodesErrors.js index a331041d6..435bd9212 100644 --- a/Plotting/NodesErrors.js +++ b/Plotting/NodesErrors.js @@ -25,7 +25,7 @@ function newNodesErrors () { let array = currentRecord.errors if (array === undefined) { return } for (let i = 0; i < array.length; i++) { - let arrayItem = array[0] + let arrayItem = array[i] let nodeId = arrayItem[0] let value = arrayItem[1] applyValue(nodeId, value) diff --git a/Plotting/NodesHighlights.js b/Plotting/NodesHighlights.js index e63d7da99..c5cdb8420 100644 --- a/Plotting/NodesHighlights.js +++ b/Plotting/NodesHighlights.js @@ -26,14 +26,12 @@ function newNodesHighlights () { let array = currentRecord.highlights if (array === undefined) { return } for (let i = 0; i < array.length; i++) { - let arrayItem = array[0] - let nodeId = arrayItem[0] - let value = arrayItem[1] - applyValue(nodeId, value) + let nodeId = array[i] + highlight(nodeId) } } - function applyValue (nodeId, value) { + function highlight (nodeId) { let node = hiriarchyMap.get(nodeId) if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } diff --git a/Plotting/NodesProgress.js b/Plotting/NodesProgress.js index 627a4e1e5..d4f08dc9d 100644 --- a/Plotting/NodesProgress.js +++ b/Plotting/NodesProgress.js @@ -26,7 +26,7 @@ function newNodesProgress () { let array = currentRecord.progress if (array === undefined) { return } for (let i = 0; i < array.length; i++) { - let arrayItem = array[0] + let arrayItem = array[i] let nodeId = arrayItem[0] let value = arrayItem[1] applyValue(nodeId, value) diff --git a/Plotting/NodesRunning.js b/Plotting/NodesRunning.js index 2be348875..e2694910e 100644 --- a/Plotting/NodesRunning.js +++ b/Plotting/NodesRunning.js @@ -26,7 +26,7 @@ function newNodesRunning () { let array = currentRecord.running if (array === undefined) { return } for (let i = 0; i < array.length; i++) { - let arrayItem = array[0] + let arrayItem = array[i] let nodeId = arrayItem[0] let value = arrayItem[1] applyValue(nodeId, value) diff --git a/Plotting/NodesStatus.js b/Plotting/NodesStatus.js index d95e8cef2..cb86bc1bd 100644 --- a/Plotting/NodesStatus.js +++ b/Plotting/NodesStatus.js @@ -26,7 +26,7 @@ function newNodesStatus () { let array = currentRecord.status if (array === undefined) { return } for (let i = 0; i < array.length; i++) { - let arrayItem = array[0] + let arrayItem = array[i] let nodeId = arrayItem[0] let value = arrayItem[1] applyValue(nodeId, value) diff --git a/Plotting/NodesValues.js b/Plotting/NodesValues.js index 23559cfc3..160e15c78 100644 --- a/Plotting/NodesValues.js +++ b/Plotting/NodesValues.js @@ -26,7 +26,7 @@ function newNodesValues () { let array = currentRecord.values if (array === undefined) { return } for (let i = 0; i < array.length; i++) { - let arrayItem = array[0] + let arrayItem = array[i] let nodeId = arrayItem[0] let value = arrayItem[1] applyValue(nodeId, value) From d1d017caf223cc299e8b3ca7fa9e9297b6b27405 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 18 Jun 2020 15:21:30 +0200 Subject: [PATCH 13/48] Update NodesHighlights.js --- Plotting/NodesHighlights.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Plotting/NodesHighlights.js b/Plotting/NodesHighlights.js index c5cdb8420..3408bf6cb 100644 --- a/Plotting/NodesHighlights.js +++ b/Plotting/NodesHighlights.js @@ -33,6 +33,7 @@ function newNodesHighlights () { function highlight (nodeId) { let node = hiriarchyMap.get(nodeId) + if (node === undefined) { return } if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } node.payload.uiObject.highlight() From c72f3b8153ad1c86d39f44315a3bb321638edfc3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 18 Jun 2020 16:02:34 +0200 Subject: [PATCH 14/48] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 5c72a28a7..56247ec70 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -57,6 +57,8 @@ function newSessionFunctions () { 'Strategy Counters->Periods->' + 'Position->' + 'Begin->End->Rate->Size->Exit Type->Status->Begin Rate->End Rate->Situation Name->' + + 'Stop Loss->Stop Loss Stage->Stop Loss Phase->' + + 'Take Profit->Take Profit Stage->Take Profit Phase->' + 'Position Counters->Periods->' + 'Position Statistics->Days->ROI->User Defined Statistic->' + 'Formula' From 0b10b04438130a0030f7265ad4e602e7f3328e13 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 18 Jun 2020 17:02:53 +0200 Subject: [PATCH 15/48] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 56247ec70..0b6274009 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -60,7 +60,7 @@ function newSessionFunctions () { 'Stop Loss->Stop Loss Stage->Stop Loss Phase->' + 'Take Profit->Take Profit Stage->Take Profit Phase->' + 'Position Counters->Periods->' + - 'Position Statistics->Days->ROI->User Defined Statistic->' + + 'Position Statistics->Profit Loss->Days->ROI->User Defined Statistic->' + 'Formula' let tradingEngine = functionLibraryProtocolNode.getProtocolNode(node.tradingEngineReference.payload.referenceParent, false, true, true, false, false, lightingPath) From 112bc828dcd98c72a7f1748a022690a02796d396 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 20 Jun 2020 18:27:53 +0200 Subject: [PATCH 16/48] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 0b6274009..4f152f951 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -32,7 +32,7 @@ function newSessionFunctions () { 'Initial Stop->Initial Take Profit->' + 'Manage Stage->' + 'Stop->Take Profit->' + - 'Phase->Formula->Next Phase Event->Move to Phase Event->Phase->' + + 'Phase->Formula->Next Phase Event->Move To Phase Event->Phase->' + 'Situation->Condition->Javascript Code->' + 'Close Stage->Close Execution->' + 'Announcement->Formula->' From c6211feaec39c8050e6ad69624358c12ae98a008 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 21 Jun 2020 14:22:39 +0200 Subject: [PATCH 17/48] Plotting Images --- Panels/Layer.js | 1 + Plotting/Plotter.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Panels/Layer.js b/Panels/Layer.js index 45efdedbc..0220a3230 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -174,6 +174,7 @@ function newLayer () { 'Polygon->Polygon Condition->Polygon Body->Style->Style Condition->Style->' + 'Polygon Border->Style->Style Condition->Style->' + 'Polygon Vertex->Point->' + + 'Image->Image Position->Point->' + 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' + 'Nodes Highlights->Nodes Values->Nodes Errors->Nodes Status->Nodes Progress->Nodes Running->Record Values->' thisObject.definition = functionLibraryProtocolNode.getProtocolNode(thisObject.payload.node, false, true, true, false, false, lightingPath) diff --git a/Plotting/Plotter.js b/Plotting/Plotter.js index 6c4bd2009..d712af407 100644 --- a/Plotting/Plotter.js +++ b/Plotting/Plotter.js @@ -589,6 +589,7 @@ function newPlotter () { record.dataPoints = dataPoints } + /* Here we are going to plot all the polygons. */ for (let j = 0; j < productDefinition.referenceParent.shapes.polygons.length; j++) { let polygon = productDefinition.referenceParent.shapes.polygons[j] /* We will check if we need to plot this Polygon or not. */ @@ -775,6 +776,35 @@ function newPlotter () { browserCanvasContext.stroke() } } + + /* Here we are going to plot images. */ + for (let j = 0; j < productDefinition.referenceParent.shapes.images.length; j++) { + let image = productDefinition.referenceParent.shapes.images[j] + if (image.imagePosition === undefined) { continue } + if (image.imagePosition.referenceParent === undefined) { continue } + let imageName = '' + let imageSize = 0 + let offsetX = 0 + let offsetY = 0 + let imagePosition = {x: 0, y: 0} + if (image.config.codeName !== undefined) { imageName = image.config.codeName } + if (image.config.size !== undefined) { imageSize = image.config.size } + if (image.imagePosition.config.offsetX !== undefined) { offsetX = image.imagePosition.config.offsetX } + if (image.imagePosition.config.offsetY !== undefined) { offsetX = image.imagePosition.config.offsetY } + let dataPointObject = dataPoints.get(image.imagePosition.referenceParent.id) + let dataPoint = { + x: dataPointObject.x, + y: dataPointObject.y + } + dataPoint = canvas.chartingSpace.viewport.fitIntoVisibleArea(dataPoint) + dataPoint = thisObject.fitFunction(dataPoint) + imagePosition.x = dataPoint.x + imagePosition.y = dataPoint.y + let imageToDraw = canvas.designSpace.iconCollection.get(imageName) + if (imageToDraw.canDrawIcon === true) { + browserCanvasContext.drawImage(imageToDraw, imagePosition.x - imageSize / 2 + offsetX, imagePosition.y - imageSize / 2 + offsetY, imageSize, imageSize) + } + } } if (coordinateSystem.autoMinYScale === true || coordinateSystem.autoMinYScale === true) { From bcebb314abc61aa592af27549a1bdcda2ad21f93 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 22 Jun 2020 19:20:09 +0200 Subject: [PATCH 18/48] Images and Texts on plotters --- Panels/Layer.js | 3 ++- Plotting/Plotter.js | 50 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index 0220a3230..bff8cc5a9 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -174,7 +174,8 @@ function newLayer () { 'Polygon->Polygon Condition->Polygon Body->Style->Style Condition->Style->' + 'Polygon Border->Style->Style Condition->Style->' + 'Polygon Vertex->Point->' + - 'Image->Image Position->Point->' + + 'Image->Image Condition->Image Position->Point->' + + 'Text->Text Condition->Text Position->Point->Text Formula->Text Style->' + 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' + 'Nodes Highlights->Nodes Values->Nodes Errors->Nodes Status->Nodes Progress->Nodes Running->Record Values->' thisObject.definition = functionLibraryProtocolNode.getProtocolNode(thisObject.payload.node, false, true, true, false, false, lightingPath) diff --git a/Plotting/Plotter.js b/Plotting/Plotter.js index d712af407..9171fbf4e 100644 --- a/Plotting/Plotter.js +++ b/Plotting/Plotter.js @@ -502,7 +502,7 @@ function newPlotter () { To enable that we need to link all records to the previous one in this way. */ if (i == 0) { - record.previous = record + record.previous = {} // this way it wont be undefined } else { record.previous = records[i - 1] } @@ -782,6 +782,10 @@ function newPlotter () { let image = productDefinition.referenceParent.shapes.images[j] if (image.imagePosition === undefined) { continue } if (image.imagePosition.referenceParent === undefined) { continue } + if (image.imageCondition !== undefined) { + let mustPlot = eval(image.imageCondition.code) + if (mustPlot !== true) { continue } + } let imageName = '' let imageSize = 0 let offsetX = 0 @@ -790,8 +794,9 @@ function newPlotter () { if (image.config.codeName !== undefined) { imageName = image.config.codeName } if (image.config.size !== undefined) { imageSize = image.config.size } if (image.imagePosition.config.offsetX !== undefined) { offsetX = image.imagePosition.config.offsetX } - if (image.imagePosition.config.offsetY !== undefined) { offsetX = image.imagePosition.config.offsetY } + if (image.imagePosition.config.offsetY !== undefined) { offsetY = image.imagePosition.config.offsetY } let dataPointObject = dataPoints.get(image.imagePosition.referenceParent.id) + if (dataPointObject === undefined) { continue } let dataPoint = { x: dataPointObject.x, y: dataPointObject.y @@ -802,9 +807,48 @@ function newPlotter () { imagePosition.y = dataPoint.y let imageToDraw = canvas.designSpace.iconCollection.get(imageName) if (imageToDraw.canDrawIcon === true) { - browserCanvasContext.drawImage(imageToDraw, imagePosition.x - imageSize / 2 + offsetX, imagePosition.y - imageSize / 2 + offsetY, imageSize, imageSize) + browserCanvasContext.drawImage(imageToDraw, imagePosition.x - imageSize / 2 + offsetX, imagePosition.y - imageSize / 2 - offsetY, imageSize, imageSize) } } + + /* Here we are going to plot texts. */ + for (let j = 0; j < productDefinition.referenceParent.shapes.texts.length; j++) { + let text = productDefinition.referenceParent.shapes.texts[j] + if (text.textPosition === undefined) { continue } + if (text.textPosition.referenceParent === undefined) { continue } + if (text.textCondition !== undefined) { + let mustPlot = eval(text.textCondition.code) + if (mustPlot !== true) { continue } + } + if (text.textFormula === undefined) { continue } + if (text.textStyle === undefined) { continue } + let value = eval(text.textFormula.code) + let fontSize = 0 + let opacity = 0 + let paletteColor = UI_COLOR.GREY + let offsetX = 0 + let offsetY = 0 + let textPosition = {x: 0, y: 0} + if (text.textStyle.config.fontSize !== undefined) { fontSize = text.textStyle.config.fontSize } + if (text.textStyle.config.opacity !== undefined) { opacity = text.textStyle.config.opacity } + if (text.textStyle.config.paletteColor !== undefined) { paletteColor = eval(text.textStyle.config.paletteColor) } + if (text.textPosition.config.offsetX !== undefined) { offsetX = text.textPosition.config.offsetX } + if (text.textPosition.config.offsetY !== undefined) { offsetY = text.textPosition.config.offsetY } + let dataPointObject = dataPoints.get(text.textPosition.referenceParent.id) + if (dataPointObject === undefined) { continue } + let dataPoint = { + x: dataPointObject.x, + y: dataPointObject.y + } + dataPoint = canvas.chartingSpace.viewport.fitIntoVisibleArea(dataPoint) + dataPoint = thisObject.fitFunction(dataPoint) + textPosition.x = dataPoint.x + textPosition.y = dataPoint.y + + browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY + browserCanvasContext.fillStyle = 'rgba(' + paletteColor + ', ' + opacity + ')' + browserCanvasContext.fillText(value, textPosition.x + offsetX, textPosition.y - offsetY) + } } if (coordinateSystem.autoMinYScale === true || coordinateSystem.autoMinYScale === true) { From f45ea412f7f6cee7469d6d5af96bd0d4de3edeca Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 23 Jun 2020 12:07:15 +0200 Subject: [PATCH 19/48] bug fixed --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 +- Plotting/NodesValues.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 4f152f951..2422ccb10 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -31,7 +31,7 @@ function newSessionFunctions () { 'Position Size->Position Rate->Formula->' + 'Initial Stop->Initial Take Profit->' + 'Manage Stage->' + - 'Stop->Take Profit->' + + 'Managed Stop Loss->Managed Take Profit->' + 'Phase->Formula->Next Phase Event->Move To Phase Event->Phase->' + 'Situation->Condition->Javascript Code->' + 'Close Stage->Close Execution->' + diff --git a/Plotting/NodesValues.js b/Plotting/NodesValues.js index 160e15c78..6ce4c139d 100644 --- a/Plotting/NodesValues.js +++ b/Plotting/NodesValues.js @@ -39,7 +39,7 @@ function newNodesValues () { if (node.payload.uiObject === undefined) { return } if (value === true) { value = 'true' } if (value === false) { value = 'false' } - node.payload.uiObject.setValue(value, 30) + node.payload.uiObject.setValue(value, 1) } } From 7b83d322845fdef85110a37813b14e0ef2488280 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 23 Jun 2020 14:27:39 +0200 Subject: [PATCH 20/48] Bug fixed --- Plotting/NodesErrors.js | 1 + Plotting/NodesProgress.js | 1 + Plotting/NodesRunning.js | 1 + Plotting/NodesStatus.js | 1 + Plotting/NodesValues.js | 1 + Plotting/Plotter.js | 7 ++----- Plotting/RecordValues.js | 1 + 7 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Plotting/NodesErrors.js b/Plotting/NodesErrors.js index 435bd9212..7ba365848 100644 --- a/Plotting/NodesErrors.js +++ b/Plotting/NodesErrors.js @@ -34,6 +34,7 @@ function newNodesErrors () { function applyValue (nodeId, value) { let node = hiriarchyMap.get(nodeId) + if (node === undefined) { return } if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } if (value === '') { diff --git a/Plotting/NodesProgress.js b/Plotting/NodesProgress.js index d4f08dc9d..57df4759f 100644 --- a/Plotting/NodesProgress.js +++ b/Plotting/NodesProgress.js @@ -35,6 +35,7 @@ function newNodesProgress () { function applyValue (nodeId, value) { let node = hiriarchyMap.get(nodeId) + if (node === undefined) { return } if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } if (value === true) { value = 'true' } diff --git a/Plotting/NodesRunning.js b/Plotting/NodesRunning.js index e2694910e..862753643 100644 --- a/Plotting/NodesRunning.js +++ b/Plotting/NodesRunning.js @@ -35,6 +35,7 @@ function newNodesRunning () { function applyValue (nodeId, value) { let node = hiriarchyMap.get(nodeId) + if (node === undefined) { return } if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } if (value === true) { value = 'true' } diff --git a/Plotting/NodesStatus.js b/Plotting/NodesStatus.js index cb86bc1bd..0544c1114 100644 --- a/Plotting/NodesStatus.js +++ b/Plotting/NodesStatus.js @@ -35,6 +35,7 @@ function newNodesStatus () { function applyValue (nodeId, value) { let node = hiriarchyMap.get(nodeId) + if (node === undefined) { return } if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } if (value === true) { value = 'true' } diff --git a/Plotting/NodesValues.js b/Plotting/NodesValues.js index 6ce4c139d..eb97dfeeb 100644 --- a/Plotting/NodesValues.js +++ b/Plotting/NodesValues.js @@ -35,6 +35,7 @@ function newNodesValues () { function applyValue (nodeId, value) { let node = hiriarchyMap.get(nodeId) + if (node === undefined) { return } if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } if (value === true) { value = 'true' } diff --git a/Plotting/Plotter.js b/Plotting/Plotter.js index 9171fbf4e..bdb2d3d05 100644 --- a/Plotting/Plotter.js +++ b/Plotting/Plotter.js @@ -252,6 +252,7 @@ function newPlotter () { } function recalculate () { + if (canvas.chartingSpace.visible !== true) { return } try { if (timeFrame >= _1_HOUR_IN_MILISECONDS) { recalculateUsingMarketFiles() @@ -873,11 +874,7 @@ function newPlotter () { } function onDragFinished () { - try { - recalculate() - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] onDragFinished -> err = ' + err.stack) } - } + recalculate() } function onDisplace (event) { diff --git a/Plotting/RecordValues.js b/Plotting/RecordValues.js index b66ba150f..1d2fd6bec 100644 --- a/Plotting/RecordValues.js +++ b/Plotting/RecordValues.js @@ -52,6 +52,7 @@ function newRecordValues () { } function applyValue (node, value) { + if (node === undefined) { return } if (node === undefined) { return } if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } From db855a1b59db2c99884e4647d510d0553892c0fc Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 24 Jun 2020 18:07:59 +0200 Subject: [PATCH 21/48] bug fixed --- Plotting/NodesErrors.js | 1 + Plotting/NodesHighlights.js | 1 + Plotting/NodesProgress.js | 1 + Plotting/NodesRunning.js | 1 + Plotting/NodesStatus.js | 1 + Plotting/NodesValues.js | 1 + Plotting/RecordValues.js | 1 + 7 files changed, 7 insertions(+) diff --git a/Plotting/NodesErrors.js b/Plotting/NodesErrors.js index 7ba365848..1a083597d 100644 --- a/Plotting/NodesErrors.js +++ b/Plotting/NodesErrors.js @@ -33,6 +33,7 @@ function newNodesErrors () { } function applyValue (nodeId, value) { + if (canvas.chartingSpace.visible !== true) { return } let node = hiriarchyMap.get(nodeId) if (node === undefined) { return } if (node.payload === undefined) { return } diff --git a/Plotting/NodesHighlights.js b/Plotting/NodesHighlights.js index 3408bf6cb..2ab8e09e5 100644 --- a/Plotting/NodesHighlights.js +++ b/Plotting/NodesHighlights.js @@ -32,6 +32,7 @@ function newNodesHighlights () { } function highlight (nodeId) { + if (canvas.chartingSpace.visible !== true) { return } let node = hiriarchyMap.get(nodeId) if (node === undefined) { return } if (node.payload === undefined) { return } diff --git a/Plotting/NodesProgress.js b/Plotting/NodesProgress.js index 57df4759f..cba36be9f 100644 --- a/Plotting/NodesProgress.js +++ b/Plotting/NodesProgress.js @@ -34,6 +34,7 @@ function newNodesProgress () { } function applyValue (nodeId, value) { + if (canvas.chartingSpace.visible !== true) { return } let node = hiriarchyMap.get(nodeId) if (node === undefined) { return } if (node.payload === undefined) { return } diff --git a/Plotting/NodesRunning.js b/Plotting/NodesRunning.js index 862753643..130a7a8f8 100644 --- a/Plotting/NodesRunning.js +++ b/Plotting/NodesRunning.js @@ -34,6 +34,7 @@ function newNodesRunning () { } function applyValue (nodeId, value) { + if (canvas.chartingSpace.visible !== true) { return } let node = hiriarchyMap.get(nodeId) if (node === undefined) { return } if (node.payload === undefined) { return } diff --git a/Plotting/NodesStatus.js b/Plotting/NodesStatus.js index 0544c1114..699c70741 100644 --- a/Plotting/NodesStatus.js +++ b/Plotting/NodesStatus.js @@ -34,6 +34,7 @@ function newNodesStatus () { } function applyValue (nodeId, value) { + if (canvas.chartingSpace.visible !== true) { return } let node = hiriarchyMap.get(nodeId) if (node === undefined) { return } if (node.payload === undefined) { return } diff --git a/Plotting/NodesValues.js b/Plotting/NodesValues.js index eb97dfeeb..53dfbfa60 100644 --- a/Plotting/NodesValues.js +++ b/Plotting/NodesValues.js @@ -34,6 +34,7 @@ function newNodesValues () { } function applyValue (nodeId, value) { + if (canvas.chartingSpace.visible !== true) { return } let node = hiriarchyMap.get(nodeId) if (node === undefined) { return } if (node.payload === undefined) { return } diff --git a/Plotting/RecordValues.js b/Plotting/RecordValues.js index 1d2fd6bec..1f41fdc12 100644 --- a/Plotting/RecordValues.js +++ b/Plotting/RecordValues.js @@ -52,6 +52,7 @@ function newRecordValues () { } function applyValue (node, value) { + if (canvas.chartingSpace.visible !== true) { return } if (node === undefined) { return } if (node === undefined) { return } if (node.payload === undefined) { return } From 7b3760a17dcf60c768f75b399fd90e669429c8fa Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 24 Jun 2020 18:13:49 +0200 Subject: [PATCH 22/48] highlights adjustments --- FloatingSpace/UiObject.js | 10 +++++++--- Plotting/NodesHighlights.js | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 5203cbeaf..2e5bf0b2c 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -716,9 +716,13 @@ function newUiObject () { } } - function highlight () { + function highlight (counter) { isHighlighted = true - highlightCounter = 30 + if (counter !== undefined) { + highlightCounter = counter + } else { + highlightCounter = 30 + } } function runningAtBackend () { @@ -1718,7 +1722,7 @@ function newUiObject () { if (isHighlighted === true) { VISIBLE_RADIUS = thisObject.container.frame.radius * 1 - let OPACITY = highlightCounter / 30 + let OPACITY = highlightCounter / 10 browserCanvasContext.beginPath() browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) diff --git a/Plotting/NodesHighlights.js b/Plotting/NodesHighlights.js index 2ab8e09e5..443166ad6 100644 --- a/Plotting/NodesHighlights.js +++ b/Plotting/NodesHighlights.js @@ -37,6 +37,6 @@ function newNodesHighlights () { if (node === undefined) { return } if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } - node.payload.uiObject.highlight() + node.payload.uiObject.highlight(10) } } From c4dcc19349b7edca74308fc131eadcebd65bd3d8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 27 Jun 2020 14:52:52 +0200 Subject: [PATCH 23/48] Announcements Plotted at Trading System --- ChartingSpace/PlottersManager.js | 12 +++++++++ Panels/Layer.js | 2 +- Plotting/NodesAnnouncements.js | 46 ++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 Plotting/NodesAnnouncements.js diff --git a/ChartingSpace/PlottersManager.js b/ChartingSpace/PlottersManager.js index 2d3b9c35a..3b76c7698 100644 --- a/ChartingSpace/PlottersManager.js +++ b/ChartingSpace/PlottersManager.js @@ -307,6 +307,18 @@ function newPlottersManager () { } connector.nodesProgress.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesProgress.onRecordChange) } + if (plotterModule.nodesAnnouncements !== undefined && plotterModule.config.connectTo !== undefined) { + connector.nodesAnnounements = newNodesAnnouncements() + switch (plotterModule.config.connectTo) { + case 'Trading System': + connector.nodesAnnounements.initialize(tradingSystem) + break + case 'Trading Engine': + connector.nodesAnnounements.initialize(tradingEngine) + break + } + connector.nodesAnnounements.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesAnnounements.onRecordChange) + } /* Another type of plotting is with Record Values. This method uses the record definition to find the target node and from there is looks into its children all based on the Record Definition configuration. diff --git a/Panels/Layer.js b/Panels/Layer.js index bff8cc5a9..cc2514911 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -177,7 +177,7 @@ function newLayer () { 'Image->Image Condition->Image Position->Point->' + 'Text->Text Condition->Text Position->Point->Text Formula->Text Style->' + 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' + - 'Nodes Highlights->Nodes Values->Nodes Errors->Nodes Status->Nodes Progress->Nodes Running->Record Values->' + 'Nodes Highlights->Nodes Values->Nodes Errors->Nodes Status->Nodes Progress->Nodes Running->Nodes Announcements->Record Values->' thisObject.definition = functionLibraryProtocolNode.getProtocolNode(thisObject.payload.node, false, true, true, false, false, lightingPath) /* Here we validate that we have all the needed information */ diff --git a/Plotting/NodesAnnouncements.js b/Plotting/NodesAnnouncements.js new file mode 100644 index 000000000..be6d257ac --- /dev/null +++ b/Plotting/NodesAnnouncements.js @@ -0,0 +1,46 @@ +function newNodesAnnouncements () { + const MODULE_NAME = 'Nodes Announcements' + const logger = newWebDebugLog() + logger.fileName = MODULE_NAME + + let thisObject = { + onRecordChange: onRecordChange, + initialize: initialize, + finalize: finalize + } + + let hiriarchyMap + return thisObject + + function finalize () { + hiriarchyMap = undefined + } + + function initialize (pRootNode) { + let rootNode = canvas.designSpace.workspace.getHierarchyHeadsById(pRootNode.id) + hiriarchyMap = getHiriarchyMap(rootNode) + } + + function onRecordChange (currentRecord) { + if (currentRecord === undefined) { return } + let array = currentRecord.announcements + if (array === undefined) { return } + for (let i = 0; i < array.length; i++) { + let arrayItem = array[i] + let nodeId = arrayItem[0] + let value = arrayItem[1] + applyValue(nodeId, value) + } + } + + function applyValue (nodeId, value) { + if (canvas.chartingSpace.visible !== true) { return } + let node = hiriarchyMap.get(nodeId) + if (node === undefined) { return } + if (node.payload === undefined) { return } + if (node.payload.uiObject === undefined) { return } + if (value === true) { value = 'true' } + if (value === false) { value = 'false' } + node.payload.uiObject.setValue(value, 1) + } +} From 5cebbfdf0aad65f1987e9525a7c5ea8ec5bd600e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 27 Jun 2020 15:01:54 +0200 Subject: [PATCH 24/48] Update NodesAnnouncements.js --- Plotting/NodesAnnouncements.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plotting/NodesAnnouncements.js b/Plotting/NodesAnnouncements.js index be6d257ac..16116df03 100644 --- a/Plotting/NodesAnnouncements.js +++ b/Plotting/NodesAnnouncements.js @@ -41,6 +41,6 @@ function newNodesAnnouncements () { if (node.payload.uiObject === undefined) { return } if (value === true) { value = 'true' } if (value === false) { value = 'false' } - node.payload.uiObject.setValue(value, 1) + node.payload.uiObject.setValue(value, 20) } } From ebce27b706fe548318cd9d9f37ba96e0619c96fd Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 28 Jun 2020 15:29:09 +0200 Subject: [PATCH 25/48] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 2422ccb10..0f6c29a06 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -68,7 +68,7 @@ function newSessionFunctions () { lightingPath = '' + 'Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + 'Parameters->' + - 'Session Base Asset->Session Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->User Defined Parameters->' + + 'Session Base Asset->Session Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->Sanpshots->User Defined Parameters->' + 'Exchange Account Asset->Asset->' + 'Social Bots->Telegram Bot->' From 8916764e2e82a2705b9a6a62406fd28d3805c6c8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 29 Jun 2020 13:21:14 +0200 Subject: [PATCH 26/48] Snapshots working --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 0f6c29a06..8d3f50c2a 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -60,7 +60,7 @@ function newSessionFunctions () { 'Stop Loss->Stop Loss Stage->Stop Loss Phase->' + 'Take Profit->Take Profit Stage->Take Profit Phase->' + 'Position Counters->Periods->' + - 'Position Statistics->Profit Loss->Days->ROI->User Defined Statistic->' + + 'Position Statistics->Profit Loss->Days->ROI->Hit Fail->User Defined Statistic->' + 'Formula' let tradingEngine = functionLibraryProtocolNode.getProtocolNode(node.tradingEngineReference.payload.referenceParent, false, true, true, false, false, lightingPath) @@ -68,7 +68,7 @@ function newSessionFunctions () { lightingPath = '' + 'Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + 'Parameters->' + - 'Session Base Asset->Session Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->Sanpshots->User Defined Parameters->' + + 'Session Base Asset->Session Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->Snapshots->User Defined Parameters->' + 'Exchange Account Asset->Asset->' + 'Social Bots->Telegram Bot->' From 48e122ce6c9552978040d0cec4892e87a7400645 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 6 Jul 2020 15:34:17 +0200 Subject: [PATCH 27/48] Update RecordValues.js --- Plotting/RecordValues.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plotting/RecordValues.js b/Plotting/RecordValues.js index 1f41fdc12..2e66ad2da 100644 --- a/Plotting/RecordValues.js +++ b/Plotting/RecordValues.js @@ -59,6 +59,6 @@ function newRecordValues () { if (node.payload.uiObject === undefined) { return } if (value === true) { value = 'true' } if (value === false) { value = 'false' } - node.payload.uiObject.setValue(value, 30) + node.payload.uiObject.setValue(value, 1) } } From accb284a2dab9fd52763b029ab4b5477587f339f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 7 Jul 2020 19:15:53 +0200 Subject: [PATCH 28/48] Ports Changed --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 6 +++++- EventsServerClient.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 8d3f50c2a..549d3b64e 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -35,7 +35,11 @@ function newSessionFunctions () { 'Phase->Formula->Next Phase Event->Move To Phase Event->Phase->' + 'Situation->Condition->Javascript Code->' + 'Close Stage->Close Execution->' + - 'Announcement->Formula->' + 'Announcement->Formula->' + + 'Execution Algorithm->Market Buy Order->Market Sell Order->Limit Buy Order->Limit Sell Order->' + + 'Position Size->Position Rate->Formula->' + + 'Create Order Event->Move Order Event->Cancel Order Event->' + + 'Situation->Condition->' let tradingSystem = functionLibraryProtocolNode.getProtocolNode(node.tradingSystemReference.payload.referenceParent, false, true, true, false, false, lightingPath) diff --git a/EventsServerClient.js b/EventsServerClient.js index 247636f03..b56712a6c 100644 --- a/EventsServerClient.js +++ b/EventsServerClient.js @@ -9,7 +9,7 @@ function newEventsServerClient (host, port, hostName) { logger.fileName = MODULE_NAME if (host === '' || host === undefined) { host = 'localhost' } - if (port === '' || port === undefined) { port = '8080' } + if (port === '' || port === undefined) { port = '8081' } const WEB_SOCKETS_URL = 'ws://' + host + ':' + port + '' let WEB_SOCKETS_CONNECTION From 7ea65f7d688e35fea203396c6bc2ac424642f63d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jul 2020 10:40:53 +0200 Subject: [PATCH 29/48] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 549d3b64e..3fec40fca 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -39,7 +39,7 @@ function newSessionFunctions () { 'Execution Algorithm->Market Buy Order->Market Sell Order->Limit Buy Order->Limit Sell Order->' + 'Position Size->Position Rate->Formula->' + 'Create Order Event->Move Order Event->Cancel Order Event->' + - 'Situation->Condition->' + 'Situation->Condition->Javascript Code->' let tradingSystem = functionLibraryProtocolNode.getProtocolNode(node.tradingSystemReference.payload.referenceParent, false, true, true, false, false, lightingPath) From 07d72e2ce02d11e160d3f6ef6898154ce28c2d22 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jul 2020 11:22:37 +0200 Subject: [PATCH 30/48] Initialization Bug Fixed --- DesignSpace/Workspace/FunctionLibraries/OnFocus.js | 4 ++-- DesignSpace/Workspace/Workspace.js | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/OnFocus.js b/DesignSpace/Workspace/FunctionLibraries/OnFocus.js index 21596fb7c..716114348 100644 --- a/DesignSpace/Workspace/FunctionLibraries/OnFocus.js +++ b/DesignSpace/Workspace/FunctionLibraries/OnFocus.js @@ -5,9 +5,9 @@ function newOnFocus () { return thisObject function getNodeThatIsOnFocus (node) { - if (node === undefined) { return } + if (node === undefined || node === null) { return } if (node.payload === undefined) { return } - let nodeDefinition = getNodeDefinition (node) + let nodeDefinition = getNodeDefinition(node) if (nodeDefinition !== undefined) { /* First we ask the question to ourself */ if (node.payload.uiObject.isOnFocus === true) { diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 4cd40ff89..5f1c80761 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -67,6 +67,7 @@ function newWorkspace () { thisObject.nodeChildren = newNodeChildren() + let isInitialized = false let workingAtTask = 0 let circularProgressBar = newBusyProgressBar() circularProgressBar.fitFunction = canvas.floatingSpace.fitIntoVisibleArea @@ -118,6 +119,7 @@ function newWorkspace () { canvas.cockpitSpace.initializePosition() canvas.splashScreen.initialize() setInterval(saveWorkspace, 60000) + isInitialized = true } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } @@ -186,17 +188,10 @@ function newWorkspace () { } function saveWorkspace () { + if (isInitialized === false) { return } /* When there is an exception while loading the app, the rootNodes of the workspace get into null value. To avoid saving a corrupt staate we are going to verufy we are not in that situation before saving. */ let workspace = canvas.designSpace.workspace.workspaceNode - for (let i = 0; i < workspace.rootNodes.length; i++) { - let rootNode = workspace.rootNodes[i] - if (rootNode === null) { - canvas.cockpitSpace.setStatus('Could not save the Workspace. The state of the workspace in memory is corrupt, please reload the App.', 150, canvas.cockpitSpace.statusTypes.WARNING) - return - } - } - let savedSessionTimestamp = window.localStorage.getItem('Session Timestamp') if (Number(savedSessionTimestamp) !== sessionTimestamp) { canvas.cockpitSpace.setStatus('Could not save the Workspace. You have more that one instance of the Superlagos User Interface open at the same time. Plese close this instance as it is older than the others.', 150, canvas.cockpitSpace.statusTypes.WARNING) From c2ea3a287917fc46e246b6f0a2002794258d0ac2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jul 2020 10:34:29 +0200 Subject: [PATCH 31/48] Update UiObjectTitle.js --- FloatingSpace/UiObjectTitle.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/FloatingSpace/UiObjectTitle.js b/FloatingSpace/UiObjectTitle.js index 89e39c5c0..2a6215ac5 100644 --- a/FloatingSpace/UiObjectTitle.js +++ b/FloatingSpace/UiObjectTitle.js @@ -51,7 +51,7 @@ function newUiObjectTitle () { thisObject.payload = payload thisObject.allwaysVisible = false // Default value - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.isTitleAllwaysVisible === true) { thisObject.allwaysVisible = true @@ -100,7 +100,7 @@ function newUiObjectTitle () { if (thisObject.payload.title === undefined) { return } /* It is possible to override the default title by setting the APP SCHEMA property 'title' */ - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition.title !== undefined) { thisObject.payload.title = '' thisObject.payload.node.name = '' @@ -170,6 +170,7 @@ function newUiObjectTitle () { if (titleReference.indexOf('Use Child @') === 0) { let propertyName = titleReference.substring(titleReference.indexOf('@') + 1, titleReference.length) let childNode = thisObject.payload.node[propertyName] + if (childNode === undefined) { break } thisObject.payload.title = thisObject.payload.title + separator + childNode.name thisObject.payload.node.name = thisObject.payload.node.name + separator + childNode.name } @@ -221,7 +222,7 @@ function newUiObjectTitle () { } function onMouseClick (event) { - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition.title !== undefined) { return } let checkPoint = { @@ -329,7 +330,7 @@ function newUiObjectTitle () { labelPoint.x = labelPoint.x - label.length / 2 * fontSize * FONT_ASPECT_RATIO labelPoint.y = labelPoint.y - 35 - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.isHierarchyHead !== true) { return From cd86336ff6671d6b524f7611d1221866df699c1a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 12 Jul 2020 13:13:31 +0200 Subject: [PATCH 32/48] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 3fec40fca..cf542c601 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -37,6 +37,7 @@ function newSessionFunctions () { 'Close Stage->Close Execution->' + 'Announcement->Formula->' + 'Execution Algorithm->Market Buy Order->Market Sell Order->Limit Buy Order->Limit Sell Order->' + + 'Market Order->Limit Order->' 'Position Size->Position Rate->Formula->' + 'Create Order Event->Move Order Event->Cancel Order Event->' + 'Situation->Condition->Javascript Code->' From 288fbb78e642e3e1d05f132066462c73be5b39b6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 13 Jul 2020 14:45:26 +0200 Subject: [PATCH 33/48] Update SessionFunctions.js --- .../FunctionLibraries/SessionFunctions.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index cf542c601..4692cb0be 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -37,10 +37,10 @@ function newSessionFunctions () { 'Close Stage->Close Execution->' + 'Announcement->Formula->' + 'Execution Algorithm->Market Buy Order->Market Sell Order->Limit Buy Order->Limit Sell Order->' + - 'Market Order->Limit Order->' 'Position Size->Position Rate->Formula->' + 'Create Order Event->Move Order Event->Cancel Order Event->' + - 'Situation->Condition->Javascript Code->' + 'Situation->Condition->Javascript Code->' + + 'Market Order->Limit Order->' let tradingSystem = functionLibraryProtocolNode.getProtocolNode(node.tradingSystemReference.payload.referenceParent, false, true, true, false, false, lightingPath) @@ -58,15 +58,20 @@ function newSessionFunctions () { 'Distance To Event->' + 'Trigger On->Trigger Off->Take Position->Close Position->Next Phase->Move To Phase->' + 'Strategy->' + - 'Begin->End->Strategy Name->Index->Stage Type->Status->Begin Rate->End Rate->Situation Name->' + + 'Identifier->Begin->End->Strategy Name->Index->Stage Type->Status->Begin Rate->End Rate->Situation Name->' + 'Strategy Counters->Periods->' + 'Position->' + - 'Begin->End->Rate->Size->Exit Type->Status->Begin Rate->End Rate->Situation Name->' + + 'Identifier->Begin->End->Rate->Size->Exit Type->Status->Begin Rate->End Rate->Situation Name->' + 'Stop Loss->Stop Loss Stage->Stop Loss Phase->' + 'Take Profit->Take Profit Stage->Take Profit Phase->' + 'Position Counters->Periods->' + 'Position Statistics->Profit Loss->Days->ROI->Hit Fail->User Defined Statistic->' + - 'Formula' + 'Formula->' + + 'Exchange Orders->Market Buy Orders->Market Sell Orders->Limit Buy Orders->Limit Sell Orders->' + + 'Market Order->Limit Order->' + + 'Identifier->Begin->End->Rate->Size->Exit Type->Status->Algorithm Name->' + + 'Order Counters->Periods->' + + 'Order Statistics->Percentage Filled->Actual Rate->Fees Paid->Days->User Defined Statistic->' let tradingEngine = functionLibraryProtocolNode.getProtocolNode(node.tradingEngineReference.payload.referenceParent, false, true, true, false, false, lightingPath) From a3ab16a7ce0cac7916ccd21282f715efb0da8114 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jul 2020 09:25:50 +0200 Subject: [PATCH 34/48] Update PlotterPanel.js --- Panels/PlotterPanel.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Panels/PlotterPanel.js b/Panels/PlotterPanel.js index 3e03dbd86..2db96284a 100644 --- a/Panels/PlotterPanel.js +++ b/Panels/PlotterPanel.js @@ -112,16 +112,14 @@ function newPlotterPanel () { } } - printLabel('Indicator Properties', X_AXIS, UI_PANEL.HEIGHT.NORMAL * 17 / 100, '1.00', 14, undefined, true, thisObject.container, thisObject.fitFunction) - /* Second we go through the panel data. */ if (panelNode.panelData === undefined) { return } for (let i = 0; i < panelNode.panelData.length; i++) { let panelData = panelNode.panelData[i] let labelText = panelData.name - let labelPosition = i * 10 + 25 - let valuePosition = i * 10 + 30 + let labelPosition = i * 10 + 12 + let valuePosition = i * 10 + 17 let value = 'No value defined.' if (valuePosition > 100) { From 6b1ad03604a4f0d40b9013dd05dbe6f816e80dbe Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jul 2020 10:02:08 +0200 Subject: [PATCH 35/48] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 4692cb0be..9bb544e9e 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -69,7 +69,7 @@ function newSessionFunctions () { 'Formula->' + 'Exchange Orders->Market Buy Orders->Market Sell Orders->Limit Buy Orders->Limit Sell Orders->' + 'Market Order->Limit Order->' + - 'Identifier->Begin->End->Rate->Size->Exit Type->Status->Algorithm Name->' + + 'Identifier->Begin->End->Rate->Size->Exit Type->Status->Order Name->Algorithm Name->Situation Name->' + 'Order Counters->Periods->' + 'Order Statistics->Percentage Filled->Actual Rate->Fees Paid->Days->User Defined Statistic->' From ccdef26fa057d651f82ae17ef5f9b6c284655791 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jul 2020 15:18:29 +0200 Subject: [PATCH 36/48] New Nodes --- .../Workspace/FunctionLibraries/SessionFunctions.js | 3 ++- FloatingSpace/UiObjectConstructor.js | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 9bb544e9e..73bbf1b44 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -40,7 +40,8 @@ function newSessionFunctions () { 'Position Size->Position Rate->Formula->' + 'Create Order Event->Move Order Event->Cancel Order Event->' + 'Situation->Condition->Javascript Code->' + - 'Market Order->Limit Order->' + 'Market Order->Limit Order->' + + 'Simulated Exchange Events->Simulated Partial Fill->Simulated Actual Rate->Simulated Fees Paid->Formula->' let tradingSystem = functionLibraryProtocolNode.getProtocolNode(node.tradingSystemReference.payload.referenceParent, false, true, true, false, false, lightingPath) diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index b2445657a..1c17ca23c 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -74,7 +74,7 @@ function newUiObjectConstructor () { */ if (userAddingNew === true) { - let definition = getNodeDefinition (payload.parentNode) + let definition = getNodeDefinition(payload.parentNode) if (definition.properties !== undefined) { for (let i = 0; i < definition.properties.length; i++) { let property = definition.properties[i] @@ -406,7 +406,7 @@ function newUiObjectConstructor () { function getMenuItemsInitialValues (uiObject, floatingObject, payload) { let menuItemsInitialValues = [] - let nodeDefinition = getNodeDefinition (payload.node) + let nodeDefinition = getNodeDefinition(payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.editors !== undefined) { if (nodeDefinition.editors.config === true) { @@ -450,7 +450,12 @@ function newUiObjectConstructor () { /* We need to reference the real function based on its name */ if (menutItemDefinition.actionFunction !== undefined) { - newMenuItem.actionFunction = eval(menutItemDefinition.actionFunction) + try { + newMenuItem.actionFunction = eval(menutItemDefinition.actionFunction) + } catch (err) { + console.log('Error at Menu Item Action Function: ' + menutItemDefinition.actionFunction + ' ' + err.stack) + continue + } } /* Adding default values */ @@ -495,7 +500,7 @@ function newUiObjectConstructor () { } default: { - let nodeDefinition = getNodeDefinition (payload.node) + let nodeDefinition = getNodeDefinition(payload.node) if (nodeDefinition !== undefined) { switch (nodeDefinition.level) { case 0: { From 1bb17586c9a5c22891ff4ecb542ecdeabef7e4a0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jul 2020 10:22:39 +0200 Subject: [PATCH 37/48] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 73bbf1b44..6b695c26c 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -62,7 +62,7 @@ function newSessionFunctions () { 'Identifier->Begin->End->Strategy Name->Index->Stage Type->Status->Begin Rate->End Rate->Situation Name->' + 'Strategy Counters->Periods->' + 'Position->' + - 'Identifier->Begin->End->Rate->Size->Exit Type->Status->Begin Rate->End Rate->Situation Name->' + + 'Identifier->Begin->End->Rate->Size->Orders Size->Filled Size->Exit Type->Status->Begin Rate->End Rate->Situation Name->' + 'Stop Loss->Stop Loss Stage->Stop Loss Phase->' + 'Take Profit->Take Profit Stage->Take Profit Phase->' + 'Position Counters->Periods->' + From ae0f1c6f7fdaa7adbd62b8cf43b0ae601c599433 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jul 2020 12:21:51 +0200 Subject: [PATCH 38/48] Update UiObject.js --- FloatingSpace/UiObject.js | 1 + 1 file changed, 1 insertion(+) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 2e5bf0b2c..5ef146676 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -646,6 +646,7 @@ function newUiObject () { if (isDragging !== true) { return } if (thisObject.payload.floatingObject.isFrozen === true) { return } if (rightDragging === false) { return } + if (thisObject.payload === undefined) { return } if (thisObject.payload.referenceParent === undefined) { return } let distanceToReferenceParent = Math.sqrt(Math.pow(thisObject.payload.position.x - thisObject.payload.referenceParent.payload.position.x, 2) + Math.pow(thisObject.payload.position.y - thisObject.payload.referenceParent.payload.position.y, 2)) From 6a193e2aa081be92c78f59ac1df94d5ddca06ce5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jul 2020 16:43:08 +0200 Subject: [PATCH 39/48] stage status --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 4 ++-- FloatingSpace/UiObject.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 6b695c26c..838f8d2e2 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -59,10 +59,10 @@ function newSessionFunctions () { 'Distance To Event->' + 'Trigger On->Trigger Off->Take Position->Close Position->Next Phase->Move To Phase->' + 'Strategy->' + - 'Identifier->Begin->End->Strategy Name->Index->Stage Type->Status->Begin Rate->End Rate->Situation Name->' + + 'Identifier->Begin->End->Strategy Name->Index->Trigger Stage Status->Open Stage Status->Manage Stage Status->Close Stage Status->Status->Begin Rate->End Rate->Situation Name->' + 'Strategy Counters->Periods->' + 'Position->' + - 'Identifier->Begin->End->Rate->Size->Orders Size->Filled Size->Exit Type->Status->Begin Rate->End Rate->Situation Name->' + + 'Identifier->Begin->End->Rate->Size->Open Stage Orders Size->Open Stage Filled Size->Close Stage Orders Size->Close Stage Filled Size->Exit Type->Status->Begin Rate->End Rate->Situation Name->' + 'Stop Loss->Stop Loss Stage->Stop Loss Phase->' + 'Take Profit->Take Profit Stage->Take Profit Phase->' + 'Position Counters->Periods->' + diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 5ef146676..62fdbbdec 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -1406,6 +1406,7 @@ function newUiObject () { } function drawValue () { + if (currentValue === null) { return } if (hasValue === false) { return } if (canvas.floatingSpace.inMapMode === true) { return } if (thisObject.payload === undefined) { return } @@ -1435,7 +1436,7 @@ function newUiObject () { const MAX_LABEL_LENGTH = 65 label = currentValue - if (!isNaN(label)) { + if (!isNaN(currentValue)) { if (currentValue.toFixed !== undefined) { label = dynamicDecimals(currentValue) } From e27f89dab3a44b6f1efccc124d44ab97d9e9571f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jul 2020 14:45:52 +0200 Subject: [PATCH 40/48] Update SessionFunctions.js --- .../Workspace/FunctionLibraries/SessionFunctions.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 838f8d2e2..0536167ad 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -37,8 +37,8 @@ function newSessionFunctions () { 'Close Stage->Close Execution->' + 'Announcement->Formula->' + 'Execution Algorithm->Market Buy Order->Market Sell Order->Limit Buy Order->Limit Sell Order->' + - 'Position Size->Position Rate->Formula->' + 'Create Order Event->Move Order Event->Cancel Order Event->' + + 'Position Size->Position Rate->Formula->' + 'Situation->Condition->Javascript Code->' + 'Market Order->Limit Order->' + 'Simulated Exchange Events->Simulated Partial Fill->Simulated Actual Rate->Simulated Fees Paid->Formula->' @@ -50,19 +50,19 @@ function newSessionFunctions () { 'Dynamic Indicators->Indicator Function->Formula->' + 'Episode->Current->Last->Previous->' + 'Episode Counters->Episode Statistics->' + - 'Periods->Positions->Hits->Fails->' + + 'Periods->Strategies->Positions->Orders->Hits->Fails->' + 'Profit Loss->Hit Ratio->Days->ROI->Anualized Rate Of Return->User Defined Statistic->' + 'Formula->' + 'Candle->' + 'Begin->End->Open->Close->Min->Max->Index->' + 'Balance->Base Asset->Quoted Asset->' + 'Distance To Event->' + - 'Trigger On->Trigger Off->Take Position->Close Position->Next Phase->Move To Phase->' + + 'Trigger On->Trigger Off->Take Position->Close Position->Next Phase->Move To Phase->Create Order->Move Order->Cancel Order->Close Order->' + 'Strategy->' + - 'Identifier->Begin->End->Strategy Name->Index->Trigger Stage Status->Open Stage Status->Manage Stage Status->Close Stage Status->Status->Begin Rate->End Rate->Situation Name->' + + 'Serial Number->Identifier->Begin->End->Strategy Name->Index->Trigger Stage Status->Open Stage Status->Manage Stage Status->Close Stage Status->Status->Begin Rate->End Rate->Situation Name->' + 'Strategy Counters->Periods->' + 'Position->' + - 'Identifier->Begin->End->Rate->Size->Open Stage Orders Size->Open Stage Filled Size->Close Stage Orders Size->Close Stage Filled Size->Exit Type->Status->Begin Rate->End Rate->Situation Name->' + + 'Serial Number->Identifier->Begin->End->Rate->Size->Open Stage Orders Size->Open Stage Filled Size->Close Stage Orders Size->Close Stage Filled Size->Exit Type->Status->Begin Rate->End Rate->Situation Name->' + 'Stop Loss->Stop Loss Stage->Stop Loss Phase->' + 'Take Profit->Take Profit Stage->Take Profit Phase->' + 'Position Counters->Periods->' + @@ -70,7 +70,7 @@ function newSessionFunctions () { 'Formula->' + 'Exchange Orders->Market Buy Orders->Market Sell Orders->Limit Buy Orders->Limit Sell Orders->' + 'Market Order->Limit Order->' + - 'Identifier->Begin->End->Rate->Size->Exit Type->Status->Order Name->Algorithm Name->Situation Name->' + + 'Serial Number->Identifier->Begin->End->Rate->Size->Exit Type->Status->Order Name->Algorithm Name->Situation Name->' + 'Order Counters->Periods->' + 'Order Statistics->Percentage Filled->Actual Rate->Fees Paid->Days->User Defined Statistic->' From 8f595b58d6333b8516c48e2eb4da8959146810e1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jul 2020 16:32:08 +0200 Subject: [PATCH 41/48] Update Plotter.js --- Plotting/Plotter.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Plotting/Plotter.js b/Plotting/Plotter.js index bdb2d3d05..bb0aaf7ee 100644 --- a/Plotting/Plotter.js +++ b/Plotting/Plotter.js @@ -42,6 +42,8 @@ function newPlotter () { let records = [] // We will have the information to be plotted here. let userPositionDate + let minUserPositionRate + let maxUserPositionRate let onMouseOverEventSuscriptionId let zoomChangedEventSubscriptionId @@ -148,6 +150,18 @@ function newPlotter () { function onMouseOver (event) { let userPosition = getDateFromPointAtBrowserCanvas(event, thisObject.container, coordinateSystem) userPositionDate = userPosition.valueOf() + + let minPositionPoint = { + x: event.x, + y: event.y + 2 + } + minUserPositionRate = getRateFromPointAtBrowserCanvas(minPositionPoint, thisObject.container, coordinateSystem) + + let maxPositionPoint = { + x: event.x, + y: event.y - 2 + } + maxUserPositionRate = getRateFromPointAtBrowserCanvas(maxPositionPoint, thisObject.container, coordinateSystem) } function onMarketFilesUpdated () { @@ -536,8 +550,17 @@ function newPlotter () { let atMousePosition = false if (userPositionDate >= record.begin && userPositionDate <= record.end) { - atMousePosition = true - thisObject.container.eventHandler.raiseEvent('Current Record Changed', record) + if (record.rate === undefined) { + /* Current Record depends only on begin and end. */ + atMousePosition = true + thisObject.container.eventHandler.raiseEvent('Current Record Changed', record) + } else { + /* Current Record depends also on rate */ + if (record.rate >= minUserPositionRate && record.rate <= maxUserPositionRate) { + atMousePosition = true + thisObject.container.eventHandler.raiseEvent('Current Record Changed', record) + } + } } /* If there is code we execute it now. */ From 1409da0f92b7203351ebe86d7946abd2480950d0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 20 Jul 2020 11:39:58 +0200 Subject: [PATCH 42/48] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 0536167ad..ca03fdd58 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -70,7 +70,7 @@ function newSessionFunctions () { 'Formula->' + 'Exchange Orders->Market Buy Orders->Market Sell Orders->Limit Buy Orders->Limit Sell Orders->' + 'Market Order->Limit Order->' + - 'Serial Number->Identifier->Begin->End->Rate->Size->Exit Type->Status->Order Name->Algorithm Name->Situation Name->' + + 'Serial Number->Identifier->Exchange Id->Begin->End->Rate->Size->Exit Type->Status->Order Name->Algorithm Name->Situation Name->' + 'Order Counters->Periods->' + 'Order Statistics->Percentage Filled->Actual Rate->Fees Paid->Days->User Defined Statistic->' From c4d0fdd735d535fc666d675036d50cfe64d0e6d9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 20 Jul 2020 16:18:23 +0200 Subject: [PATCH 43/48] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index ca03fdd58..5de3ca996 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -37,7 +37,7 @@ function newSessionFunctions () { 'Close Stage->Close Execution->' + 'Announcement->Formula->' + 'Execution Algorithm->Market Buy Order->Market Sell Order->Limit Buy Order->Limit Sell Order->' + - 'Create Order Event->Move Order Event->Cancel Order Event->' + + 'Create Order Event->Cancel Order Event->' + 'Position Size->Position Rate->Formula->' + 'Situation->Condition->Javascript Code->' + 'Market Order->Limit Order->' + @@ -57,7 +57,7 @@ function newSessionFunctions () { 'Begin->End->Open->Close->Min->Max->Index->' + 'Balance->Base Asset->Quoted Asset->' + 'Distance To Event->' + - 'Trigger On->Trigger Off->Take Position->Close Position->Next Phase->Move To Phase->Create Order->Move Order->Cancel Order->Close Order->' + + 'Trigger On->Trigger Off->Take Position->Close Position->Next Phase->Move To Phase->Create Order->Cancel Order->Close Order->' + 'Strategy->' + 'Serial Number->Identifier->Begin->End->Strategy Name->Index->Trigger Stage Status->Open Stage Status->Manage Stage Status->Close Stage Status->Status->Begin Rate->End Rate->Situation Name->' + 'Strategy Counters->Periods->' + From 397a16ea690f6c2dce1b22e100abd88037a3f8fd Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 Jul 2020 11:12:52 +0200 Subject: [PATCH 44/48] Key Reference --- DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js | 2 +- EventsServerClient.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js index e364f9303..bad8f5bc1 100644 --- a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -32,7 +32,7 @@ function newTaskFunctions () { 'Trading Bot Instance->' + 'Sensor Process Instance->Indicator Process Instance->Trading Process Instance->' + 'Market Reference->' + - 'Key Instance->Exchange Account Key->' + + 'Key Reference->Exchange Account Key->' + 'Market->Exchange Markets->Crypto Exchange->' + 'Market Base Asset->Market Quoted Asset->Asset->' + 'Backtesting Session->Live Trading Session->Paper Trading Session->Fordward Testing Session->' + diff --git a/EventsServerClient.js b/EventsServerClient.js index b56712a6c..4760a3c51 100644 --- a/EventsServerClient.js +++ b/EventsServerClient.js @@ -156,7 +156,7 @@ function newEventsServerClient (host, port, hostName) { } if (thisObject.isConnected() !== true) { - canvas.cockpitSpace.setStatus('Connecting to ' + hostName + ' Network Node. Please wait until the connection is established.', 100, canvas.cockpitSpace.statusTypes.WARNING) + canvas.cockpitSpace.setStatus('Connecting to Superalgos Backend at ' + hostName + ' Network Node. Please wait until the connection is established.', 100, canvas.cockpitSpace.statusTypes.WARNING) } else { retryCommandsPhysics() } From 2c72130261608ecdca3f60514cb1e331d8311440 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 22 Jul 2020 10:22:52 +0200 Subject: [PATCH 45/48] new field --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 +- Plotting/Plotter.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 5de3ca996..e552a7c53 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -72,7 +72,7 @@ function newSessionFunctions () { 'Market Order->Limit Order->' + 'Serial Number->Identifier->Exchange Id->Begin->End->Rate->Size->Exit Type->Status->Order Name->Algorithm Name->Situation Name->' + 'Order Counters->Periods->' + - 'Order Statistics->Percentage Filled->Actual Rate->Fees Paid->Days->User Defined Statistic->' + 'Order Statistics->Size Filled->Percentage Filled->Amount Received->Actual Rate->Fees Paid->Days->User Defined Statistic->' let tradingEngine = functionLibraryProtocolNode.getProtocolNode(node.tradingEngineReference.payload.referenceParent, false, true, true, false, false, lightingPath) diff --git a/Plotting/Plotter.js b/Plotting/Plotter.js index bb0aaf7ee..844ace277 100644 --- a/Plotting/Plotter.js +++ b/Plotting/Plotter.js @@ -305,6 +305,7 @@ function newPlotter () { jsonifiedArray.push(record) previous = record + if (record.begin === undefined || record.end === undefined) { console.log('Could not find the property begin or end which are needed for the plotter to work.') } if (datetime.valueOf() >= record.begin && datetime.valueOf() <= record.end) { thisObject.currentRecord = record thisObject.container.eventHandler.raiseEvent('Current Record Changed', thisObject.currentRecord) From 080215f489eabc76c09d24ac9100975bedbf5b2c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 23 Jul 2020 12:13:54 +0200 Subject: [PATCH 46/48] working with index --- Plotting/Plotter.js | 10 ++++----- Plotting/RecordValues.js | 48 +++++++++++++++++++++++++++++++--------- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/Plotting/Plotter.js b/Plotting/Plotter.js index 844ace277..85f3e6873 100644 --- a/Plotting/Plotter.js +++ b/Plotting/Plotter.js @@ -551,16 +551,16 @@ function newPlotter () { let atMousePosition = false if (userPositionDate >= record.begin && userPositionDate <= record.end) { - if (record.rate === undefined) { - /* Current Record depends only on begin and end. */ - atMousePosition = true - thisObject.container.eventHandler.raiseEvent('Current Record Changed', record) - } else { + if (record.rate !== undefined && productDefinition.referenceParent.config.useRateAtMousePosition === true) { /* Current Record depends also on rate */ if (record.rate >= minUserPositionRate && record.rate <= maxUserPositionRate) { atMousePosition = true thisObject.container.eventHandler.raiseEvent('Current Record Changed', record) } + } else { + /* Current Record depends only on begin and end. */ + atMousePosition = true + thisObject.container.eventHandler.raiseEvent('Current Record Changed', record) } } diff --git a/Plotting/RecordValues.js b/Plotting/RecordValues.js index 2e66ad2da..8f84ba629 100644 --- a/Plotting/RecordValues.js +++ b/Plotting/RecordValues.js @@ -12,7 +12,6 @@ function newRecordValues () { let tradingSystem let tradingEngine let productDefinition - let productTargetNode let propertyTargetNodeMap = new Map() return thisObject @@ -20,7 +19,6 @@ function newRecordValues () { tradingSystem = undefined tradingEngine = undefined productDefinition = undefined - productTargetNode = undefined propertyTargetNodeMap = undefined } @@ -28,15 +26,45 @@ function newRecordValues () { tradingSystem = canvas.designSpace.workspace.getHierarchyHeadsById(pTradingSystem.id) tradingEngine = canvas.designSpace.workspace.getHierarchyHeadsById(pTradingEngine.id) productDefinition = pProductDefinition - productTargetNode = eval(productDefinition.config.nodePath) - for (let i = 0; i < productDefinition.record.properties.length; i++) { - let property = productDefinition.record.properties[i] - if (property.config.nodePath !== undefined) { - let propertyRoot = eval(property.config.nodePath) - propertyTargetNodeMap.set(property.id, propertyRoot) - } else { - propertyTargetNodeMap.set(property.id, productTargetNode) + /* + The product root can be a node or a node property of type array. + */ + let productRoot = eval(productDefinition.config.nodePath) + + if (productDefinition.config.nodePathType === 'array') { + /* + This means that the configured nodePath is not pointing to a node, but to a node property that is an array. + For that reason we will assume that each element of the array is a record to be outputed + */ + for (let index = 0; index < productRoot.length; index++) { + /* + The Product Root Node is the root of the node hiriarchy from where we are going to extract the record values. + */ + let productRootNode = productRoot[index] + scanProperties(productRootNode, index) + } + } else { + /* + This means that the configured nodePath points to a single node, which is the one whose children constitutes + the record to be saved at the output file. + */ + /* + The Product Root Node is the root of the node hiriarchy from where we are going to extract the record values. + */ + let productRootNode = productRoot + scanProperties(productRootNode) + } + + function scanProperties (productRootNode, index) { + for (let i = 0; i < productDefinition.record.properties.length; i++) { + let property = productDefinition.record.properties[i] + if (property.config.nodePath !== undefined) { + let propertyRoot = eval(property.config.nodePath) + propertyTargetNodeMap.set(property.id, propertyRoot) + } else { + propertyTargetNodeMap.set(property.id, productRootNode) + } } } } From 9a863c3ee4db2862aaf27b5870ba020d0954e8d1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 24 Jul 2020 13:04:56 +0200 Subject: [PATCH 47/48] Update TaskFunctions.js --- DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js index bad8f5bc1..832e7bcd8 100644 --- a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -28,7 +28,7 @@ function newTaskFunctions () { let taskLightingPath = '->Task->' + 'Sensor Bot Instance->' + - 'Indicator Bot Instance->' + + 'Indicator Bot Instance->Time Frames Filter->' + 'Trading Bot Instance->' + 'Sensor Process Instance->Indicator Process Instance->Trading Process Instance->' + 'Market Reference->' + From 68a8bc224c155be4a163aef899182285408a76c6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 25 Jul 2020 09:16:06 +0200 Subject: [PATCH 48/48] Internet Independent --- Animation.js | 131 +++++++++++++++++-------------------- Canvas.js | 15 ++--- CockpitSpace/FullScreen.js | 2 +- Globals.js | 3 +- 4 files changed, 69 insertions(+), 82 deletions(-) diff --git a/Animation.js b/Animation.js index cab8a470c..b43fcf413 100644 --- a/Animation.js +++ b/Animation.js @@ -59,89 +59,80 @@ function newAnimation () { function animationLoop () { try { - if (window.canvasApp.visible === true) { - /* We set the canvas to its normal width and height */ - // browserCanvas.width = window.innerWidth - // browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN + /* First thing is to clear the actual canvas */ + clearBrowserCanvas() - /* First thing is to clear the actual canvas */ - clearBrowserCanvas() - - /* We loop through the callback functions collections and execute them all. */ - let performanceMap = new Map() - let totalTimeConsumed = 0 - let totalElements = 0 - let chanceToExecute - let randomNumber - let mustExecute + /* We loop through the callback functions collections and execute them all. */ + let performanceMap = new Map() + let totalTimeConsumed = 0 + let totalElements = 0 + let chanceToExecute + let randomNumber + let mustExecute // console.clear() - let row = 0 - for (const [key, callBackFunction] of callBackFunctions.entries()) { - row++ - switch (key) { - case 'Floating Space Physics': - chanceToExecute = 50 - randomNumber = Math.random() * 100 * chanceToExecute - if (randomNumber > 100 - chanceToExecute) { mustExecute = true } else { mustExecute = false } - break - default: { - mustExecute = true - } - + let row = 0 + for (const [key, callBackFunction] of callBackFunctions.entries()) { + row++ + switch (key) { + case 'Floating Space Physics': + chanceToExecute = 50 + randomNumber = Math.random() * 100 * chanceToExecute + if (randomNumber > 100 - chanceToExecute) { mustExecute = true } else { mustExecute = false } + break + default: { + mustExecute = true } - let timeConsumed = 0 - if (mustExecute === true) { - let t0 = performance.now() - callBackFunction() - let t1 = performance.now() - timeConsumed = t1 - t0 - if (key === 'Charting Space Draw') { - if (Math.random() * 100 > 99) { - totalConsumption = 0 - totalCounter = 0 - } - totalConsumption = totalConsumption + timeConsumed - totalCounter = totalCounter + 1 - } - performanceMap.set(key, timeConsumed) - totalTimeConsumed = totalTimeConsumed + timeConsumed - totalElements++ - } } + let timeConsumed = 0 + if (mustExecute === true) { + let t0 = performance.now() + callBackFunction() + let t1 = performance.now() + timeConsumed = t1 - t0 + if (key === 'Charting Space Draw') { + if (Math.random() * 100 > 99) { + totalConsumption = 0 + totalCounter = 0 + } + + totalConsumption = totalConsumption + timeConsumed + totalCounter = totalCounter + 1 + } + performanceMap.set(key, timeConsumed) + totalTimeConsumed = totalTimeConsumed + timeConsumed + totalElements++ + } + } /* Frame per Seconds */ - ANIMATION_FRAME_PER_SECONDS = Math.trunc(1000 / totalTimeConsumed) + ANIMATION_FRAME_PER_SECONDS = Math.trunc(1000 / totalTimeConsumed) /* Performance Check */ - if (SHOW_ANIMATION_PERFORMACE === true) { - row = 0 - for (const [key, timeConsumed] of performanceMap.entries()) { - row++ - labelToPrint = key + ' ' + timeConsumed.toFixed(4) - printLabel(labelToPrint, 10, 100 + row * 30, 1, 20, UI_COLOR.RED) - let percentage = timeConsumed * 100 / totalTimeConsumed - labelToPrint = key + ' ' + percentage.toFixed(1) + '%' - printLabel(labelToPrint, 300, 100 + row * 30, 1, 20, UI_COLOR.RED) - } + if (SHOW_ANIMATION_PERFORMACE === true) { + row = 0 + for (const [key, timeConsumed] of performanceMap.entries()) { + row++ + labelToPrint = key + ' ' + timeConsumed.toFixed(4) + printLabel(labelToPrint, 10, 100 + row * 30, 1, 20, UI_COLOR.RED) + let percentage = timeConsumed * 100 / totalTimeConsumed + labelToPrint = key + ' ' + percentage.toFixed(1) + '%' + printLabel(labelToPrint, 300, 100 + row * 30, 1, 20, UI_COLOR.RED) + } /* Other Variables */ - row++ - printLabel(DEBUG.variable1, 300, 100 + row * 30, 1, 20, UI_COLOR.RED) - row++ - printLabel(DEBUG.variable2, 300, 100 + row * 30, 1, 20, UI_COLOR.RED) - row++ - printLabel(DEBUG.variable3, 300, 100 + row * 30, 1, 20, UI_COLOR.RED) - row++ - printLabel(DEBUG.variable4, 300, 100 + row * 30, 1, 20, UI_COLOR.RED) - row++ - printLabel('Animation Frame Per Seconds: ' + ANIMATION_FRAME_PER_SECONDS, 300, 100 + row * 30, 1, 20, UI_COLOR.TITANIUM_YELLOW) - } - } else { - browserCanvas.width = 1 - browserCanvas.height = 1 + row++ + printLabel(DEBUG.variable1, 300, 100 + row * 30, 1, 20, UI_COLOR.RED) + row++ + printLabel(DEBUG.variable2, 300, 100 + row * 30, 1, 20, UI_COLOR.RED) + row++ + printLabel(DEBUG.variable3, 300, 100 + row * 30, 1, 20, UI_COLOR.RED) + row++ + printLabel(DEBUG.variable4, 300, 100 + row * 30, 1, 20, UI_COLOR.RED) + row++ + printLabel('Animation Frame Per Seconds: ' + ANIMATION_FRAME_PER_SECONDS, 300, 100 + row * 30, 1, 20, UI_COLOR.TITANIUM_YELLOW) } /* Video Recording */ diff --git a/Canvas.js b/Canvas.js index af920101a..50f08991c 100644 --- a/Canvas.js +++ b/Canvas.js @@ -97,12 +97,11 @@ function newCanvas () { function initialize () { try { + browserResized() initializeBrowserCanvas() - addCanvasEvents() - /* Instantiate all the children spaces of Canvas object */ - + /* Instantiate all the children spaces of Canvas object */ thisObject.floatingSpace = newFloatingSpace() thisObject.floatingSpace.initialize() @@ -199,14 +198,10 @@ function newCanvas () { } function browserResized () { - try { - browserCanvas = document.getElementById('canvas') + browserCanvas = document.getElementById('canvas') - browserCanvas.width = window.innerWidth - browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] browserResized -> err = ' + err.stack) } - } + browserCanvas.width = window.innerWidth + browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN } function checkMediaRecording (event) { diff --git a/CockpitSpace/FullScreen.js b/CockpitSpace/FullScreen.js index 12951403f..9fb2717d9 100644 --- a/CockpitSpace/FullScreen.js +++ b/CockpitSpace/FullScreen.js @@ -82,7 +82,7 @@ function newFullScreen () { } else { thisObject.status = 'Off' goOutFullscreen() - CURRENT_TOP_MARGIN = window.canvasApp.topMargin + CURRENT_TOP_MARGIN = TOP_MARGIN AT_FULL_SCREEN_MODE = false } } diff --git a/Globals.js b/Globals.js index d9a737c01..f47174216 100644 --- a/Globals.js +++ b/Globals.js @@ -178,7 +178,8 @@ let INITIAL_ZOOM_LEVEL = -28.25 // This is the zoom level at the view port let INITIAL_TIME_PERIOD = ONE_DAY_IN_MILISECONDS // This value will be overwritten at the canvas.chartingSpace.viewport.initialize if the user had a prevous session with this same browser. let VERY_LARGE_NUMBER = 100000000000000 -let CURRENT_TOP_MARGIN = window.canvasApp.topMargin +const TOP_MARGIN = 0 +let CURRENT_TOP_MARGIN = TOP_MARGIN let AT_FULL_SCREEN_MODE = false let maxDate = new Date();