Compare commits

...
Author SHA1 Message Date
Luis Fernando Molina 45bfccfb18 Update AppSchema.json 2020-11-16 10:22:19 +01:00
Luis Fernando Molina 70ec4efb38 Bug hot fix 2020-11-15 20:41:12 +01:00
Luis Fernando Molina 6cb3307be3 Update README.md 2020-11-14 16:00:34 +01:00
Luis Fernando Molina 385bf38a02 Merge pull request #292 from Superalgos/develop
SP4 bug fix
2020-11-13 20:54:49 +01:00
Luis Fernando Molina 0f7b40cca7 SP4 again 2020-11-13 20:52:29 +01:00
Luis Fernando Molina b66e4c0dd6 Bug fix 2020-11-13 20:32:30 +01:00
Luis Fernando Molina 6969542ed6 Beta 7, again, with ETH Node connectivity 2020-11-13 19:13:27 +01:00
Luis Fernando Molina 04f20402fa Merge pull request #291 from 9808us/develop
Zeus Data Mine Fix
2020-11-12 20:58:07 +01:00
9808us 43070ea333 Zeus Data Mine Fix 2020-11-12 18:07:23 +01:00
Luis Fernando Molina 126dc6331b Merge pull request #290 from Superalgos/develop
Beta 6, Service Pack 4
2020-11-11 18:46:45 +01:00
Luis Fernando Molina b72ddfb20b Beta 6, SP4 2020-11-11 18:38:47 +01:00
Luis Fernando Molina 77bbcc9e99 Update DrawPrint.js 2020-11-10 19:18:25 +01:00
Luis Fernando Molina b820e165c4 Panel Improvements 2020-11-10 18:46:32 +01:00
Luis Fernando Molina 6fbc0b709c Update README.md 2020-11-10 14:07:33 +01:00
Luis Fernando Molina c8eee46ece Update README.md 2020-11-10 14:05:21 +01:00
Julian Molina 6fe81b9e17 Update README.md 2020-11-09 16:32:30 +01:00
Luis Fernando Molina 20fec1eccd Beta 6 SP4 RC 1 2020-11-09 10:01:38 +01:00
Luis Fernando Molina 66012c9d48 Update README.md 2020-11-07 17:18:13 +01:00
Luis Fernando Molina 69ad61ff8e Perf Improvement 2020-11-07 13:25:35 +01:00
Luis Fernando Molina 9627ef5941 Bug Fixes 2020-11-07 11:25:09 +01:00
Luis Fernando Molina ce1d474bfa Mines Updated 2020-11-06 16:48:56 +01:00
Luis Fernando Molina 75b9b38259 Plugins Upgraded to Beta 7 2020-11-06 14:35:58 +01:00
Luis Fernando Molina 1532baea55 Update README.md 2020-11-06 09:50:29 +01:00
Luis Fernando Molina 59b4ad9671 Update README.md 2020-11-06 09:44:11 +01:00
Luis Fernando Molina f98f4ae3d4 Update README.md 2020-11-06 09:36:32 +01:00
Luis Fernando Molina a85b945cf3 Update README.md 2020-11-06 09:35:16 +01:00
Luis Fernando Molina 52f385d64e Texts splitted 2020-11-05 20:12:19 +01:00
Luis Fernando Molina 3b33406a55 Update README.md 2020-11-05 19:35:05 +01:00
Luis Fernando Molina 5de7cdc4e8 Update README.md 2020-11-05 19:32:31 +01:00
Luis Fernando Molina 96572e6e09 Update README.md 2020-11-05 16:25:51 +01:00
Luis Fernando Molina 591e863994 Update README.md 2020-11-05 16:23:37 +01:00
Luis Fernando Molina 7dd461ca8d Parameters and Bug Fix 2020-11-05 15:57:29 +01:00
Luis Fernando Molina 5a82a3bd35 Update Plotter.js 2020-11-05 13:08:22 +01:00
Luis Fernando Molina 1abb1e4b00 Update Masters.json 2020-11-05 13:01:54 +01:00
Luis Fernando Molina 0192863203 Merge pull request #289 from 9808us/develop
Zeus update
2020-11-05 12:49:11 +01:00
9808us ded65cc12c Zeus update 2020-11-05 12:46:40 +01:00
Luis Fernando Molina b3da2cf6bc Update AppSchema.json 2020-11-05 12:41:59 +01:00
Luis Fernando Molina eb427eb146 Superalgos Beta 7, first commit. 2020-11-05 10:38:10 +01:00
Luis Fernando Molina c877072b7c Refactoring and Bug Fixes 2020-10-31 21:08:57 +01:00
Luis Fernando Molina c94f7fc747 Fix Workspaces 2020-10-29 17:21:18 +01:00
Luis Fernando Molina 221cd70d53 Candle Analisys 2020-10-29 12:05:08 +01:00
Luis Fernando Molina 1262b339c6 Latest fixes 2020-10-28 11:28:34 +01:00
Luis Fernando Molina 850018265e Bug at mouse position 2020-10-27 20:10:39 +01:00
Luis Fernando Molina 8022578c46 More Warnings 2020-10-27 17:59:04 +01:00
Luis Fernando Molina d3e097e316 Fixes 2020-10-27 17:20:20 +01:00
Luis Fernando Molina 5c18a1a976 Timeline Charts Order Inverted 2020-10-27 11:16:57 +01:00
Luis Fernando Molina 9c29d4f45d Update OrdersSimulations.js 2020-10-27 09:44:41 +01:00
Luis Fernando Molina 5cda19de6a Fix 2020-10-27 09:18:25 +01:00
Luis Fernando Molina 8deaea9330 Create Ethereum-Integration-Demo.json 2020-10-27 08:14:29 +01:00
Luis Fernando Molina 589c8ddee5 Update OrdersSimulations.js 2020-10-26 17:53:49 +01:00
Luis Fernando Molina 5012cf35e8 Decimals 2020-10-26 17:41:59 +01:00
Luis Fernando Molina ae0ec9499b Fixes 2020-10-26 16:03:54 +01:00
Luis Fernando Molina 3d7919fd54 Scale Fixed 2020-10-26 15:48:10 +01:00
Luis Fernando Molina b3ab20ef74 Decimals 2020-10-26 15:19:25 +01:00
Luis Fernando Molina 209eb6d2cb Warnings 2020-10-26 13:22:36 +01:00
Luis Fernando Molina 6a0bc7b6c2 Warnings Improved 2020-10-26 12:40:49 +01:00
Luis Fernando Molina 31dd974a6d Update UiObject.js 2020-10-26 11:18:51 +01:00
Luis Fernando Molina 87a65cc7ea Warnings Improved 2020-10-26 10:06:53 +01:00
Luis Fernando Molina 12bb518cc9 More fixes 2020-10-25 18:53:20 +01:00
Luis Fernando Molina f5af6f3bdf Balance not below zero validation 2020-10-25 17:29:55 +01:00
Luis Fernando Molina 903933220c Merge pull request #285 from 9808us/develop
Develop
2020-10-25 15:42:12 +01:00
Luis Fernando Molina d3da5c220b Complete Review of Trading Orders 2020-10-25 13:09:10 +01:00
9808us bec81ef962 Fixed names Upper/Lower case 2020-10-25 09:50:04 +01:00
9808us 7fa5a332ae Fix properties names 2020-10-25 08:33:36 +01:00
Luis Fernando Molina 7cacff86d0 Actual Size, Size to be Filled and Fees To be Paid 2020-10-23 19:41:57 +02:00
9808us 11996d801e Removed useless indicator 2020-10-23 17:40:23 +02:00
9808us d8e5fb3e28 Add files via upload 2020-10-23 17:37:09 +02:00
Luis Fernando Molina 3a500976a2 Latest fixes 2020-10-23 10:36:26 +02:00
Luis Fernando Molina 6bf36f3aee Merge branch 'master' into develop 2020-10-22 14:57:22 +02:00
Luis Fernando Molina 4848c577d9 Initial and Final Values 2020-10-22 14:56:59 +02:00
Luis Fernando Molina c3bdd64f2e Update README.md 2020-10-22 14:56:35 +02:00
Luis Fernando Molina e0f683aec3 STOP TP fixes 2020-10-22 13:09:31 +02:00
Luis Fernando Molina b7811b2914 Fixes 2020-10-21 19:52:54 +02:00
Luis Fernando Molina 715ba11867 Placeholders 2020-10-21 19:07:41 +02:00
Luis Fernando Molina 6bcce5b25f Missing Files 2020-10-21 19:00:09 +02:00
Luis Fernando Molina f68ebb63ca Fix 2020-10-21 18:47:02 +02:00
Luis Fernando Molina 85b1d86493 Multi Project 2020-10-21 18:31:43 +02:00
Luis Fernando Molina 3519e0ea43 Update README.md 2020-10-17 13:06:34 +02:00
Luis Fernando Molina f19c82cf5b Update README.md 2020-10-17 13:05:49 +02:00
Luis Fernando Molina ef1c869476 Update README.md 2020-10-15 11:00:29 +02:00
Luis Fernando Molina 3f71e7fcb6 Delete Untitled-10.js 2020-10-14 15:32:07 +02:00
Luis Fernando Molina 88e81a0461 Update README.md 2020-10-14 14:44:15 +02:00
Luis Fernando Molina 3c72a210f5 Update README.md 2020-10-14 14:36:13 +02:00
Luis Fernando Molina 0881f43643 Update README.md 2020-10-14 14:35:49 +02:00
Luis Fernando Molina b716b47972 Update README.md 2020-10-14 14:28:55 +02:00
Luis Fernando Molina 92b4a1abee Update README.md 2020-10-14 14:25:01 +02:00
Luis Fernando Molina f11a8128a3 Update README.md 2020-10-14 14:24:24 +02:00
Luis Fernando Molina a28c2ef6be Update README.md 2020-10-14 14:23:38 +02:00
Luis Fernando Molina 68fea0183a Update README.md 2020-10-14 14:22:41 +02:00
Luis Fernando Molina fea45905eb Update README.md 2020-10-14 14:20:42 +02:00
Luis Fernando Molina 803adbc900 Update README.md 2020-10-14 13:14:37 +02:00
Luis Fernando Molina 0e0d5c9068 Update README.md 2020-10-14 11:59:17 +02:00
Luis Fernando Molina b11ed02836 Update README.md 2020-10-14 11:53:06 +02:00
Luis Fernando Molina f64581d38f Merge pull request #282 from Superalgos/develop
Beta 6 SP3
2020-10-14 11:45:18 +02:00
Luis Fernando Molina 1ba794084b Lastest Review 2020-10-14 11:38:58 +02:00
Luis Fernando Molina f97a36f4cd Update TutorialSpace.js 2020-10-13 21:07:39 +02:00
Luis Fernando Molina df81951e51 Update TutorialSpace.js 2020-10-13 21:04:04 +02:00
Luis Fernando Molina eef64df5a4 Update TutorialSpace.js 2020-10-13 20:59:08 +02:00
Luis Fernando Molina 8fe6babb47 fix 2020-10-13 19:54:11 +02:00
Luis Fernando Molina 36b241a8a7 Latest Icons 2020-10-13 19:13:55 +02:00
Luis Fernando Molina 17cb2fa87b Update superalgos-platform.jpg 2020-10-13 16:17:17 +02:00
Luis Fernando Molina 9a056d51de Merge pull request #281 from Superalgos/develop
hot fix
2020-10-13 11:57:39 +02:00
Luis Fernando Molina 5d705c6fd7 Bug Fix 2020-10-13 11:55:23 +02:00
Luis Fernando Molina 3d8d8b5b49 Merge branch 'master' into develop 2020-10-13 10:30:53 +02:00
Luis Fernando Molina 5767faab65 Update AppSchema.json 2020-10-13 10:30:37 +02:00
Luis Fernando Molina 199a81fd75 Update AppSchema.json 2020-10-13 10:27:33 +02:00
Luis Fernando Molina c2b8e3c50b Fix 2020-10-13 10:01:42 +02:00
Luis Fernando Molina ef49ad7db1 Update README.md 2020-10-13 09:48:21 +02:00
700 changed files with 31129 additions and 7378 deletions

No files matched your search

+2 -13
View File
@@ -10,18 +10,9 @@ TASK_SERVER_PATH=./TaskServer
# TASK SERVER VARIABLES:
INTER_PROCESS_FILES_PATH=./Inter-Process-Files
STORAGE_PATH=./Data-Storage
PLOTTERS_PATH=./Legacy-Code
DATA_MINES_PATH=./Plugins/Data-Mines
TRADING_MINES_PATH=./Plugins/Trading-Mines
TRADING_SYSTEMS_PATH=./Plugins/Trading-Systems
SUPER_SCRIPTS_PATH=./Plugins/Super-Scripts
TRADING_ENGINES_PATH=./Plugins/Trading-Engines
TUTORIALS_PATH=./Plugins/Tutorials
WORKSPACES_PATH=./Plugins/Workspaces
WRITE_LOGS_TO_FILES=true
BOTS_PATH=./Legacy-Code
LOG_PATH=./Log-Files
@@ -34,13 +25,11 @@ CONSOLE_LOG=false
CONSOLE_ERROR_LOG=true
LOG_FILE_CONTENT=false
PROJECTS_PATH=./Integrations/Projects
PATH_TO_CANVAS_APP=./CanvasApp
PATH_TO_FILES_COMPONENT=./Files-Component/src
PATH_TO_WEB_SERVER=./BackendServers/
APP_SCHEMA_PATH=./
DOC_SCHEMA_PATH=./
CONCEPT_SCHEMA_PATH=./
DEFAULT_WORKSPACE_PATH=./Plugins/Workspaces
DEFAULT_WORKSPACE_PATH=./Integrations/Projects/Superalgos/Plugins/Workspaces
MY_WORKSPACES_PATH=./My-Workspaces
PATH_TO_FONTS=./BackendServers/WebServer/Fonts
+21 -28
View File
@@ -2511,8 +2511,7 @@
"childType": "Indicator Function",
"autoAdd": true
}
],
"icon": "bitcoin"
]
},
{
"type": "Indicator Function",
@@ -12467,8 +12466,7 @@
"childType": "Space Settings",
"autoAdd": true
}
],
"icon": "bitcoin"
]
},
{
"type": "Space Style",
@@ -12501,8 +12499,7 @@
"iconPathOff": "delete"
}
],
"addLeftIcons": true,
"icon": "bitcoin"
"addLeftIcons": true
},
{
"type": "Space Settings",
@@ -12535,8 +12532,7 @@
"iconPathOff": "delete"
}
],
"addLeftIcons": true,
"icon": "bitcoin"
"addLeftIcons": true
},
{
"type": "Charting Space",
@@ -12959,6 +12955,12 @@
"relatedUiObject": "Layer",
"actionFunction": "payload.onMenuItemClick"
},
{
"action": "Add UI Object",
"label": "Add Bot Layers",
"relatedUiObject": "Bot Layers",
"actionFunction": "payload.onMenuItemClick"
},
{
"action": "Add All Mine Layers",
"label": "Add All Mine Layers",
@@ -12993,7 +12995,7 @@
"compatibleTypes": "->Timeline Chart->"
},
"referenceAttachesTo": {
"compatibleTypes": "->Data Mine Products->"
"compatibleTypes": "->Data Mine Products->Trading Mine Products->"
},
"propertyNameAtParent": "layerManager",
"properties": [
@@ -14347,7 +14349,7 @@
"addLeftIcons": true,
"level": 3,
"chainAttachesTo": {
"compatibleTypes": "->Data Mine Products->"
"compatibleTypes": "->Data Mine Products->Trading Mine Products->"
},
"propertyNameAtParent": "botProducts",
"properties": [
@@ -14462,8 +14464,7 @@
"childType": "Plugin Tutorials",
"autoAdd": false
}
],
"icon": "bitcoin"
]
},
{
"type": "Plugin Data Mines",
@@ -14497,8 +14498,7 @@
"childType": "Plugin File",
"autoAdd": false
}
],
"icon": "bitcoin"
]
},
{
"type": "Plugin Trading Mines",
@@ -14532,8 +14532,7 @@
"childType": "Plugin File",
"autoAdd": false
}
],
"icon": "bitcoin"
]
},
{
"type": "Plugin Trading Systems",
@@ -14567,8 +14566,7 @@
"childType": "Plugin File",
"autoAdd": false
}
],
"icon": "bitcoin"
]
},
{
"type": "Plugin Trading Engines",
@@ -14602,8 +14600,7 @@
"childType": "Plugin File",
"autoAdd": false
}
],
"icon": "bitcoin"
]
},
{
"type": "Plugin Super Scripts",
@@ -14637,8 +14634,7 @@
"childType": "Plugin File",
"autoAdd": false
}
],
"icon": "bitcoin"
]
},
{
"type": "Plugin Tutorials",
@@ -14672,8 +14668,7 @@
"childType": "Plugin File",
"autoAdd": false
}
],
"icon": "bitcoin"
]
},
{
"type": "Plugin File",
@@ -14706,8 +14701,7 @@
"childType": "Plugin File Position",
"autoAdd": false
}
],
"icon": "bitcoin"
]
},
{
"type": "Plugin File Position",
@@ -14729,8 +14723,7 @@
"level": 3,
"propertyNameAtParent": "pluginFilePosition",
"properties": [
],
"icon": "bitcoin"
]
},
{
"type": "Tutorial",
-218
View File
@@ -1,218 +0,0 @@
let dashboard
function newAppLoader() {
const MODULE_NAME = 'App Loader'
const INFO_LOG = false
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
let thisObject = {
loadModules: loadModules
}
return thisObject
async function loadModules() {
try {
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> Entering function.') }
let plotters
let modulesArray = []
plotters = defaultPlotters()
modulesArray = modulesArray.concat([
'ChartingSpace/Viewport.js',
'Globals.js',
'AppSchema.js',
'DocSchema.js',
'ConceptSchema.js',
'Workspace.js',
'ChartingSpace/EdgeEditor.js',
'ChartingSpace/ChartUtilities.js',
'ChartingSpace/PlottersManager.js',
'ChartingSpace/TimelineChart.js',
'ChartingSpace/TimeMachine.js',
'ChartingSpace/CoordinateSystem.js',
'DesignSpace/Workspace/Workspace.js',
'DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js',
'DesignSpace/Workspace/FunctionLibraries/ChainAttachDetach.js',
'DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js',
'DesignSpace/Workspace/FunctionLibraries/NodeDeleter.js',
'DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js',
'DesignSpace/Workspace/FunctionLibraries/NodeCloning.js',
'DesignSpace/Workspace/FunctionLibraries/NodeChildren.js',
'DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js',
'DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js',
'DesignSpace/Workspace/FunctionLibraries/ShortcutKeys.js',
'DesignSpace/Workspace/FunctionLibraries/OnFocus.js',
'DesignSpace/Workspace/FunctionLibraries/SuperScripts.js',
'DesignSpace/Workspace/FunctionLibraries/CryptoEcosystemFunctions.js',
'DesignSpace/Workspace/FunctionLibraries/WebhookFunctions.js',
'DesignSpace/Workspace/FunctionLibraries/DependenciesFilter.js',
'DesignSpace/Workspace/FunctionLibraries/NodePath.js',
'DesignSpace/Workspace/FunctionLibraries/DataMineFunctions.js',
'DesignSpace/Workspace/FunctionLibraries/DataStorageFunctions.js',
'DesignSpace/Workspace/FunctionLibraries/ChartingSpaceFunctions.js',
'DesignSpace/Workspace/FunctionLibraries/TutorialFunctions.js',
'DesignSpace/Workspace/FunctionLibraries/PluginsFunctions.js',
'Utilities/CoordinateTransformations.js',
'Utilities/DateRateTransformations.js',
'Utilities/Download.js',
'Utilities/Clipboard.js',
'Utilities/DrawPrint.js',
'Utilities/LoadSaveFrame.js',
'Utilities/LoadSaveTutorial.js',
'Utilities/NodeConfig.js',
'Utilities/Hiriarchy.js',
'Utilities/Folders.js',
'Utilities/Branches.js',
'Utilities/Meshes.js',
'Utilities/NodeChildren.js',
'Utilities/Menu.js',
'Utilities/Dates.js',
'Panels/LayersPanel.js',
'Panels/UpDownButton.js',
'Panels/LeftRightButton.js',
'Panels/Layer.js',
'Panels/PlotterPanel.js',
'Panels/PanelsVisibleButton.js',
'SideSpace/SidePanelTab.js',
'SideSpace/ListView.js',
'SideSpace/ListItem.js',
'Spaces/CockpitSpace.js',
'Spaces/TopSpace.js',
'Spaces/PanelsSpace.js',
'Spaces/ChartingSpace.js',
'Spaces/FloatingSpace.js',
'Spaces/DesignSpace.js',
'Spaces/SideSpace.js',
'Spaces/DocSpace.js',
'Spaces/ChatSpace.js',
'Spaces/TutorialSpace.js',
'Files/SingleFile.js',
'Files/FileCloud.js',
'Files/MarketFiles.js',
'Files/DailyFiles.js',
'Files/FileCursor.js',
'Files/FileSequence.js',
'Files/FileStorage.js',
'FloatingSpace/FloatingObject.js',
'FloatingSpace/FloatingLayer.js',
'FloatingSpace/UiObjectConstructor.js',
'FloatingSpace/UiObject.js',
'FloatingSpace/UiObjectTitle.js',
'FloatingSpace/CircularMenu.js',
'FloatingSpace/CircularMenuItem.js',
'FloatingSpace/CircularProgressBar.js',
'FloatingSpace/BusyProgressBar.js',
'FloatingSpace/CodeEditor.js',
'FloatingSpace/ConfigEditor.js',
'FloatingSpace/ConditionEditor.js',
'FloatingSpace/FormulaEditor.js',
'FloatingSpace/Picker.js',
'Scales/RateScale.js',
'Scales/TimeScale.js',
'Scales/TimeFrameScale.js',
'Scales/Commons.js',
'Scales/AutoScaleButton.js',
'CockpitSpace/AssetBalances.js',
'CockpitSpace/Speedometer.js',
'CockpitSpace/FullScreen.js',
'EventsServerClient.js',
'Plotting/Plotter.js',
'Plotting/NodesHighlights.js',
'Plotting/NodesErrors.js',
'Plotting/NodesWarnings.js',
'Plotting/NodesInfos.js',
'Plotting/NodesValues.js',
'Plotting/NodesStatus.js',
'Plotting/NodesProgress.js',
'Plotting/NodesRunning.js',
'Plotting/NodesAnnouncements.js',
'Plotting/RecordValues.js',
'LegacyPlotter.js',
'PlotterPanel.js',
'VideoRecorder.js',
'ProductStorage.js',
'SplashScreen.js',
'Canvas.js',
'EventHandler.js',
'Frame.js',
'Animation.js',
'Container.js',
'Utilities.js',
'PostLoader.js'
])
modulesArray = modulesArray.concat(plotters)
let downloadedCounter = 0
for (let i = 0; i < modulesArray.length; i++) {
let path = modulesArray[i]
REQUIREJS([path], onRequired)
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> Module Requested.') }
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> path = ' + path) }
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> total requested = ' + (i + 1)) }
function onRequired(pModule) {
try {
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> Entering function.') }
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> Module Downloaded.') }
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> path = ' + path) }
downloadedCounter++
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> downloadedCounter = ' + downloadedCounter) }
if (downloadedCounter === modulesArray.length) {
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> Starting Advanced Algos Platform.') }
setTimeout(() => {
dashboard = newDashboard()
dashboard.start()
}, 500)
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] loadModules -> onRequired -> err = ' + err.stack) }
}
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] loadModules -> err = ' + err.stack) }
}
}
function defaultPlotters() {
return [
'Plotters/Masters/Plotters-Candles-Volumes/Candles.js',
'Plotters/Masters/Plotters-Candles-Volumes/CandlePanel.js',
'Plotters/Masters/Plotters-Candles-Volumes/Volumes.js',
'Plotters/Masters/Plotters-Candles-Volumes/VolumePanel.js',
'Plotters/Masters/Plotters-Bollinger-Bands/BollingerBands.js',
'Plotters/Masters/Plotters-Bollinger-Bands/BollingerBandsPanel.js',
'Plotters/Masters/Plotters-Bollinger-Bands/PercentageBandwidth.js'
]
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 926 KiB

After

Width:  |  Height:  |  Size: 1.1 MiB

+54
View File
@@ -0,0 +1,54 @@
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Web3=t():e.Web3=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=171)}([function(e,t,r){"use strict";e.exports=function(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){"use strict";function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=n=function(e){return typeof e}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(t)}e.exports=n},function(e,t,r){"use strict";(function(e){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
var n=r(178),i=r(179),o=r(90);function a(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,t){if(a()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return h(this,e)}return f(this,e,t,r)}function f(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=d(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,r),i=(e=s(e,n)).write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(u.isBuffer(t)){var r=0|l(t.length);return 0===(e=s(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?s(e,0):d(e,t);if("Buffer"===t.type&&o(t.data))return d(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function h(e,t){if(c(t),e=s(e,t<0?0:0|l(t)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function d(e,t){var r=t.length<0?0:0|l(t.length);e=s(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function l(e){if(e>=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|e}function p(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return D(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(n)return D(e).length;t=(""+t).toLowerCase(),n=!0}}function b(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return O(this,t,r);case"utf8":case"utf-8":return x(this,t,r);case"ascii":return M(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function m(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function y(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var c=-1;for(o=r;o<s;o++)if(f(e,o)===f(t,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===u)return c*a}else-1!==c&&(o-=o-c),c=-1}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){for(var h=!0,d=0;d<u;d++)if(f(e,o+d)!==f(t,d)){h=!1;break}if(h)return o}return-1}function g(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a<n;++a){var s=parseInt(t.substr(2*a,2),16);if(isNaN(s))return a;e[r+a]=s}return a}function w(e,t,r,n){return z(D(t,e.length-r),e,r,n)}function _(e,t,r,n){return z(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function k(e,t,r,n){return _(e,t,r,n)}function A(e,t,r,n){return z(q(t),eLine truncated
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;function a(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,s,u=a(e),f=1;f<arguments.length;f++){for(var c in r=Object(arguments[f]))i.call(r,c)&&(u[c]=r[c]);if(n){s=n(r);for(var h=0;h<s.length;h++)o.call(r,s[h])&&(u[s[h]]=r[s[h]])}}return u}},function(e,t,r){"use strict";var n=r(445);e.exports=Function.prototype.bind||n},function(e,t,r){"use strict";var n=r(0)(r(1)),i=Function.prototype.toString,o=/^\s*class\b/,a=function(e){try{var t=i.call(e);return o.test(t)}catch(e){return!1}},s=Object.prototype.toString,u="function"==typeof Symbol&&"symbol"===(0,n.default)(Symbol.toStringTag);e.exports=function(e){if(!e)return!1;if("function"!=typeof e&&"object"!==(0,n.default)(e))return!1;if("function"==typeof e&&!e.prototype)return!0;if(u)return function(e){try{return!a(e)&&(i.call(e),!0)}catch(e){return!1}}(e);if(a(e))return!1;var t=s.call(e);return"[object Function]"===t||"[object GeneratorFunction]"===t}},function(e,t,r){"use strict";(function(e){var n=r(0)(r(1)),i=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),r={},n=0;n<t.length;n++)r[t[n]]=Object.getOwnPropertyDescriptor(e,t[n]);return r},o=/%[sdj%]/g;t.format=function(e){if(!v(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(u(arguments[r]));return t.join(" ")}r=1;for(var n=arguments,i=n.length,a=String(e).replace(o,(function(e){if("%%"===e)return"%";if(r>=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r<i;s=n[++r])m(s)||!_(s)?a+=" "+s:a+=" "+u(s);return a},t.deprecate=function(r,n){if(void 0!==e&&!0===e.noDeprecation)return r;if(void 0===e)return function(){return t.deprecate(r,n).apply(this,arguments)};var i=!1;return function(){if(!i){if(e.throwDeprecation)throw new Error(n);e.traceDeprecation?console.trace(n):console.error(n),i=!0}return r.apply(this,arguments)}};var a,s={};function u(e,r){var n={seen:[],stylize:c};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),b(r)?n.showHidden=r:r&&t._extend(n,r),g(n.showHidden)&&(n.showHidden=!1),g(n.depth)&&(n.depth=2),g(n.colors)&&(n.colors=!1),g(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=f),h(n,e,n.depth)}function f(e,t){var r=u.styles[t];return r?"["+u.colors[r][0]+"m"+e+"["+u.colors[r][1]+"m":e}function c(e,t){return e}function h(e,r,n){if(e.customInspect&&r&&S(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,e);return v(i)||(i=h(e,i,n)),i}var o=function(e,t){if(g(t))return e.stylize("undefined","undefined");if(v(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(y(t))return e.stylize(""+t,"number");if(b(t))return e.stylize(""+t,"boolean");if(m(t))return e.stylize("null","null")}(e,r);if(o)return o;var a=Object.keys(r),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(r)),A(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return d(r);if(0===a.length){if(S(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(w(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(k(r))return e.stylize(Date.prototype.toString.call(r),"date");if(A(r))return d(r)}var f,c="",_=!1,E=["{","}"];(p(r)&&(_=!0,E=["[","]"]),S(r))&&(c=" [Function"+(r.name?": "+r.name:"")+"]");return w(r)&&(c=" "+RegExp.prototype.toString.call(r)),k(r)&&(c=" "+Date.prototype.toUTCString.call(r)),A(r)&&(c=" "+d(r)),0!==a.length||_&&0!=r.length?n<0?w(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),f=_?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a<s;++a)O(t,String(a))?o.push(l(e,t,r,n,String(a),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(l(e,t,r,n,i,!0))})),o}(e,r,n,s,a):a.map((function(t){return l(e,r,n,s,t,_)})),e.seen.pop(),function(e,t,r){if(e.reduce((function(e,t){return t.indexOf("\n")>=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(f,c,E)):E[0]+c+E[1]}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i,Line truncated
/*! https://mths.be/utf8js v3.0.0 by @mathias */!function(e){var t,r,n,i=String.fromCharCode;function o(e){for(var t,r,n=[],i=0,o=e.length;i<o;)(t=e.charCodeAt(i++))>=55296&&t<=56319&&i<o?56320==(64512&(r=e.charCodeAt(i++)))?n.push(((1023&t)<<10)+(1023&r)+65536):(n.push(t),i--):n.push(t);return n}function a(e){if(e>=55296&&e<=57343)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value")}function s(e,t){return i(e>>t&63|128)}function u(e){if(0==(4294967168&e))return i(e);var t="";return 0==(4294965248&e)?t=i(e>>6&31|192):0==(4294901760&e)?(a(e),t=i(e>>12&15|224),t+=s(e,6)):0==(4292870144&e)&&(t=i(e>>18&7|240),t+=s(e,12),t+=s(e,6)),t+=i(63&e|128)}function f(){if(n>=r)throw Error("Invalid byte index");var e=255&t[n];if(n++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function c(){var e,i;if(n>r)throw Error("Invalid byte index");if(n==r)return!1;if(e=255&t[n],n++,0==(128&e))return e;if(192==(224&e)){if((i=(31&e)<<6|f())>=128)return i;throw Error("Invalid continuation byte")}if(224==(240&e)){if((i=(15&e)<<12|f()<<6|f())>=2048)return a(i),i;throw Error("Invalid continuation byte")}if(240==(248&e)&&(i=(7&e)<<18|f()<<12|f()<<6|f())>=65536&&i<=1114111)return i;throw Error("Invalid UTF-8 detected")}e.version="3.0.0",e.encode=function(e){for(var t=o(e),r=t.length,n=-1,i="";++n<r;)i+=u(t[n]);return i},e.decode=function(e){t=o(e),r=t.length,n=0;for(var a,s=[];!1!==(a=c());)s.push(a);return function(e){for(var t,r=e.length,n=-1,o="";++n<r;)(t=e[n])>65535&&(o+=i((t-=65536)>>>10&1023|55296),t=56320|1023&t),o+=i(t);return o}(s)}}(t)},function(e,t,r){"use strict";var n=r(0)(r(1));Object.defineProperty(t,"__esModule",{value:!0});var i=r(186);function o(e){return"string"==typeof e&&(!!/^(0x)?[0-9a-f]{512}$/i.test(e)&&!(!/^(0x)?[0-9a-f]{512}$/.test(e)&&!/^(0x)?[0-9A-F]{512}$/.test(e)))}function a(e,t){"object"===(0,n.default)(t)&&t.constructor===Uint8Array&&(t=i.bytesToHex(t));for(var r=i.keccak256(t).replace("0x",""),o=0;o<12;o+=4){var a=(parseInt(r.substr(o,2),16)<<8)+parseInt(r.substr(o+2,2),16)&2047,u=1<<a%4;if((s(e.charCodeAt(e.length-1-Math.floor(a/4)))&u)!==u)return!1}return!0}function s(e){if(e>=48&&e<=57)return e-48;if(e>=65&&e<=70)return e-55;if(e>=97&&e<=102)return e-87;throw new Error("invalid bloom")}function u(e){return"string"==typeof e&&(!!/^(0x)?[0-9a-f]{64}$/i.test(e)&&!(!/^(0x)?[0-9a-f]{64}$/.test(e)&&!/^(0x)?[0-9A-F]{64}$/.test(e)))}function f(e){return"string"==typeof e&&(!!e.match(/^(0x)?[0-9a-fA-F]{40}$/)||!!e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/))}t.isBloom=o,t.isInBloom=a,t.isUserEthereumAddressInBloom=function(e,t){if(!o(e))throw new Error("Invalid bloom given");if(!f(t))throw new Error('Invalid ethereum address given: "'.concat(t,'"'));return a(e,i.padLeft(t,64))},t.isContractAddressInBloom=function(e,t){if(!o(e))throw new Error("Invalid bloom given");if(!f(t))throw new Error('Invalid contract address given: "'.concat(t,'"'));return a(e,t)},t.isTopicInBloom=function(e,t){if(!o(e))throw new Error("Invalid bloom given");if(!u(t))throw new Error("Invalid topic");return a(e,t)},t.isTopic=u,t.isAddress=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(187);function i(e){if(null==e)throw new Error("cannot convert null value to array");if("string"==typeof e){var t=e.match(/^(0x)?[0-9a-fA-F]*$/);if(!t)throw new Error("invalid hexidecimal string");if("0x"!==t[1])throw new Error("hex string must have 0x prefix");(e=e.substring(2)).length%2&&(e="0"+e);for(var r=[],n=0;n<e.length;n+=2)r.push(parseInt(e.substr(n,2),16));return o(new Uint8Array(r))}if(function(e){if(!e||parseInt(String(e.length))!=e.length||"string"==typeof e)return!1;for(var t=0;t<e.length;t++){var r=e[t];if(r<0||r>=256||parseInt(String(r))!=r)return!1}return!0}(e))return o(new Uint8Array(e));throw new Error("invalid arrayify value")}function o(e){return e.slice||(e.slice=function(){var t=Array.prototype.slice.call(arguments);return o(new Uint8Array(Array.prototype.slice.apply(e,t)))}),e}t.keccak256=function(e){return"0x"+n.keccak_256(i(e))},t.padLeft=function(e,t){var r=/^0x/i.test(e)||"number"==typeof e,n=t-(e=e.toString().replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(r?"0x":"")+new Array(n).join("0")+e},t.bytesToHex=function(e){for(var t=[],r=0;r<e.length;r++)t.push((e[r]>>>4).toString(16)),t.push((15&e[r]).toString(16));return"0x".concat(t.join("").replace(/^0+/,""))},t.toByteArray=i},function(e,t,r){"use strict";(function(e,n,i){var o,a=r(0)(r(1));
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2018
* @license MIT
*/
!function(){var s="input is invalid type",u="object"===("undefined"==typeof window?"undefined":(0,a.default)(window)),f=u?window:{};f.JS_SHA3_NO_WINDOW&&(u=!1);var c=!u&&"object"===("undefined"==typeof self?"undefined":(0,a.default)(self));!f.JS_SHA3_NO_NODE_JS&&"object"===(void 0===e?"undefined":(0,a.default)(e))&&e.versions&&e.versions.node?f=n:c&&(f=self);var h=!f.JS_SHA3_NO_COMMON_JS&&"object"===(0,a.default)(i)&&i.exports,d=r(62),l=!f.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,p="0123456789abcdef".split(""),b=[4,1024,262144,67108864],m=[0,8,16,24],y=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],v=[224,256,384,512],g=[128,256],w=["hex","buffer","arrayBuffer","array","digest"],_={128:168,256:136};!f.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!l||!f.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"===(0,a.default)(e)&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var k=function(e,t,r){return function(n){return new j(e,t,e).update(n)[r]()}},A=function(e,t,r){return function(n,i){return new j(e,t,i).update(n)[r]()}},S=function(e,t,r){return function(t,n,i,o){return O["cshake"+e].update(t,n,i,o)[r]()}},E=function(e,t,r){return function(t,n,i,o){return O["kmac"+e].update(t,n,i,o)[r]()}},x=function(e,t,r,n){for(var i=0;i<w.length;++i){var o=w[i];e[o]=t(r,n,o)}return e},M=function(e,t){var r=k(e,t,"hex");return r.create=function(){return new j(e,t,e)},r.update=function(e){return r.create().update(e)},x(r,k,e,t)},I=[{name:"keccak",padding:[1,256,65536,16777216],bits:v,createMethod:M},{name:"sha3",padding:[6,1536,393216,100663296],bits:v,createMethod:M},{name:"shake",padding:[31,7936,2031616,520093696],bits:g,createMethod:function(e,t){var r=A(e,t,"hex");return r.create=function(r){return new j(e,t,r)},r.update=function(e,t){return r.create(t).update(e)},x(r,A,e,t)}},{name:"cshake",padding:b,bits:g,createMethod:function(e,t){var r=_[e],n=S(e,0,"hex");return n.create=function(n,i,o){return i||o?new j(e,t,n).bytepad([i,o],r):O["shake"+e].create(n)},n.update=function(e,t,r,i){return n.create(t,r,i).update(e)},x(n,S,e,t)}},{name:"kmac",padding:b,bits:g,createMethod:function(e,t){var r=_[e],n=E(e,0,"hex");return n.create=function(n,i,o){return new L(e,t,i).bytepad(["KMAC",o],r).bytepad([n],r)},n.update=function(e,t,r,i){return n.create(e,r,i).update(t)},x(n,E,e,t)}}],O={},C=[],P=0;P<I.length;++P)for(var T=I[P],U=T.bits,B=0;B<U.length;++B){var R=T.name+"_"+U[B];if(C.push(R),O[R]=T.createMethod(U[B],T.padding),"sha3"!==T.name){var N=T.name+U[B];C.push(N),O[N]=O[R]}}function j(e,t,r){this.blocks=[],this.s=[],this.padding=t,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(e<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function L(e,t,r){j.call(this,e,t,r)}j.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t,r=(0,a.default)(e);if("string"!==r){if("object"!==r)throw new Error(s);if(null===e)throw new Error(s);if(l&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||l&&ArrayBuffer.isView(e)))throw new Error(s);t=!0}for(var n,i,o=this.blocks,u=this.byteCount,f=e.length,c=this.blockCount,h=0,d=this.s;h<f;){if(this.reset)for(this.reset=!1,o[0]=this.block,n=1;n<c+1;++n)o[n]=0;if(t)for(n=this.start;h<f&&n<u;++h)o[n>>2]|=e[h]<<m[3&n++];else for(n=this.start;h<f&&n<u;++h)(i=e.charCodeAt(h))<128?o[n>>2]|=i<<m[3&n++]:i<2048?(o[n>>2]|=(192|i>>6)<<m[3&n++],o[n>>2]|=(128|63&i)<<m[3&n++]):i<55296||i>=57344?(o[n>>2]|=(224|i>>12)<<m[3&n++],o[n>>2]|=(128|i>>6&63)<<m[3&n++],o[n>>2]|=(128|63&i)<<m[3&n++]):(i=65536+((1023&i)<<10|1023&e.charCodeAt(++h)),o[n>>2]|=(240|i>>18)<<m[3&n++],o[n>>2]|=(128|i>>12&63)<<m[3&n++],o[n>>2]|=(128|i>>6&63)<<m[3&n++],o[n>>2]|=(128|63&i)<<m[3&n++]);if(this.lastByteIndex=n,n>=u){for(this.start=n-u,this.block=o[c],n=0;n<c;++n)d[n]^=o[n];F(d),this.reset=!0}else this.start=n}return this},j.prototype.encode=function(e,t){var r=255&e,n=1,i=[r];for(r=255&(e>>=8);r>0;)i.unshift(r),r=255&(e>>=8),++n;return t?i.push(n):i.unshift(n),this.update(i),i.length},j.prototype.encodeString=function(e){var t,r=(0,a.default)(e);if("string"!==r){if("object"!==r)throw new Error(s);if(null===e)throw new Error(s);if(l&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||l&&ArrayBuffer.isView(e)))throw new Error(s);t=!0}var n=0,i=e.length;if(t)n=i;else for(var o=0;o<e.length;++o){var u=e.charCodeAt(o);u<128?n+=1:u<2048?n+=2:u<55296||u>=57344?n+=3:(u=65536+((1023&u)<<10|1023&Line truncated
/*!
* v2.1.4-104-gc868b3a
*
*/
a=function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=7)}([function(e,t,r){r.d(t,"j",(function(){return i})),r.d(t,"d",(function(){return o})),r.d(t,"c",(function(){return a})),r.d(t,"h",(function(){return s})),r.d(t,"b",(function(){return u})),r.d(t,"k",(function(){return f})),r.d(t,"e",(function(){return c})),r.d(t,"g",(function(){return h})),r.d(t,"i",(function(){return d})),r.d(t,"a",(function(){return l})),r.d(t,"f",(function(){return p}));var n=r(1),i=f((function(e,t){var r=t.length;return f((function(n){for(var i=0;i<n.length;i++)t[r+i]=n[i];return t.length=r+n.length,e.apply(this,t)}))}));function o(e,t){return function(){return e.call(this,t.apply(this,arguments))}}function a(e){return function(t){return t[e]}}f((function(e){var t=Object(n.c)(e);function r(e,t){return[u(e,t)]}return f((function(e){return Object(n.f)(r,e,t)[0]}))}));var s=f((function(e){return f((function(t){for(var r,n=0;n<a("length")(e);n++)if(r=u(t,e[n]))return r}))}));function u(e,t){return t.apply(void 0,e)}function f(e){var t=e.length-1,r=Array.prototype.slice;if(0===t)return function(){return e.call(this,r.call(arguments))};if(1===t)return function(){return e.call(this,arguments[0],r.call(arguments,1))};var n=Array(e.length);return function(){for(var i=0;i<t;i++)n[i]=arguments[i];return n[t]=r.call(arguments,t),e.apply(this,n)}}function c(e){return function(t,r){return e(r,t)}}function h(e,t){return function(r){return e(r)&&t(r)}}function d(){}function l(){return!0}function p(e){return function(){return e}}},function(e,t,r){r.d(t,"d",(function(){return i})),r.d(t,"g",(function(){return o})),r.d(t,"l",(function(){return a})),r.d(t,"c",(function(){return s})),r.d(t,"h",(function(){return u})),r.d(t,"i",(function(){return f})),r.d(t,"j",(function(){return c})),r.d(t,"f",(function(){return h})),r.d(t,"m",(function(){return d})),r.d(t,"a",(function(){return l})),r.d(t,"b",(function(){return p})),r.d(t,"k",(function(){return b})),r.d(t,"e",(function(){return m}));var n=r(0);function i(e,t){return[e,t]}var o=Object(n.c)(0),a=Object(n.c)(1);function s(e){return b(e.reduce(Object(n.e)(i),null))}var u=Object(n.k)(s);function f(e){return h((function(e,t){return e.unshift(t),e}),[],e)}function c(e,t){return t?i(e(o(t)),c(e,a(t))):null}function h(e,t,r){return r?e(h(e,t,a(r)),o(r)):t}function d(e,t,r){return function e(r,n){return r?t(o(r))?(n(o(r)),a(r)):i(o(r),e(a(r),n)):null}(e,r||n.i)}function l(e,t){return!t||e(o(t))&&l(e,a(t))}function p(e,t){e&&(o(e).apply(null,t),p(a(e),t))}function b(e){return function e(t,r){return t?e(a(t),i(o(t),r)):r}(e,null)}function m(e,t){return t&&(e(o(t))?o(t):m(e,a(t)))}},function(e,t,r){r.d(t,"c",(function(){return o})),r.d(t,"e",(function(){return a})),r.d(t,"d",(function(){return s})),r.d(t,"a",(function(){return u})),r.d(t,"b",(function(){return f}));var n=r(1),i=r(0);function o(e,t){return t&&t.constructor===e}var a=Object(i.c)("length"),s=Object(i.j)(o,String);function u(e){return void 0!==e}function f(e,t){return t instanceof Object&&Object(n.a)((function(e){return e in t}),e)}},function(e,t,r){r.d(t,"f",(function(){return i})),r.d(t,"d",(function(){return o})),r.d(t,"g",(function(){return a})),r.d(t,"e",(function(){return s})),r.d(t,"b",(function(){return u})),r.d(t,"h",(function(){return f})),r.d(t,"i",(function(){return c})),r.d(t,"c",(function(){return h})),r.d(t,"m",(function(){return d})),r.d(t,"n",(function(){return l})),r.d(t,"a",(function(){return p})),r.d(t,"j",(function(){return b})),r.d(t,"l",(function(){return m})),r.d(t,"k",(function(){return y})),r.d(t,"o",(function(){return v}));var n=1,i=n++,o=n++,a=n++,s=n++,u="fail",f=n++,c=n++,h="start",d="data",l="end",p=n++,b=n++,m=n++,y=n++;function v(e,t,r){try{var n=JSON.parse(t)}catch(e){}return{statusCode:e,body:t,jsonBody:n,thrown:r}}},function(e,t,r){r.d(t,"b",(function(){return i})),r.d(t,"a",(function(){return o})),r.d(t,"c",(function(){return a}));var n=r(0);function i(e,t){return{key:e,node:t}}var o=Object(n.c)("key"),a=Object(n.c)("node")},function(e,t,r){r.d(t,"a",(function(){return u}));var n=r(1),i=r(0),o=r(2),a=r(8),s=r(9);function u(e){var t=Object(n.h)("resume","pause","pipe"),r=Object(i.j)(o.b,t);return e?r(e)||Object(o.d)(e)?Object(a.a)(s.a,e):Object(a.a)(s.a,e.url,e.method,e.body,e.headers,e.withCredentials,e.cached):Object(s.a)()}u.drop=function(){return u.drop}},function(e,t,r){r.d(t,"b",(function(){return u})),r.d(t,"a",(function(){return s}));var n=r(3),i=r(4),o=r(2),a=r(1),s={};function u(e){var t=e(n.f).emit,r=e(n.d).emit,u=e(n.i).emit,f=e(n.h).emit;function c(e,t,r){Object(i.c)(Object(a.g)Line truncated
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.5.7
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2016
* @license MIT
*/
!function(){var r="object"===("undefined"==typeof window?"undefined":(0,i.default)(window))?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"===(void 0===e?"undefined":(0,i.default)(e))&&e.versions&&e.versions.node&&(r=t);for(var o=!r.JS_SHA3_NO_COMMON_JS&&"object"===(0,i.default)(n)&&n.exports,a="0123456789abcdef".split(""),s=[0,8,16,24],u=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],f=[224,256,384,512],c=["hex","buffer","arrayBuffer","array"],h=function(e,t,r){return function(n){return new k(e,t,e).update(n)[r]()}},d=function(e,t,r){return function(n,i){return new k(e,t,i).update(n)[r]()}},l=function(e,t){var r=h(e,t,"hex");r.create=function(){return new k(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n<c.length;++n){var i=c[n];r[i]=h(e,t,i)}return r},p=[{name:"keccak",padding:[1,256,65536,16777216],bits:f,createMethod:l},{name:"sha3",padding:[6,1536,393216,100663296],bits:f,createMethod:l},{name:"shake",padding:[31,7936,2031616,520093696],bits:[128,256],createMethod:function(e,t){var r=d(e,t,"hex");r.create=function(r){return new k(e,t,r)},r.update=function(e,t){return r.create(t).update(e)};for(var n=0;n<c.length;++n){var i=c[n];r[i]=d(e,t,i)}return r}}],b={},m=[],y=0;y<p.length;++y)for(var v=p[y],g=v.bits,w=0;w<g.length;++w){var _=v.name+"_"+g[w];m.push(_),b[_]=v.createMethod(g[w],v.padding)}function k(e,t,r){this.blocks=[],this.s=[],this.padding=t,this.outputBits=r,this.reset=!0,this.block=0,this.start=0,this.blockCount=1600-(e<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}k.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,o=this.blocks,a=this.byteCount,u=this.blockCount,f=0,c=this.s;f<i;){if(this.reset)for(this.reset=!1,o[0]=this.block,r=1;r<u+1;++r)o[r]=0;if(t)for(r=this.start;f<i&&r<a;++f)o[r>>2]|=e[f]<<s[3&r++];else for(r=this.start;f<i&&r<a;++f)(n=e.charCodeAt(f))<128?o[r>>2]|=n<<s[3&r++]:n<2048?(o[r>>2]|=(192|n>>6)<<s[3&r++],o[r>>2]|=(128|63&n)<<s[3&r++]):n<55296||n>=57344?(o[r>>2]|=(224|n>>12)<<s[3&r++],o[r>>2]|=(128|n>>6&63)<<s[3&r++],o[r>>2]|=(128|63&n)<<s[3&r++]):(n=65536+((1023&n)<<10|1023&e.charCodeAt(++f)),o[r>>2]|=(240|n>>18)<<s[3&r++],o[r>>2]|=(128|n>>12&63)<<s[3&r++],o[r>>2]|=(128|n>>6&63)<<s[3&r++],o[r>>2]|=(128|63&n)<<s[3&r++]);if(this.lastByteIndex=r,r>=a){for(this.start=r-a,this.block=o[u],r=0;r<u;++r)c[r]^=o[r];A(c),this.reset=!0}else this.start=r}return this},k.prototype.finalize=function(){var e=this.blocks,t=this.lastByteIndex,r=this.blockCount,n=this.s;if(e[t>>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t<r+1;++t)e[t]=0;for(e[r-1]|=2147483648,t=0;t<r;++t)n[t]^=e[t];A(n)},k.prototype.toString=k.prototype.hex=function(){this.finalize();for(var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,u="";s<n;){for(o=0;o<t&&s<n;++o,++s)e=r[o],u+=a[e>>4&15]+a[15&e]+a[e>>12&15]+a[e>>8&15]+a[e>>20&15]+a[e>>16&15]+a[e>>28&15]+a[e>>24&15];s%t==0&&(A(r),o=0)}return i&&(e=r[o],i>0&&(u+=a[e>>4&15]+a[15&e]),i>1&&(u+=a[e>>12&15]+a[e>>8&15]),i>2&&(u+=a[e>>20&15]+a[e>>16&15])),u},k.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a<n;){for(o=0;o<t&&a<n;++o,++a)u[a]=r[o];a%t==0&&A(r)}return i&&(u[o]=r[o],e=e.slice(0,s)),e},k.prototype.buffer=k.prototype.arrayBuffer,k.prototype.digest=k.prototype.array=function(){this.finalize();for(var e,t,r=this.blockCount,n=this.s,i=this.outputBlocks,o=this.extraBytes,a=0,s=0,u=[];s<i;){for(a=0;a<r&&s<i;++a,++s)e=s<<2,t=n[a],u[e]=255&t,u[e+1]=t>>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&A(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var A=function(e){var t,r,n,i,o,a,s,f,c,h,d,l,p,b,m,y,v,g,w,_,k,A,S,E,x,M,I,O,C,P,T,U,B,R,N,j,L,F,D,q,z,H,K,V,G,W,Y,$,J,Z,X,Q,ee,te,re,ne,ie,oe,ae,se,ue,fe,ce;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],s=e[3]^e[13]^e[23]^e[33]^e[43],f=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],d=e[7]^e[17]^e[27]^e[37]^e[47],t=(l=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|s>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(s<<1|a>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(f<<1|c>>>31),r=o^(c<<1|f>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=a^(h<<1|d>>>31),r=s^(d<<1|h>>>31),e[4]^=t,e[5]^=rLine truncated
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.5.7
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2016
* @license MIT
*/
!function(){var r="object"===("undefined"==typeof window?"undefined":(0,i.default)(window))?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"===(void 0===e?"undefined":(0,i.default)(e))&&e.versions&&e.versions.node&&(r=t);for(var o=!r.JS_SHA3_NO_COMMON_JS&&"object"===(0,i.default)(n)&&n.exports,a="0123456789abcdef".split(""),s=[0,8,16,24],u=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],f=[224,256,384,512],c=["hex","buffer","arrayBuffer","array"],h=function(e,t,r){return function(n){return new k(e,t,e).update(n)[r]()}},d=function(e,t,r){return function(n,i){return new k(e,t,i).update(n)[r]()}},l=function(e,t){var r=h(e,t,"hex");r.create=function(){return new k(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n<c.length;++n){var i=c[n];r[i]=h(e,t,i)}return r},p=[{name:"keccak",padding:[1,256,65536,16777216],bits:f,createMethod:l},{name:"sha3",padding:[6,1536,393216,100663296],bits:f,createMethod:l},{name:"shake",padding:[31,7936,2031616,520093696],bits:[128,256],createMethod:function(e,t){var r=d(e,t,"hex");r.create=function(r){return new k(e,t,r)},r.update=function(e,t){return r.create(t).update(e)};for(var n=0;n<c.length;++n){var i=c[n];r[i]=d(e,t,i)}return r}}],b={},m=[],y=0;y<p.length;++y)for(var v=p[y],g=v.bits,w=0;w<g.length;++w){var _=v.name+"_"+g[w];m.push(_),b[_]=v.createMethod(g[w],v.padding)}function k(e,t,r){this.blocks=[],this.s=[],this.padding=t,this.outputBits=r,this.reset=!0,this.block=0,this.start=0,this.blockCount=1600-(e<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}k.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,o=this.blocks,a=this.byteCount,u=this.blockCount,f=0,c=this.s;f<i;){if(this.reset)for(this.reset=!1,o[0]=this.block,r=1;r<u+1;++r)o[r]=0;if(t)for(r=this.start;f<i&&r<a;++f)o[r>>2]|=e[f]<<s[3&r++];else for(r=this.start;f<i&&r<a;++f)(n=e.charCodeAt(f))<128?o[r>>2]|=n<<s[3&r++]:n<2048?(o[r>>2]|=(192|n>>6)<<s[3&r++],o[r>>2]|=(128|63&n)<<s[3&r++]):n<55296||n>=57344?(o[r>>2]|=(224|n>>12)<<s[3&r++],o[r>>2]|=(128|n>>6&63)<<s[3&r++],o[r>>2]|=(128|63&n)<<s[3&r++]):(n=65536+((1023&n)<<10|1023&e.charCodeAt(++f)),o[r>>2]|=(240|n>>18)<<s[3&r++],o[r>>2]|=(128|n>>12&63)<<s[3&r++],o[r>>2]|=(128|n>>6&63)<<s[3&r++],o[r>>2]|=(128|63&n)<<s[3&r++]);if(this.lastByteIndex=r,r>=a){for(this.start=r-a,this.block=o[u],r=0;r<u;++r)c[r]^=o[r];A(c),this.reset=!0}else this.start=r}return this},k.prototype.finalize=function(){var e=this.blocks,t=this.lastByteIndex,r=this.blockCount,n=this.s;if(e[t>>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t<r+1;++t)e[t]=0;for(e[r-1]|=2147483648,t=0;t<r;++t)n[t]^=e[t];A(n)},k.prototype.toString=k.prototype.hex=function(){this.finalize();for(var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,u="";s<n;){for(o=0;o<t&&s<n;++o,++s)e=r[o],u+=a[e>>4&15]+a[15&e]+a[e>>12&15]+a[e>>8&15]+a[e>>20&15]+a[e>>16&15]+a[e>>28&15]+a[e>>24&15];s%t==0&&(A(r),o=0)}return i&&(e=r[o],i>0&&(u+=a[e>>4&15]+a[15&e]),i>1&&(u+=a[e>>12&15]+a[e>>8&15]),i>2&&(u+=a[e>>20&15]+a[e>>16&15])),u},k.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a<n;){for(o=0;o<t&&a<n;++o,++a)u[a]=r[o];a%t==0&&A(r)}return i&&(u[o]=r[o],e=e.slice(0,s)),e},k.prototype.buffer=k.prototype.arrayBuffer,k.prototype.digest=k.prototype.array=function(){this.finalize();for(var e,t,r=this.blockCount,n=this.s,i=this.outputBlocks,o=this.extraBytes,a=0,s=0,u=[];s<i;){for(a=0;a<r&&s<i;++a,++s)e=s<<2,t=n[a],u[e]=255&t,u[e+1]=t>>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&A(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var A=function(e){var t,r,n,i,o,a,s,f,c,h,d,l,p,b,m,y,v,g,w,_,k,A,S,E,x,M,I,O,C,P,T,U,B,R,N,j,L,F,D,q,z,H,K,V,G,W,Y,$,J,Z,X,Q,ee,te,re,ne,ie,oe,ae,se,ue,fe,ce;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],s=e[3]^e[13]^e[23]^e[33]^e[43],f=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],d=e[7]^e[17]^e[27]^e[37]^e[47],t=(l=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|s>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(s<<1|a>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(f<<1|c>>>31),r=o^(c<<1|f>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=a^(h<<1|d>>>31),r=s^(d<<1|h>>>31),e[4]^=t,e[5]^=rLine truncated
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
function o(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0}function a(e){return t.Buffer&&"function"==typeof t.Buffer.isBuffer?t.Buffer.isBuffer(e):!(null==e||!e._isBuffer)}var s=r(88),u=Object.prototype.hasOwnProperty,f=Array.prototype.slice,c="foo"===function(){}.name;function h(e){return Object.prototype.toString.call(e)}function d(e){return!a(e)&&("function"==typeof t.ArrayBuffer&&("function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):!!e&&(e instanceof DataView||!!(e.buffer&&e.buffer instanceof ArrayBuffer))))}var l=e.exports=g,p=/\s*function\s+([^\(\s]*)\s*/;function b(e){if(s.isFunction(e)){if(c)return e.name;var t=e.toString().match(p);return t&&t[1]}}function m(e,t){return"string"==typeof e?e.length<t?e:e.slice(0,t):e}function y(e){if(c||!s.isFunction(e))return s.inspect(e);var t=b(e);return"[Function"+(t?": "+t:"")+"]"}function v(e,t,r,n,i){throw new l.AssertionError({message:r,actual:e,expected:t,operator:n,stackStartFunction:i})}function g(e,t){e||v(e,!0,t,"==",l.ok)}function w(e,t,r,i){if(e===t)return!0;if(a(e)&&a(t))return 0===o(e,t);if(s.isDate(e)&&s.isDate(t))return e.getTime()===t.getTime();if(s.isRegExp(e)&&s.isRegExp(t))return e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase;if(null!==e&&"object"===(0,n.default)(e)||null!==t&&"object"===(0,n.default)(t)){if(d(e)&&d(t)&&h(e)===h(t)&&!(e instanceof Float32Array||e instanceof Float64Array))return 0===o(new Uint8Array(e.buffer),new Uint8Array(t.buffer));if(a(e)!==a(t))return!1;var u=(i=i||{actual:[],expected:[]}).actual.indexOf(e);return-1!==u&&u===i.expected.indexOf(t)||(i.actual.push(e),i.expected.push(t),function(e,t,r,n){if(null==e||null==t)return!1;if(s.isPrimitive(e)||s.isPrimitive(t))return e===t;if(r&&Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;var i=_(e),o=_(t);if(i&&!o||!i&&o)return!1;if(i)return e=f.call(e),t=f.call(t),w(e,t,r);var a,u,c=S(e),h=S(t);if(c.length!==h.length)return!1;for(c.sort(),h.sort(),u=c.length-1;u>=0;u--)if(c[u]!==h[u])return!1;for(u=c.length-1;u>=0;u--)if(a=c[u],!w(e[a],t[a],r,n))return!1;return!0}(e,t,r,i))}return r?e===t:e==t}function _(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function k(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function A(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&v(i,r,"Missing expected exception"+n);var o="string"==typeof n,a=!e&&i&&!r;if((!e&&s.isError(i)&&o&&k(i,r)||a)&&v(i,r,"Got unwanted exception"+n),e&&i&&r&&!k(i,r)||!e&&i)throw i}l.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=function(e){return m(y(e.actual),128)+" "+e.operator+" "+m(y(e.expected),128)}(this),this.generatedMessage=!0);var t=e.stackStartFunction||v;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var r=new Error;if(r.stack){var n=r.stack,i=b(t),o=n.indexOf("\n"+i);if(o>=0){var a=n.indexOf("\n",o+1);n=n.substring(a+1)}this.stack=n}}},s.inherits(l.AssertionError,Error),l.fail=v,l.ok=g,l.equal=function(e,t,r){e!=t&&v(e,t,r,"==",l.equal)},l.notEqual=function(e,t,r){e==t&&v(e,t,r,"!=",l.notEqual)},l.deepEqual=function(e,t,r){w(e,t,!1)||v(e,t,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(e,t,r){w(e,t,!0)||v(e,t,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(e,t,r){w(e,t,!1)&&v(e,t,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function e(t,r,n){w(t,r,!0)&&v(t,r,n,"notDeepStrictEqual",e)},l.strictEqual=function(e,t,r){e!==t&&v(e,t,r,"===",l.strictEqual)},l.notStrictEqual=function(e,t,r){e===t&&v(e,t,r,"!==",l.notStrictEqual)},l.throws=function(e,t,r){A(!0,e,t,r)},l.doesNotThrow=function(e,t,r){A(!1,e,t,r)},l.ifError=function(e){if(e)throw e},l.strict=i((function e(t,r){t||v(t,!0,r,"==",e)}),l,{equal:l.strictEqual,deepEqual:l.deepStrictEqual,notEqual:l.notStrictEqual,notDeepEqual:l.notDeepStrictEqual}),l.strict.strict=l.strict;var S=Object.keys||function(e){var t=[];for(var r in e)u.call(e,r)&&t.push(r);return t}}).call(this,r(8))},function(e,t,r){"use strict";(function(t){var n=r(0)(r(1)),i=r(91),o=r(60);function a(e){var t=e;if("string"!=typeof t)throw new Error("[ethjs-util] while padding to even, value must be string, is currently "+(0,n.default)(t)+", while padToEven.");return t.length%2&&(t="0"+t),t}function s(e){return"0x"+e.toString(16)}e.exports={arrayContainsArray:function(e,t,r){if(!0!==Array.isArray(e))throw new Error("[ethjs-util] method arrayContainsArray requirLine truncated
//# sourceMappingURL=web3.min.js.map
+11 -10
View File
@@ -8,8 +8,9 @@
<link rel="stylesheet" href="font-awasome.css" type="text/css" />
<link rel="shortcut icon" type="image/png/ico" href="Images/favicon.ico" />
<script type="text/javascript" src="WebServer/require.js"></script>
<script type="text/javascript" src="WebServer/AppPreLoader.js"></script>
<script type="text/javascript" src="AppPreLoader.js"></script>
<script src="externalScripts/CCapture.all.min.js"></script>
<script src="externalScripts/web3.min.js"></script>
<!-- Documentation Style Sheets -->
<!-- -->
@@ -49,12 +50,12 @@
style="overflow:hidden; background: url(Images/superalgos-platform.jpg); background-size: cover;"
onresize="onResize()">
<div id="contributors" class="credits">
<p>Superalgos is <span class="red">open-source</span> and <span class="red">free</span> thanks to the generosity of contributors:</p>
<p>Superalgos is <span class="red">free</span> and <span class="red">open-source</span>, and is <span class="red">constantly improving</span> thanks to the involvement of contributors:</p>
<p>Luis Fernando Molina, Julian Molina, Andreja Cobeljic, Matías Benitez, Ira Miller, Eduardo Remis,
Jeff Braun, rico4dev, Barry Low, Nikola Bjelogrlic, Hirajin Koizuko, Francisco J. Santillán, Viktoria B.,
Javier A., Gustavo J., Romina, Pedro P., Thais M., Loui M., Natalia M., Bashar A., Carlos V., Diego M.,
Sebastian E., Bogdan P., Marko V., Igor S., Niksa K., Rodrigo M. and Nicanor M.</p>
<p><span class="red">Help us keep Superalgos free for all. Become a contributor!</span></p>
Jeff Braun, rico4dev, 9808us, Barry Low, Nikola Bjelogrlic, Hirajin Koizuko, Francisco J. Santillán, Viktoria B., Guillermo V., Daniel J.,
Javier A., Gustavo J., Romina GS, Pedro P., Thais M., Andrey M., Loui M., Natalia M., Bashar A., Carlos V., Diego M.,
Sebastian E., Bogdan P., Marko V., Igor S., Niksa K., Rodrigo M., Nicanor M., Alejandro P., Mateo H., Lan T., Leon A., Uroš R., Filip M., Vladimir J. and Pavle B.</p>
<p><span class="red">You too can help grow and improve Superalgos. Become a contributor!</span></p>
</div>
<div id="masterApp"></div>
<div id="canvasApp"></div>
@@ -74,19 +75,19 @@
<table class="tutorial-buttonsTable">
<tr>
<td align="center">
<label class="tutorial-font-small tutorial-stop-button" onclick="canvas.tutorialSpace.stop()"
<label class="tutorial-font-small tutorial-stop-button" onclick="UI.projects.superalgos.spaces.tutorialSpace.stop()"
value="">&nbsp;&nbsp;Stop&nbsp;&nbsp;&nbsp;</label>
</td>
<td align="center">
<label class="tutorial-font-small tutorial-skip-button" onclick="canvas.tutorialSpace.skip()"
<label class="tutorial-font-small tutorial-skip-button" onclick="UI.projects.superalgos.spaces.tutorialSpace.skip()"
value="">&nbsp;&nbsp;Skip&nbsp;&nbsp;&nbsp;</label>
</td>
<td align="center">
<label class="tutorial-font-small tutorial-previous-button"
onclick="canvas.tutorialSpace.previous()" value="">Previous</label>
onclick="UI.projects.superalgos.spaces.tutorialSpace.previous()" value="">Previous</label>
</td>
<td align="center">
<label class="tutorial-font-small tutorial-next-button" onclick="canvas.tutorialSpace.next()"
<label class="tutorial-font-small tutorial-next-button" onclick="UI.projects.superalgos.spaces.tutorialSpace.next()"
value="">&nbsp;&nbsp;Next&nbsp;&nbsp;&nbsp;</label>
</td>
</tr>
+3 -1
View File
@@ -65,7 +65,9 @@ try {
WEB_SERVER.initialize()
WEB_SERVER.run()
console.log("You are running Superalgos Beta 6 SP2.")
console.log("You are running Superalgos Beta 6 SP4: What's new? Some bugs fixed and improved performance.")
//console.log("You are running Superalgos Beta 7: What's new? Multi-Project & Machine Learning Infrastructure is being implemented here.")
} catch (err) {
console.log('[ERROR] BackendServers -> Task Manager -> server -> Error = ' + err.stack)
+253 -126
View File
@@ -17,7 +17,7 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
let http = require('http')
let isHttpServerStarted = false
let webhook = new Map()
return thisObject
@@ -301,6 +301,27 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
}
break
case 'Icons': // This means the Icons folder under Projects.
{
let path = process.env.PROJECTS_PATH + '/' + requestParameters[2] + '/Icons'
if (requestParameters[3] !== undefined) {
path = path + '/' + requestParameters[3]
}
if (requestParameters[4] !== undefined) {
path = path + '/' + requestParameters[4]
}
if (requestParameters[5] !== undefined) {
path = path + '/' + requestParameters[5]
}
path = unescape(path)
respondWithImage(path, response)
}
break
case 'favicon.ico': // This means the Scripts folder.
{
respondWithImage(process.env.PATH_TO_WEB_SERVER + 'WebServer/Images/' + 'favicon.ico', response)
@@ -349,12 +370,6 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
}
break
case 'Utilities': // This means the DesignSpace folder.
{
respondWithFile(process.env.PATH_TO_CANVAS_APP + '/Utilities/' + requestParameters[2], response)
}
break
case 'WebServer': // This means the WebServer folder.
{
respondWithFile(process.env.PATH_TO_WEB_SERVER + 'WebServer/' + requestParameters[2], response)
@@ -387,12 +402,6 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
}
break
case 'Panels':
{
respondWithFile(process.env.PATH_TO_CANVAS_APP + '/' + requestParameters[1] + '/' + requestParameters[2], response)
}
break
case 'ChartLayers':
{
respondWithFile(process.env.PATH_TO_CANVAS_APP + '/' + requestParameters[1] + '/' + requestParameters[2], response)
@@ -423,65 +432,55 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
}
break
case 'FloatingSpace':
case 'ProjectNames':
{
respondWithFile(process.env.PATH_TO_CANVAS_APP + '/' + requestParameters[1] + '/' + requestParameters[2], response)
let projects = getDirectories(process.env.PROJECTS_PATH)
respondWithContent(JSON.stringify(projects), response)
}
break
case 'ChartingSpace':
case 'Schema':
{
respondWithFile(process.env.PATH_TO_CANVAS_APP + '/' + requestParameters[1] + '/' + requestParameters[2], response)
sendSchema(process.env.PROJECTS_PATH + '/' + requestParameters[2] + '/Schemas/', requestParameters[3] + '.json')
}
break
case 'SideSpace':
case 'IconNames':
{
respondWithFile(process.env.PATH_TO_CANVAS_APP + '/' + requestParameters[1] + '/' + requestParameters[2], response)
}
break
case 'ImagesNames':
{
const folder = process.env.PATH_TO_WEB_SERVER + 'WebServer/Images/Icons/style-01/'
let projects = getDirectories(process.env.PROJECTS_PATH)
const fs = require('fs')
fs.readdir(folder, (err, files) => {
respondWithContent(JSON.stringify(files), response)
})
let icons = []
let totalProjects = projects.length
let projectCounter = 0
for (let i = 0; i < projects.length; i++) {
let project = projects[i]
const folder = process.env.PROJECTS_PATH + '/' + project + '/Icons/'
fs.readdir(folder, (err, files) => {
for (let j = 0; j < files.length; j++) {
let file = files[j]
icons.push([project, file])
}
projectCounter++
if (projectCounter === totalProjects) {
respondWithContent(JSON.stringify(icons), response)
}
})
}
}
break
case 'PluginFileNames':
{
let project = unescape(requestParameters[2])
let pluginType = unescape(requestParameters[3])
const fs = require('fs')
let folder
switch (requestParameters[2]) {
case 'Data-Mines': {
folder = process.env.DATA_MINES_PATH + '/'
break
}
case 'Trading-Mines': {
folder = process.env.TRADING_MINES_PATH + '/'
break
}
case 'Trading-Systems': {
folder = process.env.TRADING_SYSTEMS_PATH + '/'
break
}
case 'Trading-Engines': {
folder = process.env.TRADING_ENGINES_PATH + '/'
break
}
case 'Super-Scripts': {
folder = process.env.SUPER_SCRIPTS_PATH + '/'
break
}
case 'Tutorials': {
folder = process.env.TUTORIALS_PATH + '/'
break
}
}
let folder = process.env.PROJECTS_PATH + '/' + project + '/Plugins/' + pluginType
fs.readdir(folder, (err, files) => {
respondWithContent(JSON.stringify(files), response)
@@ -489,21 +488,14 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
}
break
case 'AppSchema.js':
{
sendSchema(process.env.APP_SCHEMA_PATH, 'AppSchema', 'getAppSchema')
}
break
case 'DocSchema.js':
case 'LoadPlugin':
{
sendSchema(process.env.DOC_SCHEMA_PATH, 'DocSchema', 'getDocSchema')
}
break
case 'ConceptSchema.js':
{
sendSchema(process.env.CONCEPT_SCHEMA_PATH, 'ConceptSchema', 'getConceptSchema')
let project = unescape(requestParameters[2])
let pluginType = unescape(requestParameters[3])
let fileName = unescape(requestParameters[4])
let filePath = process.env.PROJECTS_PATH + '/' + project + '/Plugins/' + pluginType + '/' + fileName
respondWithFile(filePath, response)
}
break
@@ -532,33 +524,42 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
case 'ListWorkspaces':
{
let allWorkspaces = []
readPluginWorkspaces()
function readPluginWorkspaces() {
let dirPath = process.env.WORKSPACES_PATH
try {
let fs = require('fs')
fs.readdir(dirPath, onDirRead)
let projects = getDirectories(process.env.PROJECTS_PATH)
let projectsCount = 0
function onDirRead(err, fileList) {
if (err) {
if (CONSOLE_LOG === true) { console.log('[ERROR] Error reading a directory content. filePath = ' + dirPath) }
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), response)
return
} else {
let updatedFileList = []
for (let i = 0; i < fileList.length; i++) {
let name = 'Plugin \u2192 ' + fileList[i]
updatedFileList.push(name)
for (let i = 0; i < projects.length; i++) {
let project = projects[i]
readPluginWorkspaces()
function readPluginWorkspaces() {
let dirPath = process.env.PROJECTS_PATH + '/' + project + '/Plugins/Workspaces'
try {
let fs = require('fs')
fs.readdir(dirPath, onDirRead)
function onDirRead(err, fileList) {
if (err) {
if (CONSOLE_ERROR_LOG === true) { console.log('[ERROR] Error reading a directory content. filePath = ' + dirPath) }
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), response)
return
} else {
let updatedFileList = []
for (let i = 0; i < fileList.length; i++) {
let name = 'Plugin \u2192 ' + fileList[i]
updatedFileList.push([project, name])
}
allWorkspaces = allWorkspaces.concat(updatedFileList)
projectsCount++
if (projectsCount === projects.length) {
readMyWorkspaces()
}
return
}
allWorkspaces = allWorkspaces.concat(updatedFileList)
readMyWorkspaces()
return
}
} catch (err) {
if (CONSOLE_ERROR_LOG === true) { console.log('[ERROR] Error reading a directory content. filePath = ' + dirPath) }
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), response)
return
}
} catch (err) {
if (CONSOLE_LOG === true) { console.log('[ERROR] Error reading a directory content. filePath = ' + dirPath) }
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), response)
return
}
}
@@ -570,17 +571,22 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
function onDirRead(err, fileList) {
if (err) {
if (CONSOLE_LOG === true) { console.log('[ERROR] Error reading a directory content. filePath = ' + dirPath) }
if (CONSOLE_ERROR_LOG === true) { console.log('[ERROR] Error reading a directory content. filePath = ' + dirPath) }
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), response)
return
} else {
allWorkspaces = allWorkspaces.concat(fileList)
let updatedFileList = []
for (let i = 0; i < fileList.length; i++) {
let name = fileList[i]
updatedFileList.push(['', name])
}
allWorkspaces = allWorkspaces.concat(updatedFileList)
respondWithContent(JSON.stringify(allWorkspaces), response)
return
}
}
} catch (err) {
if (CONSOLE_LOG === true) { console.log('[ERROR] Error reading a directory content. filePath = ' + dirPath) }
if (CONSOLE_ERROR_LOG === true) { console.log('[ERROR] Error reading a directory content. filePath = ' + dirPath) }
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), response)
return
}
@@ -588,7 +594,7 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
}
break
case 'LoadWorkspace':
case 'LoadMyWorkspace':
{
let fileName = unescape(requestParameters[2])
let filePath = process.env.MY_WORKSPACES_PATH + '/' + fileName + '.json'
@@ -596,14 +602,6 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
}
break
case 'LoadPluginWorkspace':
{
let fileName = unescape(requestParameters[2])
let filePath = process.env.WORKSPACES_PATH + '/' + fileName + '.json'
respondWithFile(filePath, response)
}
break
case 'SaveWorkspace':
{
getBody(processRequest)
@@ -627,7 +625,7 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
function onFileWritten(err) {
if (err) {
if (CONSOLE_LOG === true) { console.log('[ERROR] Error writting the Workspace file. fileName = ' + fileName) }
if (CONSOLE_ERROR_LOG === true) { console.log('[ERROR] Error writting the Workspace file. fileName = ' + fileName) }
respondWithContent(JSON.stringify(exchanges), response)
} else {
respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), response)
@@ -635,46 +633,109 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
}
} catch (err) {
if (CONSOLE_LOG === true) { console.log('[ERROR] Error writting the Workspace file. fileName = ' + fileName) }
if (CONSOLE_ERROR_LOG === true) { console.log('[ERROR] Error writting the Workspace file. fileName = ' + fileName) }
respondWithContent(JSON.stringify(exchanges), response)
}
}
}
break
case 'Data-Mines':
case 'ListFunctionLibraries':
{
respondWithFile(process.env.DATA_MINES_PATH + '/' + requestParameters[2], response)
returnProjectFolderFileList('Function-Libraries')
}
break
case 'Trading-Mines':
case 'ProjectsSchema':
{
respondWithFile(process.env.TRADING_MINES_PATH + '/' + requestParameters[2], response)
let path = process.env.PROJECTS_PATH + '/' + 'ProjectsSchema.json'
respondWithFile(path, response)
}
break
case 'Trading-Systems':
case 'ListSpaceFiles':
{
respondWithFile(process.env.TRADING_SYSTEMS_PATH + '/' + requestParameters[2], response)
let fs = require('fs')
let allFiles = []
let projects = getDirectories(process.env.PROJECTS_PATH)
let dirCount = 0
let totalDirs = 0
for (let i = 0; i < projects.length; i++) {
let project = projects[i]
let dirPath = project + '/Spaces'
let spaces = getDirectories(process.env.PROJECTS_PATH + '/' + dirPath)
for (let j = 0; j < spaces.length; j++) {
let space = spaces[j]
readDirectory(dirPath + '/' + space)
}
function readDirectory(path) {
try {
totalDirs++
fs.readdir(process.env.PROJECTS_PATH + '/' + path, onDirRead)
let otherDirs = getDirectories(process.env.PROJECTS_PATH + '/' + path)
for (let m = 0; m < otherDirs.length; m++) {
let otherDir = otherDirs[m]
readDirectory(path + '/' + otherDir)
}
function onDirRead(err, fileList) {
if (err) {
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), response)
} else {
let updatedFileList = []
for (let k = 0; k < fileList.length; k++) {
let name = fileList[k]
if (name.indexOf('.js') < 0) { continue }
updatedFileList.push(path + '/' + name)
}
allFiles = allFiles.concat(updatedFileList)
dirCount++
if (dirCount === totalDirs) {
respondWithContent(JSON.stringify(allFiles), response)
}
}
}
} catch (err) {
console.log('[ERROR] Error reading a directory content. filePath = ' + path)
console.log(err.stack)
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), response)
return
}
}
}
}
break
case 'Super-Scripts':
case 'ListUtilitiesFiles':
{
respondWithFile(process.env.SUPER_SCRIPTS_PATH + '/' + requestParameters[2], response)
returnProjectFolderFileList('Utilities')
}
break
case 'Trading-Engines':
case 'ListGlobalFiles':
{
respondWithFile(process.env.TRADING_ENGINES_PATH + '/' + requestParameters[2], response)
returnProjectFolderFileList('Globals')
}
break
case 'Tutorials':
case 'Projects':
{
respondWithFile(process.env.TUTORIALS_PATH + '/' + requestParameters[2], response)
let path = ''
for (let i = 2; i < 10; i++) {
if (requestParameters[i] !== undefined) {
let parameter = unescape(requestParameters[i])
path = path + '/' + parameter
}
}
let filePath = process.env.PROJECTS_PATH + path
respondWithFile(filePath, response)
}
break
@@ -695,18 +756,80 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
sendStyleSheet('font-awasome.css')
}
break
case 'ExecuteTerminalCommand':
{
let command = unescape(requestParameters[2])
executeTerminalCommand(command)
}
break
default:
{
homePage()
}
}
function sendSchema(filePath, fileName, functionName) {
function returnProjectFolderFileList(projectFolderName) {
{
let allLibraries = []
let projects = getDirectories(process.env.PROJECTS_PATH)
let projectsCount = 0
for (let i = 0; i < projects.length; i++) {
let project = projects[i]
let dirPath = process.env.PROJECTS_PATH + '/' + project + '/' + projectFolderName
try {
let fs = require('fs')
fs.readdir(dirPath, onDirRead)
function onDirRead(err, fileList) {
if (err) {
if (CONSOLE_ERROR_LOG === true) { console.log('[ERROR] Error reading a directory content. filePath = ' + dirPath) }
if (CONSOLE_ERROR_LOG === true) { console.log(err.stack) }
return
} else {
let updatedFileList = []
for (let i = 0; i < fileList.length; i++) {
let name = fileList[i]
updatedFileList.push([project, name])
}
allLibraries = allLibraries.concat(updatedFileList)
projectsCount++
if (projectsCount === projects.length) {
respondWithContent(JSON.stringify(allLibraries), response)
}
return
}
}
} catch (err) {
if (CONSOLE_ERROR_LOG === true) { console.log('[ERROR] Error reading a directory content. filePath = ' + dirPath) }
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), response)
return
}
}
}
}
function executeTerminalCommand(command) {
const util = require('util');
const exec = util.promisify(require('child_process').exec);
async function lsWithGrep() {
try {
const { stdout, stderr } = await exec(command);
console.log('stdout:', stdout);
console.log('stderr:', stderr);
} catch (err) {
console.error(err.stack);
};
};
lsWithGrep();
}
function sendSchema(filePath, fileName) {
let fs = require('fs')
try {
filePath = filePath + fileName + '.json'
filePath = filePath + fileName
fs.readFile(filePath, onFileRead)
} catch (e) {
console.log('[ERROR] Error reading the ' + fileName, e)
@@ -716,8 +839,7 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
if (err) {
respondWithContent(undefined, response)
} else {
let responseContent = 'function ' + functionName + '(){ return ' + schema + '}'
respondWithContent(responseContent, response)
respondWithContent(schema, response)
}
}
}
@@ -773,7 +895,6 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
function respondWithFile(fileName, response) {
if (CONSOLE_LOG === true) { console.log('[INFO] webServer -> respondWithFile -> Entering function.') }
let fs = require('fs')
if (fileName.indexOf('undefined') > 0) {
console.log('[WRN] webServer -> respondWithFile -> Received request for undefined file. ')
@@ -889,8 +1010,7 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
function returnEmptyArray(response) {
try {
if (CONSOLE_LOG === true) { console.log('[INFO] webServer -> respondWithFile -> returnEmptyArray -> Entering function.') }
if (CONSOLE_LOG === true) { console.log('[INFO] webServer -> returnEmptyArray -> Entering function.') }
response.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate') // HTTP 1.1.
response.setHeader('Pragma', 'no-cache') // HTTP 1.0.
response.setHeader('Expires', '0') // Proxies.
@@ -899,7 +1019,14 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
response.write('[]')
response.end('\n')
} catch (err) {
console.log('[ERROR] webServer -> returnEmptyArray -> err.message ' + err.message)
console.log('[ERROR] webServer -> returnEmptyArray -> err.stack ' + err.stack)
}
}
function getDirectories(path) {
const fs = require('fs')
return fs.readdirSync(path).filter(function (file) {
return fs.statSync(path + '/' + file).isDirectory();
});
}
}
+9 -9
View File
@@ -116,23 +116,23 @@ function newAnimation() {
for (const [key, timeConsumed] of performanceMap.entries()) {
row++
let labelToPrint = key + ' ' + timeConsumed.toFixed(4)
printLabel(labelToPrint, 10, 100 + row * 30, 1, 20, UI_COLOR.RED)
UI.projects.superalgos.utilities.drawPrint.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)
UI.projects.superalgos.utilities.drawPrint.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)
UI.projects.superalgos.utilities.drawPrint.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)
UI.projects.superalgos.utilities.drawPrint.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)
UI.projects.superalgos.utilities.drawPrint.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)
UI.projects.superalgos.utilities.drawPrint.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)
UI.projects.superalgos.utilities.drawPrint.printLabel('Animation Frame Per Seconds: ' + ANIMATION_FRAME_PER_SECONDS, 300, 100 + row * 30, 1, 20, UI_COLOR.RED)
}
/* Video Recording */
@@ -144,7 +144,7 @@ function newAnimation() {
/* Panorama Recording */
if (ARE_WE_RECORDING_A_MARKET_PANORAMA === true) {
if (PANORAMA_WAS_PANNED === true) {
addToMarketPanorama()
UI.projects.superalgos.utilities.download.addToMarketPanorama()
PANORAMA_WAS_PANNED = false
}
}
@@ -167,7 +167,7 @@ function newAnimation() {
}
function clearBrowserCanvas() {
if (canWeDraw === false) { return }
if (CAN_SPACES_DRAW === false) { return }
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
browserCanvasContext.clearRect(0, 0, browserCanvas.width, browserCanvas.height)
}
+190
View File
@@ -0,0 +1,190 @@
let postLoader
function newAppLoader() {
const MODULE_NAME = 'App Loader'
const INFO_LOG = false
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
let thisObject = {
loadModules: loadModules
}
return thisObject
async function loadModules() {
try {
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> Entering function.') }
let plotters
let modulesArray = []
plotters = defaultPlotters()
modulesArray = modulesArray.concat([
'Globals.js',
'Workspace.js',
'Files/SingleFile.js',
'Files/FileCloud.js',
'Files/MarketFiles.js',
'Files/DailyFiles.js',
'Files/FileCursor.js',
'Files/FileSequence.js',
'Files/FileStorage.js',
'EventsServerClient.js',
'LegacyPlotter.js',
'PlotterPanel.js',
'VideoRecorder.js',
'ProductStorage.js',
'Canvas.js',
'EventHandler.js',
'Frame.js',
'Animation.js',
'Container.js',
'Utilities.js',
'AppPostLoader.js'
])
modulesArray = modulesArray.concat(plotters)
functionLibraries()
function functionLibraries() {
let url = 'ListFunctionLibraries'
callWebServer(undefined, url, onResponse)
function onResponse(err, fileList) {
let urlArray = []
let fileArray = JSON.parse(fileList)
for (let i = 0; i < fileArray.length; i++) {
let item = fileArray[i]
project = item[0]
fileName = item[1]
urlArray.push('Projects' + '/' + project + '/' + 'Function-Libraries' + '/' + fileName)
}
modulesArray = modulesArray.concat(urlArray)
utilities()
}
}
function utilities() {
let url = 'ListUtilitiesFiles'
callWebServer(undefined, url, onResponse)
function onResponse(err, fileList) {
let urlArray = []
let fileArray = JSON.parse(fileList)
for (let i = 0; i < fileArray.length; i++) {
let item = fileArray[i]
project = item[0]
fileName = item[1]
urlArray.push('Projects' + '/' + project + '/' + 'Utilities' + '/' + fileName)
}
modulesArray = modulesArray.concat(urlArray)
globals()
}
}
function globals() {
let url = 'ListGlobalFiles'
callWebServer(undefined, url, onResponse)
function onResponse(err, fileList) {
let urlArray = []
let fileArray = JSON.parse(fileList)
for (let i = 0; i < fileArray.length; i++) {
let item = fileArray[i]
project = item[0]
fileName = item[1]
urlArray.push('Projects' + '/' + project + '/' + 'Globals' + '/' + fileName)
}
modulesArray = modulesArray.concat(urlArray)
spaces()
}
}
function spaces() {
let url = 'ListSpaceFiles'
callWebServer(undefined, url, onResponse)
function onResponse(err, fileList) {
let urlArray = []
let fileArray = JSON.parse(fileList)
for (let i = 0; i < fileArray.length; i++) {
let path = fileArray[i]
urlArray.push('Projects' + '/' + path)
}
modulesArray = modulesArray.concat(urlArray)
downloadIncludedFiles()
}
}
function downloadIncludedFiles() {
let downloadedCounter = 0
for (let i = 0; i < modulesArray.length; i++) {
let path = modulesArray[i]
REQUIREJS([path], onRequired)
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> Module Requested.') }
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> path = ' + path) }
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> total requested = ' + (i + 1)) }
function onRequired(pModule) {
try {
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> Entering function.') }
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> Module Downloaded.') }
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> path = ' + path) }
downloadedCounter++
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> downloadedCounter = ' + downloadedCounter) }
if (downloadedCounter === modulesArray.length) {
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> Starting Advanced Algos Platform.') }
setTimeout(() => {
postLoader = newAppPostLoader()
postLoader.start()
}, 500)
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] loadModules -> onRequired -> err = ' + err.stack) }
}
}
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] loadModules -> err = ' + err.stack) }
}
}
function defaultPlotters() {
return [
'Plotters/Masters/Plotters-Candles-Volumes/Candles.js',
'Plotters/Masters/Plotters-Candles-Volumes/CandlePanel.js',
'Plotters/Masters/Plotters-Candles-Volumes/Volumes.js',
'Plotters/Masters/Plotters-Candles-Volumes/VolumePanel.js',
'Plotters/Masters/Plotters-Bollinger-Bands/BollingerBands.js',
'Plotters/Masters/Plotters-Bollinger-Bands/BollingerBandsPanel.js',
'Plotters/Masters/Plotters-Bollinger-Bands/PercentageBandwidth.js'
]
}
}
+147
View File
@@ -0,0 +1,147 @@
function newAppPostLoader() {
const MODULE_NAME = 'Post Loader'
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
let thisObject = {
start: start
}
return thisObject
function start() {
try {
/* Moving PROJECTS_ARRAY to the global variable */
PROJECTS_ARRAY = window.PROJECTS
window.PROJECTS = undefined
setBrowserEvents()
setupProjectsSchema()
function setupProjectsSchema() {
callWebServer(undefined, 'ProjectsSchema', onResponse)
function onResponse(err, file) {
PROJECTS_SCHEMA = JSON.parse(file)
setupSchemas()
}
}
function setupSchemas() {
let totalWebServerCalls = 0
let webServerResponses = 0
for (let i = 0; i < PROJECTS_ARRAY.length; i++) {
let project = PROJECTS_ARRAY[i]
let schemas = {
array: {
appSchema: [],
docSchema: [],
conceptSchema: []
},
map: {
appSchema: new Map(),
docSchema: new Map(),
conceptSchema: new Map()
}
}
SCHEMAS_BY_PROJECT.set(project, schemas)
totalWebServerCalls++
callWebServer(undefined, 'Schema/' + project + '/AppSchema', onResponseAppSchema)
function onResponseAppSchema(err, schema) {
try {
schemas.array.appSchema = JSON.parse(schema)
for (let j = 0; j < schemas.array.appSchema.length; j++) {
let nodeDefinition = schemas.array.appSchema[j]
let key = nodeDefinition.type
schemas.map.appSchema.set(key, nodeDefinition)
}
} catch (err) {
console.log(err.stack)
}
webServerResponses++
if (webServerResponses === totalWebServerCalls) { startCanvas() }
}
totalWebServerCalls++
callWebServer(undefined, 'Schema/' + project + '/DocSchema', onResponseDocSchema)
function onResponseDocSchema(err, schema) {
try {
schemas.array.docSchema = JSON.parse(schema)
for (let j = 0; j < schemas.array.docSchema.length; j++) {
let nodeDefinition = schemas.array.docSchema[j]
let key = nodeDefinition.type
schemas.map.docSchema.set(key, nodeDefinition)
}
} catch (err) {
console.log(err.stack)
}
webServerResponses++
if (webServerResponses === totalWebServerCalls) { startCanvas() }
}
totalWebServerCalls++
callWebServer(undefined, 'Schema/' + project + '/ConceptSchema', onResponseConceptSchema)
function onResponseConceptSchema(err, schema) {
try {
schemas.array.conceptSchema = JSON.parse(schema)
for (let j = 0; j < schemas.array.conceptSchema.length; j++) {
let nodeDefinition = schemas.array.conceptSchema[j]
let key = nodeDefinition.type
schemas.map.conceptSchema.set(key, nodeDefinition)
}
} catch (err) {
console.log(err.stack)
}
webServerResponses++
if (webServerResponses === totalWebServerCalls) { startCanvas() }
}
}
}
function startCanvas() {
/* If this method is executed for a second time, it should finalize the current execution structure */
if (canvas !== undefined) { canvas.finalize() }
canvas = newCanvas()
canvas.initialize()
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] start -> err = ' + err.stack) }
}
}
function setBrowserEvents() {
window.onbeforeunload = saveWorkspace
/* handles backspace and refresh(F5) from keyboard */
window.manageBackRefresh = function (event) {
var tag = event.target.tagName.toLowerCase()
if (event.keyCode === 8 && tag !== 'input' && tag !== 'textarea') { // Backbutton pressed
saveWorkspace()
} else if (event.keyCode === 116) { // F5 pressed
saveWorkspace()
}
}
window.addEventListener('keydown', window.manageBackRefresh)
function saveWorkspace() {
UI.projects.superalgos.spaces.designSpace.workspace.save()
}
}
}
@@ -103,13 +103,23 @@ function loadSuperalgos() {
function onRequired(pModule) {
if (INFO_LOG === true) { console.log(spacePad(MODULE_NAME, 50) + " : " + "[INFO] " + path + " downloaded."); }
loadModules();
setUpProjects();
}
}
function setUpProjects() {
let url = 'ProjectNames'
callWebServer(undefined, url, onResponse)
function onResponse(err, projects) {
window.PROJECTS = JSON.parse(projects)
loadModules()
}
}
/* And Finally, we start loading all the scripts we will inmediatelly need. */
function loadModules() {
let path = "WebServer/AppLoader.js";
let path = "AppLoader.js";
REQUIREJS([path], onRequired);
function onRequired(pModule) {
@@ -120,7 +130,7 @@ function loadSuperalgos() {
}
}
function callServer(pContentToSend, pPath, callBackFunction) {
function callWebServer(pContentToSend, pPath, callBackFunction) {
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
+292 -496
View File
File diff suppressed because it is too large. Load diff
@@ -1,460 +0,0 @@
function newCryptoEcosystemFunctions() {
thisObject = {
addMissingExchanges: addMissingExchanges,
addMissingAssets: addMissingAssets,
addMissingMarkets: addMissingMarkets,
installMarket: installMarket,
uninstallMarket: uninstallMarket
}
return thisObject
function addMissingExchanges(node, functionLibraryUiObjectsFromNodes) {
currentExchanges = new Map()
let parent = node.payload.parentNode
if (parent !== undefined) {
for (let i = 0; i < parent.cryptoExchanges.length; i++) {
let cryptoExchanges = parent.cryptoExchanges[i]
for (let j = 0; j < cryptoExchanges.exchanges.length; j++) {
let exchange = cryptoExchanges.exchanges[j]
let codeName = loadPropertyFromNodeConfig(exchange.payload, 'codeName')
currentExchanges.set(codeName, exchange)
}
}
}
let params = {
method: 'listExchanges',
has: {
fetchOHLCV: true,
fetchMarkets: true
}
}
callServer(JSON.stringify(params), 'CCXT', onResponse)
function onResponse(err, data) {
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
return
}
let exchanges = JSON.parse(data)
for (let i = 0; i < exchanges.length; i++) {
let exchange = exchanges[i]
let existingExchange = currentExchanges.get(exchange.id)
if (existingExchange === undefined) {
let newExchange = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Crypto Exchange')
newExchange.name = exchange.name
newExchange.config = '{ \n\"codeName\": \"' + exchange.id + '\"\n}'
newExchange.payload.floatingObject.collapseToggle()
newExchange.exchangeAssets.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
newExchange.exchangeMarkets.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
newExchange.exchangeAccounts.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
newExchange.exchangeAssets.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_050X
newExchange.exchangeMarkets.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
newExchange.exchangeAccounts.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_025X
newExchange.exchangeAssets.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
newExchange.exchangeMarkets.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
newExchange.exchangeAccounts.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
}
}
}
}
function addMissingAssets(node, functionLibraryUiObjectsFromNodes) {
if (node.payload.parentNode === undefined) { return }
let currentAssets = new Map()
for (let j = 0; j < node.assets.length; j++) {
let asset = node.assets[j]
let codeName = loadPropertyFromNodeConfig(asset.payload, 'codeName')
currentAssets.set(codeName, asset)
}
let exchangeId = loadPropertyFromNodeConfig(node.payload.parentNode.payload, 'codeName')
try {
let params = {
exchangeId: exchangeId,
method: 'fetchMarkets'
}
callServer(JSON.stringify(params), 'CCXT', onResponse)
function onResponse(err, data) {
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
return
}
let queryParams = loadPropertyFromNodeConfig(node.payload, 'addMissingAssetsFilter')
let markets = JSON.parse(data)
for (let i = 0; i < markets.length; i++) {
let market = markets[i]
if (queryParams !== undefined) {
if (queryParams.baseAsset !== undefined) {
if (market.base.indexOf(queryParams.baseAsset) < 0) {
continue
}
}
if (queryParams.quotedAsset !== undefined) {
if (market.quote.indexOf(queryParams.quotedAsset) < 0) {
continue
}
}
}
if (currentAssets.get(market.base) === undefined) {
addAsset(market.base)
currentAssets.set(market.base, market.base)
}
if (currentAssets.get(market.quote) === undefined) {
addAsset(market.quote)
currentAssets.set(market.quote, market.quote)
}
function addAsset(name) {
let newAsseet = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Asset')
newAsseet.name = name
newAsseet.config = '{ \n\"codeName\": \"' + name + '\"\n}'
}
}
}
} catch (err) {
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
console.log(err.stack)
}
}
function addMissingMarkets(node, functionLibraryUiObjectsFromNodes, functionLibraryNodeCloning) {
if (node.payload.parentNode === undefined) { return }
if (node.payload.parentNode.exchangeAssets === undefined) { return }
if (node.payload.parentNode.payload.parentNode === undefined) { return }
if (node.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { return }
let currentAssets = new Map()
let exchangeAssets = node.payload.parentNode.exchangeAssets
for (let j = 0; j < exchangeAssets.assets.length; j++) {
let asset = exchangeAssets.assets[j]
let codeName = loadPropertyFromNodeConfig(asset.payload, 'codeName')
currentAssets.set(codeName, asset)
}
let currentMarkets = new Map()
let exchangeMarkets = node
for (let j = 0; j < exchangeMarkets.markets.length; j++) {
let asset = exchangeMarkets.markets[j]
let codeName = loadPropertyFromNodeConfig(asset.payload, 'codeName')
currentMarkets.set(codeName, asset)
}
let exchangeId = loadPropertyFromNodeConfig(node.payload.parentNode.payload, 'codeName')
try {
let params = {
exchangeId: exchangeId,
method: 'fetchMarkets'
}
callServer(JSON.stringify(params), 'CCXT', onResponse)
function onResponse(err, data) {
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
return
}
let markets = JSON.parse(data)
for (let i = 0; i < markets.length; i++) {
let market = markets[i]
let baseAsset = currentAssets.get(market.base)
let quotedAsset = currentAssets.get(market.quote)
if (baseAsset === undefined) {
continue
}
if (quotedAsset === undefined) {
continue
}
if (currentMarkets.get(market.symbol) === undefined) {
addMarket(market.symbol, baseAsset, quotedAsset)
}
function addMarket(name, baseAsset, quotedAsset) {
let newMarket = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Market')
newMarket.name = name
newMarket.config = '{ \n\"codeName\": \"' + name + '\"\n}'
newMarket.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
newMarket.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
newMarket.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
newMarket.baseAsset.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_45
newMarket.quotedAsset.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_45
newMarket.baseAsset.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
newMarket.quotedAsset.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
newMarket.baseAsset.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
newMarket.quotedAsset.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
newMarket.baseAsset.payload.referenceParent = baseAsset
newMarket.quotedAsset.payload.referenceParent = quotedAsset
currentMarkets.set(name, newMarket)
}
}
}
} catch (err) {
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
console.log(err.stack)
}
}
function installMarket(node, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter, functionLibraryChartingSpaceFunctions, functionLibraryDataStorageFunctions) {
let market = node
let cryptoExchange = findNodeInNodeMesh(node, 'Crypto Exchange', undefined, true, false, true, false)
if (cryptoExchange === undefined) {
node.payload.uiObject.setErrorMessage('Market must be a descendant of a Crypto Exchange')
return
}
let dashboardsArray = []
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === 'Network') {
installInNetwork(rootNode)
}
}
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === 'Charting Space') {
installInChartingSpace(rootNode)
}
}
function installInNetwork(network) {
for (let j = 0; j < network.networkNodes.length; j++) {
let networkNode = network.networkNodes[j]
installInNetworkNode(networkNode)
}
function installInNetworkNode(networkNode) {
/*
Here we complete the missing stuff at Data Mining
*/
let dataMining = findInBranch(networkNode, 'Data Mining', node, true)
if (dataMining === undefined) {
node.payload.uiObject.setErrorMessage('Data Mining node not found at Network Node ' + networkNode.name)
return
}
let exchangeDataTasks = findOrCreateChildWithReference(dataMining, 'Exchange Data Tasks', cryptoExchange, functionLibraryUiObjectsFromNodes)
exchangeDataTasks.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
let marketDataTask = findAndRecreateChildWithReference(exchangeDataTasks, 'Market Data Tasks', market, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
menuClick(marketDataTask, 'Add Missing Data Mine Tasks', true)
menuClickOfNodeArray(marketDataTask.dataMineTasks, 'Add All Tasks', true)
let sessionsCreatedArray = []
/*
Next we complete the missing stuff at Testing Environment
*/
installEnvironment('Testing Environment')
/*
Next we complete the missing stuff at Production Environment
*/
installEnvironment('Production Environment')
function installEnvironment(environment) {
/*
Now we install the environmnet at the current Network Node
*/
let environmentFound = findInBranch(networkNode, environment, node, true)
if (environmentFound === undefined) {
node.payload.uiObject.setErrorMessage(environment + ' node not found at Network Node ' + networkNode.name)
return
}
let exchangeTradingTasks = findOrCreateChildWithReference(environmentFound, 'Exchange Trading Tasks', cryptoExchange, functionLibraryUiObjectsFromNodes)
exchangeTradingTasks.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
let marketTradingTask = findAndRecreateChildWithReference(exchangeTradingTasks, 'Market Trading Tasks', market, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
menuClick(marketTradingTask, 'Add Missing Trading Mine Tasks', true)
menuClickOfNodeArray(marketTradingTask.tradingMineTasks, 'Add All Tasks', true)
/* This will be needed at the charging space, for creating Dashboards */
let backtestingSessionsArray = nodeBranchToArray(marketTradingTask, 'Backtesting Session')
let liveTradingSessionsArray = nodeBranchToArray(marketTradingTask, 'Live Trading Session')
let allSessionsArray = backtestingSessionsArray.concat(liveTradingSessionsArray)
sessionsCreatedArray = sessionsCreatedArray.concat(allSessionsArray)
dashboardsArray.push({ environmentNode: environmentFound, networkNode: networkNode, sessionsArray: allSessionsArray })
}
/*
Here we complete the missing stuff at Data Mines Data
*/
let dataMinesData = findInBranch(networkNode, 'Data Mines Data', node, true)
if (dataMinesData === undefined) {
node.payload.uiObject.setErrorMessage('Data Mines Data node not found at Network Node ' + networkNode.name)
return
}
let exchangeDataProducts = findOrCreateChildWithReference(dataMinesData, 'Exchange Data Products', cryptoExchange, functionLibraryUiObjectsFromNodes)
exchangeDataProducts.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
let marketDataProducts = findAndRecreateChildWithReference(exchangeDataProducts, 'Market Data Products', market, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
marketDataProducts.payload.floatingObject.collapseToggle()
menuClick(marketDataProducts, 'Add All Data Mine Products', true)
menuClickOfNodeArray(marketDataProducts.dataMineProducts, 'Add All Data Products', true)
/*
Finally we complete the missing stuff at Trading Mines Data
*/
let tradingMinesData = findInBranch(networkNode, 'Trading Mines Data', node, true)
if (tradingMinesData === undefined) {
node.payload.uiObject.setErrorMessage('Trading Mines Data node not found at Network Node ' + networkNode.name)
return
}
let exchangeTradingProducts = findOrCreateChildWithReference(tradingMinesData, 'Exchange Trading Products', cryptoExchange, functionLibraryUiObjectsFromNodes)
exchangeTradingProducts.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
let marketTradingProducts = findAndRecreateChildWithReference(exchangeTradingProducts, 'Market Trading Products', market, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
marketTradingProducts.payload.floatingObject.collapseToggle()
/*
Create the new session references.
*/
for (let i = 0; i < sessionsCreatedArray.length; i++) {
let session = sessionsCreatedArray[i]
if (isMissingChildren(marketTradingProducts, session, true) === true) {
functionLibraryDataStorageFunctions.createSessionReference(marketTradingProducts, session, functionLibraryUiObjectsFromNodes)
}
}
/*
Create everything inside the session references.
*/
for (let j = 0; j < marketTradingProducts.sessionReferences.length; j++) {
let sessionReference = marketTradingProducts.sessionReferences[j]
menuClick(sessionReference, 'Add All Trading Mine Products', true)
menuClickOfNodeArray(sessionReference.tradingMineProducts, 'Add All Data Products', true)
sessionReference.payload.floatingObject.collapseToggle()
}
}
}
function installInChartingSpace(chartingSpace) {
for (let i = 0; i < dashboardsArray.length; i++) {
/*
If the Dashboard we need is not already there we create a new one.
*/
let arrayItem = dashboardsArray[i]
let dashboard = findOrCreateChildWithReference(chartingSpace, 'Dashboard', arrayItem.environmentNode, functionLibraryUiObjectsFromNodes)
dashboard.name = arrayItem.environmentNode.type + ' ' + arrayItem.networkNode.name
/*
We delete all the existing Time Machines related to the market we are currently installing.
For that, we make a new array with the existing Time Machines so that the deleting
of each node does not affect the proccessing of the whole set.
*/
let timeMachines = []
for (let i = 0; i < dashboard.timeMachines.length; i++) {
let timeMachine = dashboard.timeMachines[i]
timeMachines.push(timeMachine)
}
for (let i = 0; i < timeMachines.length; i++) {
let timeMachine = timeMachines[i]
let session = timeMachine.payload.referenceParent
if (session === undefined || session.cleaned === true) {
/*
This is what usually happens, that the intall process make these
time machines to lose their reference parent since the install
process deletes them.
*/
functionLibraryNodeDeleter.deleteUIObject(timeMachine, rootNodes)
continue
}
let marketTradingTasks = findNodeInNodeMesh(session, 'Market Trading Tasks', undefined, true, false, true, false)
if (marketTradingTasks === undefined) { continue }
if (marketTradingTasks.payload === undefined) { continue }
if (marketTradingTasks.payload.referenceParent === undefined) { continue }
if (marketTradingTasks.payload.referenceParent.id === market.id) {
functionLibraryNodeDeleter.deleteUIObject(timeMachine, rootNodes)
}
}
/*
We create a time machine for each session added during the previous processing.
*/
for (let j = 0; j < arrayItem.sessionsArray.length; j++) {
let session = arrayItem.sessionsArray[j]
functionLibraryChartingSpaceFunctions.createTimeMachine(dashboard, session, node, arrayItem.networkNode, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
}
}
}
}
function uninstallMarket(node, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter, functionLibraryChartingSpaceFunctions, functionLibraryDataStorageFunctions) {
let market = node
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === 'Charting Space') {
uninstallInChartingSpace(rootNode)
}
}
function uninstallInChartingSpace(chartingSpace) {
/* Delete all time machines which are referencing sessions inside the market being unistalled. */
let timeMachines = nodeBranchToArray(chartingSpace, 'Time Machine')
for (let i = 0; i < timeMachines.length; i++) {
let timeMachine = timeMachines[i]
let session = timeMachine.payload.referenceParent
if (session === undefined) { continue }
let marketTradingTasks = findNodeInNodeMesh(session, 'Market Trading Tasks', undefined, true, false, true, false)
if (marketTradingTasks === undefined) { continue }
if (marketTradingTasks.payload === undefined) { continue }
if (marketTradingTasks.payload.referenceParent === undefined) { continue }
if (marketTradingTasks.payload.referenceParent.id === market.id) {
functionLibraryNodeDeleter.deleteUIObject(timeMachine, rootNodes)
}
}
/* Delete all Dashboards that does not have time machines inside. */
let dashboardArray = nodeBranchToArray(chartingSpace, 'Dashboard')
for (let i = 0; i < dashboardArray.length; i++) {
let dashboard = dashboardArray[i]
if (dashboard.timeMachines.length === 0) {
functionLibraryNodeDeleter.deleteUIObject(dashboard, rootNodes)
}
}
/* Scan Networks for the market being unistalled to delete it. */
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === 'Network') {
uninstallInNetwork(rootNode)
}
}
}
function uninstallInNetwork(network) {
let marketDataTasksArray = nodeBranchToArray(network, 'Market Data Tasks')
let marketTradingTasksArray = nodeBranchToArray(network, 'Market Trading Tasks')
let marketDataProductsArray = nodeBranchToArray(network, 'Market Data Products')
let marketTradingProductsArray = nodeBranchToArray(network, 'Market Trading Products')
uninstalMarketArray(marketDataTasksArray)
uninstalMarketArray(marketTradingTasksArray)
uninstalMarketArray(marketDataProductsArray)
uninstalMarketArray(marketTradingProductsArray)
function uninstalMarketArray(marketArray) {
for (let i = 0; i < marketArray.length; i++) {
let marketReference = marketArray[i]
if (marketReference.payload === undefined) { continue }
if (marketReference.payload.referenceParent === undefined) { continue }
if (marketReference.payload.referenceParent.id === market.id) {
functionLibraryNodeDeleter.deleteUIObject(marketReference, rootNodes)
}
}
}
}
}
}
@@ -1,84 +0,0 @@
function newPluginsFunctions() {
thisObject = {
pluginMissingDataMines: pluginMissingDataMines,
pluginMissingTradingMines: pluginMissingTradingMines,
pluginMissingTradingSystems: pluginMissingTradingSystems,
pluginMissingTradingEngines: pluginMissingTradingEngines,
pluginMissingSuperScripts: pluginMissingSuperScripts,
pluginMissingTutorials: pluginMissingTutorials
}
return thisObject
function getPluginFileNames(pluginType, callBack) {
callServer(undefined, 'PluginFileNames/' + pluginType, onResponse)
function onResponse(err, data) {
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
console.log('Failed to Fetch Plugin ' + pluginType + ' from the Backend')
return
}
let pluginFileNames = JSON.parse(data)
callBack(pluginFileNames)
}
}
function addPluginFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes) {
for (let i = 0; i < fileNames.length; i++) {
let fileName = fileNames[i]
fileName = fileName.replace('.json', '')
if (isMissingChildrenByName(node, fileName) === true) {
let child = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Plugin File')
child.name = fileName
}
}
}
function pluginMissingDataMines(node, rootNodes, functionLibraryUiObjectsFromNodes) {
getPluginFileNames('Data-Mines', onNamesArrived)
function onNamesArrived(fileNames) {
addPluginFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
}
}
function pluginMissingTradingMines(node, rootNodes, functionLibraryUiObjectsFromNodes) {
getPluginFileNames('Trading-Mines', onNamesArrived)
function onNamesArrived(fileNames) {
addPluginFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
}
}
function pluginMissingTradingSystems(node, rootNodes, functionLibraryUiObjectsFromNodes) {
getPluginFileNames('Trading-Systems', onNamesArrived)
function onNamesArrived(fileNames) {
addPluginFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
}
}
function pluginMissingTradingEngines(node, rootNodes, functionLibraryUiObjectsFromNodes) {
getPluginFileNames('Trading-Engines', onNamesArrived)
function onNamesArrived(fileNames) {
addPluginFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
}
}
function pluginMissingSuperScripts(node, rootNodes, functionLibraryUiObjectsFromNodes) {
getPluginFileNames('Super-Scripts', onNamesArrived)
function onNamesArrived(fileNames) {
addPluginFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
}
}
function pluginMissingTutorials(node, rootNodes, functionLibraryUiObjectsFromNodes) {
getPluginFileNames('Tutorials', onNamesArrived)
function onNamesArrived(fileNames) {
addPluginFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
}
}
}
@@ -1,5 +0,0 @@
function newTutorialFunctions() {
thisObject = {
}
return thisObject
}
@@ -1,930 +0,0 @@
function newWorkspace() {
const MODULE_NAME = 'Workspace'
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
let thisObject = {
workspaceNode: undefined,
container: undefined,
enabled: false,
nodeChildren: undefined,
eventsServerClients: new Map(),
replaceWorkspaceByLoadingOne: replaceWorkspaceByLoadingOne,
save: saveWorkspace,
getHierarchyHeads: getHierarchyHeads,
getHierarchyHeadsById: getHierarchyHeadsById,
getHierarchyHeadsByType: getHierarchyHeadsByType,
getNodeThatIsOnFocus: getNodeThatIsOnFocus,
getNodeByShortcutKey: getNodeByShortcutKey,
getNodeById: getNodeById,
stopAllRunningTasks: stopAllRunningTasks,
onMenuItemClick: onMenuItemClick,
physics: physics,
draw: draw,
spawn: spawn,
chainDetachNode: chainDetachNode,
chainAttachNode: chainAttachNode,
referenceDetachNode: referenceDetachNode,
referenceAttachNode: referenceAttachNode,
initialize: initialize,
finalize: finalize
}
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
thisObject.container.isClickeable = false
thisObject.container.isDraggeable = false
thisObject.container.isWheelable = false
thisObject.container.detectMouseOver = false
thisObject.container.frame.radius = 0
thisObject.container.frame.position.x = 0
thisObject.container.frame.position.y = 0
thisObject.container.frame.width = 0
thisObject.container.frame.height = 0
spawnPosition = {
x: canvas.floatingSpace.container.frame.width / 2,
y: canvas.floatingSpace.container.frame.height / 2
}
thisObject.workspaceNode = {}
thisObject.workspaceNode.rootNodes = []
let functionLibraryReferenceAttachDetach = newReferenceAttachDetach()
let functionLibraryChainAttachDetach = newChainAttachDetach()
let functionLibraryNodeDeleter = newNodeDeleter()
let functionLibraryUiObjectsFromNodes = newUiObjectsFromNodes()
let functionLibraryProtocolNode = newProtocolNode()
let functionLibraryNodeCloning = newNodeCloning()
let functionLibraryTaskFunctions = newTaskFunctions()
let functionLibrarySessionFunctions = newSessionFunctions()
let functionLibraryShortcutKeys = newShortcutKeys()
let functionLibraryOnFocus = newOnFocus()
let functionLibrarySuperScripts = newSuperScriptsFunctions()
let functionLibraryCryptoEcosystemFunctions = newCryptoEcosystemFunctions()
let functionLibraryWebhookFunctions = newWebhookFunctions()
let functionLibraryDependenciesFilter = newDependenciesFilter()
let functionLibraryNodePath = newNodePath()
let functionLibraryDataMineFunctions = newDataMineFunctions()
let functionLibraryDataStorageFunctions = newDataStorageFunctions()
let functionLibraryChartingSpaceFunctions = newChartingSpaceFunctions()
let functionLibraryTutorialFunctions = newTutorialFunctions()
let functionLibraryPluginsFunctions = newPluginsFunctions()
thisObject.nodeChildren = newNodeChildren()
let savingWorkspaceIntervalId
let isInitialized = false
let workingAtTask = 0
let circularProgressBar = newBusyProgressBar()
circularProgressBar.fitFunction = canvas.floatingSpace.fitIntoVisibleArea
let loadedWorkspaceNode
let sessionTimestamp = (new Date()).valueOf()
window.localStorage.setItem('Session Timestamp', sessionTimestamp)
return thisObject
function finalize() {
thisObject.definition = undefined
thisObject.container.finalize()
thisObject.container = undefined
thisObject.workspaceNode = undefined
circularProgressBar.finalize()
circularProgressBar = undefined
}
function initialize() {
try {
let lastUsedWorkspace = window.localStorage.getItem('Last Used Workspace')
if (lastUsedWorkspace !== 'undefined' && lastUsedWorkspace !== null && lastUsedWorkspace !== undefined) {
let blobService = newFileStorage()
blobService.getFileFromHost('LoadWorkspace' + '/' + lastUsedWorkspace, onFileReceived, true)
function onFileReceived(err, text, response) {
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
canvas.cockpitSpace.setStatus('Could not load the last Workspace used, called "' + lastUsedWorkspace + '". Will switch to the default Workspace instead.', 500, canvas.cockpitSpace.statusTypes.WARNING)
thisObject.workspaceNode = getWorkspace() // This is the default workspace that comes with the system.
recreateWorkspace()
return
}
thisObject.workspaceNode = JSON.parse(text)
recreateWorkspace()
}
} else {
thisObject.workspaceNode = getWorkspace() // This is the default workspace that comes with the system.
recreateWorkspace()
}
function recreateWorkspace() {
functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode, finishInitialization)
}
function finishInitialization() {
setupEventsServerClients()
runTasksAndSessions()
thisObject.enabled = true
canvas.cockpitSpace.initializePosition()
canvas.splashScreen.initialize()
savingWorkspaceIntervalId = setInterval(saveWorkspace, 60000)
isInitialized = true
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) }
}
}
function runTasksAndSessions() {
functionLibraryUiObjectsFromNodes.syncronizeTasksFoundAtWorkspaceWithBackEnd(functionLibraryTaskFunctions)
functionLibraryUiObjectsFromNodes.syncronizeSessionsFoundAtWorkspaceWithBackEnd(functionLibrarySessionFunctions)
setTimeout(functionLibraryUiObjectsFromNodes.playTutorials, 1000)
}
function setupEventsServerClients() {
for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) {
let rootNode = thisObject.workspaceNode.rootNodes[i]
if (rootNode.type === 'Network') {
for (let j = 0; j < rootNode.networkNodes.length; j++) {
let networkNode = rootNode.networkNodes[j]
let eventsServerClient = newEventsServerClient(networkNode)
eventsServerClient.initialize()
thisObject.eventsServerClients.set(networkNode.id, eventsServerClient)
}
}
}
}
function chainDetachNode(node) {
functionLibraryChainAttachDetach.chainDetachNode(node, thisObject.workspaceNode.rootNodes)
}
function chainAttachNode(node, attachToNode) {
functionLibraryChainAttachDetach.chainAttachNode(node, attachToNode, thisObject.workspaceNode.rootNodes)
}
function referenceDetachNode(node) {
functionLibraryReferenceAttachDetach.referenceDetachNode(node)
}
function referenceAttachNode(node, attachToNode) {
functionLibraryReferenceAttachDetach.referenceAttachNode(node, attachToNode, thisObject.workspaceNode.rootNodes)
}
function saveWorkspace() {
let workspace = canvas.designSpace.workspace.workspaceNode
/* Validation if it is too early to save. */
if (isInitialized === false) { return }
/* Validation of 2 sessions opened at the same time. */
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)
return
}
/* Validation that there is something to save */
let textToSave = stringifyWorkspace()
if (textToSave === undefined) {
canvas.cockpitSpace.setStatus(
'Could not save the Workspace. Something is preventing the System to do it at this time.'
, 150, canvas.cockpitSpace.statusTypes.WARNING)
return
}
window.localStorage.setItem('Session Timestamp', sessionTimestamp)
/* Validation Workspace has a name */
if (workspace.name === undefined) {
canvas.cockpitSpace.setStatus(
'Could not save the Workspace. You need to specify a name for it.'
, 150, canvas.cockpitSpace.statusTypes.WARNING)
return
}
let url = 'SaveWorkspace/' + workspace.name
callServer(textToSave, url, onResponse)
return true
function onResponse(err) {
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
window.localStorage.setItem('Last Used Workspace', workspace.name)
window.localStorage.setItem('Session Timestamp', sessionTimestamp)
if (ARE_WE_RECORDING_A_MARKET_PANORAMA === false) {
canvas.cockpitSpace.setStatus(workspace.name + ' Saved.', 50, canvas.cockpitSpace.statusTypes.ALL_GOOD)
}
} else {
canvas.cockpitSpace.setStatus('Could not save the Workspace at the Backend. Please check the Backend Console for more information.', 150, canvas.cockpitSpace.statusTypes.WARNING)
}
}
}
function getNodeById(nodeId) {
return functionLibraryUiObjectsFromNodes.getNodeById(nodeId)
}
function physics() {
eventsServerClientsPhysics()
replacingWorkspacePhysics()
}
function eventsServerClientsPhysics() {
thisObject.eventsServerClients.forEach(applyPhysics)
function applyPhysics(eventServerClient) {
eventServerClient.physics()
}
}
function finalizeEventsServerClients() {
thisObject.eventsServerClients.forEach(finalize)
function finalize(eventServerClient) {
eventServerClient.finalize()
}
}
function replacingWorkspacePhysics() {
if (thisObject.enabled !== true) { return }
if (workingAtTask > 0) {
circularProgressBar.physics()
switch (workingAtTask) {
case 1:
canvas.tutorialSpace.stop()
functionLibraryNodeDeleter.deleteWorkspace(thisObject.workspaceNode, thisObject.workspaceNode.rootNodes)
workingAtTask++
break
case 2:
finalizeEventsServerClients()
thisObject.eventsServerClients = new Map()
workingAtTask++
break
case 3:
clearInterval(savingWorkspaceIntervalId)
workingAtTask++
break
case 4:
thisObject.workspaceNode = loadedWorkspaceNode
loadedWorkspaceNode = undefined
workingAtTask++
break
case 5:
functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode, finishInitialization)
function finishInitialization() {
setupEventsServerClients()
runTasksAndSessions()
}
workingAtTask++
break
case 6:
canvas.chartingSpace.reset()
workingAtTask++
break
case 7:
workingAtTask = 0
circularProgressBar.visible = false
break
}
}
}
function draw() {
if (circularProgressBar !== undefined) {
circularProgressBar.draw()
}
}
function stringifyWorkspace(removePersonalData) {
let stringifyReadyNodes = []
for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) {
let rootNode = thisObject.workspaceNode.rootNodes[i]
if (rootNode.isPlugin !== true) {
let node = functionLibraryProtocolNode.getProtocolNode(rootNode, removePersonalData, false, true, true, true)
stringifyReadyNodes.push(node)
}
}
let workspace = {
type: 'Workspace',
name: thisObject.workspaceNode.name,
rootNodes: stringifyReadyNodes
}
/*
Sometimes it happens that there are no rootNodes.
In those situations the workspace can not be stringified,
to prevent later saving it corrupting the original file.
*/
if (stringifyReadyNodes.length > 0) {
return JSON.stringify(workspace)
} else {
return
}
}
function stopAllRunningTasks() {
for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) {
let rootNode = thisObject.workspaceNode.rootNodes[i]
if (rootNode.type === 'Network') {
if (rootNode.networkNodes !== undefined) {
for (let j = 0; j < rootNode.networkNodes.length; j++) {
let networkNode = rootNode.networkNodes[j]
if (networkNode.dataMining !== undefined && networkNode.dataMining.payload !== undefined) {
networkNode.dataMining.payload.uiObject.menu.internalClick('Stop All Exchange Data Tasks')
networkNode.dataMining.payload.uiObject.menu.internalClick('Stop All Exchange Data Tasks')
}
if (networkNode.testingEnvironment !== undefined && networkNode.testingEnvironment.payload !== undefined) {
networkNode.testingEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Trading Tasks')
networkNode.testingEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Trading Tasks')
}
if (networkNode.productionEnvironment !== undefined && networkNode.productionEnvironment.payload !== undefined) {
networkNode.productionEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Trading Tasks')
networkNode.productionEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Trading Tasks')
}
}
}
}
}
}
function getNodeByShortcutKey(searchingKey) {
for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) {
let rootNode = thisObject.workspaceNode.rootNodes[i]
let node = functionLibraryShortcutKeys.getNodeByShortcutKey(rootNode, searchingKey)
if (node !== undefined) { return node }
}
}
function getNodeThatIsOnFocus() {
for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) {
let rootNode = thisObject.workspaceNode.rootNodes[i]
let node = functionLibraryOnFocus.getNodeThatIsOnFocus(rootNode)
if (node !== undefined) { return node }
}
}
function getHierarchyHeads() {
let nodes = []
for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) {
let rootNode = thisObject.workspaceNode.rootNodes[i]
let nodeDefinition = getNodeDefinition(rootNode)
if (nodeDefinition !== undefined) {
if (nodeDefinition.isHierarchyHead === true) {
nodes.push(rootNode)
}
}
}
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 getHierarchyHeadsByType(nodeType) {
let hiriatchyHeads = getHierarchyHeads()
for (let i = 0; i < hiriatchyHeads.length; i++) {
let hiriatchyHead = hiriatchyHeads[i]
if (hiriatchyHead.type === nodeType) {
return hiriatchyHead
}
}
}
function replaceWorkspaceByLoadingOne(name) {
let webCommand
if (name.indexOf('Plugin \u2192 ') >= 0) {
name = name.replace('Plugin \u2192 ', '')
webCommand = 'LoadPluginWorkspace'
} else {
webCommand = 'LoadWorkspace'
}
let blobService = newFileStorage()
blobService.getFileFromHost(webCommand + '/' + name, onFileReceived, true)
function onFileReceived(err, text, response) {
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
canvas.cockpitSpace.setStatus('Could not load the Workspace called "' + name + '". ', 500, canvas.cockpitSpace.statusTypes.WARNING)
return
}
loadedWorkspaceNode = JSON.parse(text)
saveWorkspace()
canvas.cockpitSpace.toTop()
let position = {
x: browserCanvas.width / 2,
y: browserCanvas.height / 2
}
circularProgressBar.initialize(position)
circularProgressBar.visible = true
workingAtTask = 1
}
}
function spawn(nodeText, mousePointer) {
try {
let point = {
x: mousePointer.x,
y: mousePointer.y
}
point = canvas.floatingSpace.container.frame.unframeThisPoint(point)
spawnPosition.x = point.x
spawnPosition.y = point.y
let droppedNode = JSON.parse(nodeText)
if (droppedNode.type === 'Workspace') {
loadedWorkspaceNode = droppedNode
circularProgressBar.initialize(mousePointer)
circularProgressBar.visible = true
workingAtTask = 1
return
}
/* It does not exist, so we recreeate it respecting the inner state of each object. */
let positionOffset = {
x: spawnPosition.x - droppedNode.savedPayload.position.x,
y: spawnPosition.y - droppedNode.savedPayload.position.y
}
thisObject.workspaceNode.rootNodes.push(droppedNode)
functionLibraryUiObjectsFromNodes.createUiObjectFromNode(droppedNode, undefined, undefined, positionOffset)
functionLibraryUiObjectsFromNodes.tryToConnectChildrenWithReferenceParents()
droppedNode = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] spawn -> err = ' + err.stack) }
}
}
async function onMenuItemClick(payload, action, relatedUiObject, callBackFunction) {
switch (action) {
case 'Copy Node Path':
{
let nodePath = functionLibraryNodePath.getNodePath(payload.node)
copyTextToClipboard(nodePath)
canvas.cockpitSpace.setStatus(
nodePath + ' copied to the Clipboard.'
, 50, canvas.cockpitSpace.statusTypes.ALL_GOOD)
}
break
case 'Add UI Object':
{
functionLibraryUiObjectsFromNodes.addUIObject(payload.node, relatedUiObject)
}
break
case 'Add Missing Children':
{
functionLibraryUiObjectsFromNodes.addMissingChildren(payload.node)
}
break
case 'Delete UI Object':
{
functionLibraryNodeDeleter.deleteUIObject(payload.node, thisObject.workspaceNode.rootNodes)
}
break
case 'Share Workspace':
{
let text = stringifyWorkspace(true)
let fileName = 'Share - ' + payload.node.type + ' - ' + payload.node.name + '.json'
if (text !== undefined) {
downloadText(fileName, text)
}
}
break
case 'Backup Workspace':
{
let text = stringifyWorkspace(false)
let fileName = 'Backup - ' + payload.node.type + ' - ' + payload.node.name + '.json'
if (text !== undefined) {
downloadText(fileName, text)
}
}
break
case 'Edit Code':
break
case 'Share':
{
let text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, true, false, true, true, true))
let nodeName = payload.node.name
if (nodeName === undefined) {
nodeName = ''
} else {
nodeName = '.' + nodeName
}
let fileName = 'Share - ' + payload.node.type + ' - ' + nodeName + '.json'
downloadText(fileName, text)
}
break
case 'Backup':
{
let text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, false, false, true, true, true))
let nodeName = payload.node.name
if (nodeName === undefined) {
nodeName = ''
} else {
nodeName = ' ' + nodeName
}
let fileName = 'Backup - ' + payload.node.type + ' - ' + nodeName + '.json'
downloadText(fileName, text)
}
break
case 'Clone':
{
let text = JSON.stringify(functionLibraryNodeCloning.getNodeClone(payload.node))
let nodeName = payload.node.name
if (nodeName === undefined) {
nodeName = ''
} else {
nodeName = ' ' + nodeName
}
let fileName = 'Clone - ' + payload.node.type + ' - ' + nodeName + '.json'
downloadText(fileName, text)
}
break
case 'Debug Task':
{
functionLibraryTaskFunctions.runTask(payload.node, functionLibraryProtocolNode, true, callBackFunction)
}
break
case 'Run Task':
{
functionLibraryTaskFunctions.runTask(payload.node, functionLibraryProtocolNode, false, callBackFunction)
}
break
case 'Stop Task':
{
functionLibraryTaskFunctions.stopTask(payload.node, functionLibraryProtocolNode, callBackFunction)
}
break
case 'Run All Tasks':
{
functionLibraryTaskFunctions.runAllTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Stop All Tasks':
{
functionLibraryTaskFunctions.stopAllTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Run All Task Managers':
{
functionLibraryTaskFunctions.runAllTaskManagers(payload.node, functionLibraryProtocolNode)
}
break
case 'Stop All Task Managers':
{
functionLibraryTaskFunctions.stopAllTaskManagers(payload.node, functionLibraryProtocolNode)
}
break
case 'Run All Exchange Data Tasks':
{
functionLibraryTaskFunctions.runAllExchangeDataTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Stop All Exchange Data Tasks':
{
functionLibraryTaskFunctions.stopAllExchangeDataTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Run All Exchange Trading Tasks':
{
functionLibraryTaskFunctions.runAllExchangeTradingTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Stop All Exchange Trading Tasks':
{
functionLibraryTaskFunctions.stopAllExchangeTradingTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Run All Market Data Tasks':
{
functionLibraryTaskFunctions.runAllMarketDataTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Stop All Market Data Tasks':
{
functionLibraryTaskFunctions.stopAllMarketDataTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Run All Market Trading Tasks':
{
functionLibraryTaskFunctions.runAllMarketTradingTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Stop All Market Trading Tasks':
{
functionLibraryTaskFunctions.stopAllMarketTradingTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Run All Data Mine Tasks':
{
functionLibraryTaskFunctions.runAllDataMineTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Stop All Data Mine Tasks':
{
functionLibraryTaskFunctions.stopAllDataMineTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Run All Trading Mine Tasks':
{
functionLibraryTaskFunctions.runAllTradingMineTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Stop All Trading Mine Tasks':
{
functionLibraryTaskFunctions.stopAllTradingMineTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Add Missing Exchange Data Tasks':
{
functionLibraryTaskFunctions.addMissingExchangeDataTasks(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Market Data Tasks':
{
functionLibraryTaskFunctions.addMissingMarketDataTasks(payload.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Data Mine Tasks':
{
functionLibraryTaskFunctions.addMissingDataMineTasks(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Exchange Trading Tasks':
{
functionLibraryTaskFunctions.addMissingExchangeTradingTasks(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Market Trading Tasks':
{
functionLibraryTaskFunctions.addMissingMarketTradingTasks(payload.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Trading Mine Tasks':
{
functionLibraryTaskFunctions.addMissingTradingMineTasks(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Tasks':
{
functionLibraryTaskFunctions.addAllTasks(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Crypto Exchanges':
{
functionLibraryCryptoEcosystemFunctions.addMissingExchanges(payload.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Assets':
{
functionLibraryCryptoEcosystemFunctions.addMissingAssets(payload.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Markets':
{
functionLibraryCryptoEcosystemFunctions.addMissingMarkets(payload.node, functionLibraryUiObjectsFromNodes, functionLibraryNodeCloning)
}
break
case 'Install Market':
{
functionLibraryCryptoEcosystemFunctions.installMarket(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter, functionLibraryChartingSpaceFunctions, functionLibraryDataStorageFunctions)
}
break
case 'Uninstall Market':
{
functionLibraryCryptoEcosystemFunctions.uninstallMarket(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter, functionLibraryChartingSpaceFunctions, functionLibraryDataStorageFunctions)
}
break
case 'Add All Output Datasets':
{
functionLibraryDataMineFunctions.addAllOutputDatasets(payload.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Data Products':
{
functionLibraryDataStorageFunctions.addAllDataProducts(payload.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Data Mine Products':
{
functionLibraryDataStorageFunctions.addAllDataMineProducts(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Trading Mine Products':
{
functionLibraryDataStorageFunctions.addAllTradingMineProducts(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Session References':
{
functionLibraryDataStorageFunctions.addMissingSessionReferences(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Market Data Products':
{
functionLibraryDataStorageFunctions.addMissingMarketDataProducts(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Market Trading Products':
{
functionLibraryDataStorageFunctions.addMissingMarketTradingProducts(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Exchange Trading Products':
{
functionLibraryDataStorageFunctions.addMissingExchangeTradingProducts(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Exchange Data Products':
{
functionLibraryDataStorageFunctions.addMissingExchangeDataProducts(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Data Dependencies':
{
functionLibraryDataMineFunctions.addAllDataDependencies(payload.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Data Mine Dependencies':
{
functionLibraryDataMineFunctions.addAllDataMineDataDependencies(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Mine Layers':
{
functionLibraryChartingSpaceFunctions.addAllMineLayers(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
}
break
case 'Add Missing Time Machines':
{
functionLibraryChartingSpaceFunctions.addMissingTimeMachines(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
}
break
case 'Add Missing Dashboards':
{
functionLibraryChartingSpaceFunctions.addMissingDashboards(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
}
break
case 'Play Tutorial':
{
canvas.tutorialSpace.playTutorial(payload.node)
}
break
case 'Play Tutorial Topic':
{
canvas.tutorialSpace.playTutorialTopic(payload.node)
}
break
case 'Play Tutorial Step':
{
canvas.tutorialSpace.playTutorialStep(payload.node)
}
break
case 'Resume Tutorial':
{
canvas.tutorialSpace.resumeTutorial(payload.node)
}
break
case 'Resume Tutorial Topic':
{
canvas.tutorialSpace.resumeTutorialTopic(payload.node)
}
break
case 'Resume Tutorial Step':
{
canvas.tutorialSpace.resumeTutorialStep(payload.node)
}
break
case 'Reset Tutorial Progress':
{
canvas.tutorialSpace.resetTutorialProgress(payload.node)
}
break
case 'Send Webhook Test Message':
{
functionLibraryWebhookFunctions.sendTestMessage(payload.node, callBackFunction)
}
break
case 'Run Session':
{
functionLibrarySessionFunctions.runSession(payload.node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, false, callBackFunction)
}
break
case 'Resume Session':
{
functionLibrarySessionFunctions.runSession(payload.node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, true, callBackFunction)
}
break
case 'Stop Session':
{
functionLibrarySessionFunctions.stopSession(payload.node, functionLibraryProtocolNode, callBackFunction)
}
break
case 'Run Super Action':
{
functionLibrarySuperScripts.runSuperScript(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryNodeCloning, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
}
break
case 'Remove Parent':
{
chainDetachNode(payload.node)
}
break
case 'Remove Reference':
{
referenceDetachNode(payload.node)
}
break
case 'Push Code to Javascript Code':
{
payload.node.javascriptCode.code = payload.node.code
}
break
case 'Fetch Code to Javascript Code':
{
payload.node.code = payload.node.javascriptCode.code
}
break
case 'Open Documentation':
{
let definition = getNodeDefinition(payload.node)
if (definition !== undefined) {
if (definition.docURL !== undefined) {
canvas.docSpace.navigateTo(definition.docURL)
} else {
let headName = getHiriarchyHead(payload.node).type
headName = headName.toLowerCase()
headName = headName.split(" ").join("-")
let nodeName = payload.node.type
nodeName = nodeName.toLowerCase()
nodeName = nodeName.split(" ").join("-")
url = DOCUMENTATION_URL_PREFIX + "suite-hierarchy-" + headName + ".html#" + nodeName
canvas.docSpace.navigateTo(url)
}
}
}
break
case 'Add Missing Data Mines':
{
functionLibraryPluginsFunctions.pluginMissingDataMines(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Trading Mines':
{
functionLibraryPluginsFunctions.pluginMissingTradingMines(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Trading Systems':
{
functionLibraryPluginsFunctions.pluginMissingTradingSystems(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Trading Engines':
{
functionLibraryPluginsFunctions.pluginMissingTradingEngines(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Super Scripts':
{
functionLibraryPluginsFunctions.pluginMissingSuperScripts(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Tutorials':
{
functionLibraryPluginsFunctions.pluginMissingTutorials(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
}
}
}
+2
View File
@@ -76,6 +76,8 @@ function newEventsServerClient(networkNode) {
}
function sendToWebSocketServer(command) {
if (commandsWaitingConfirmation === undefined) {return} // object already finalized
nonce++
let stringNonce = nonce.toString()
let timestamp = (new Date()).valueOf()
+22 -22
View File
@@ -53,7 +53,7 @@ function newFrame() {
}
function isInViewPort() {
/* This function is usefull to know if the object who has this frame is currently appearing at least in part at the canvas.chartingSpace.viewport */
/* This function is usefull to know if the object who has this frame is currently appearing at least in part at the UI.projects.superalgos.spaces.chartingSpace.viewport */
point1 = {
x: 0,
@@ -67,10 +67,10 @@ function newFrame() {
/* Now the transformations. */
point1 = transformThisPoint(point1, thisObject.container)
point3 = transformThisPoint(point3, thisObject.container)
point1 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point1, thisObject.container)
point3 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point3, thisObject.container)
if (point1.x < canvas.chartingSpace.viewport.visibleArea.topRight.x && point1.y < canvas.chartingSpace.viewport.visibleArea.bottomRight.y && point3.x > canvas.chartingSpace.viewport.visibleArea.bottomLeft.x && point3.y > canvas.chartingSpace.viewport.visibleArea.topLeft.y) {
if (point1.x < UI.projects.superalgos.spaces.chartingSpace.viewport.visibleArea.topRight.x && point1.y < UI.projects.superalgos.spaces.chartingSpace.viewport.visibleArea.bottomRight.y && point3.x > UI.projects.superalgos.spaces.chartingSpace.viewport.visibleArea.bottomLeft.x && point3.y > UI.projects.superalgos.spaces.chartingSpace.viewport.visibleArea.topLeft.y) {
return true
} else {
return false
@@ -78,7 +78,7 @@ function newFrame() {
}
function isCenterInViewPort() {
/* This function is usefull to know if the object who has this frame is currently appearing at least in part at the canvas.chartingSpace.viewport */
/* This function is usefull to know if the object who has this frame is currently appearing at least in part at the UI.projects.superalgos.spaces.chartingSpace.viewport */
point1 = {
x: thisObject.width * 40 / 100,
@@ -92,10 +92,10 @@ function newFrame() {
/* Now the transformations. */
point1 = transformThisPoint(point1, thisObject.container)
point3 = transformThisPoint(point3, thisObject.container)
point1 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point1, thisObject.container)
point3 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point3, thisObject.container)
if (point1.x < canvas.chartingSpace.viewport.visibleArea.topRight.x && point1.y < canvas.chartingSpace.viewport.visibleArea.bottomRight.y && point3.x > canvas.chartingSpace.viewport.visibleArea.bottomLeft.x && point3.y > canvas.chartingSpace.viewport.visibleArea.topLeft.y) {
if (point1.x < UI.projects.superalgos.spaces.chartingSpace.viewport.visibleArea.topRight.x && point1.y < UI.projects.superalgos.spaces.chartingSpace.viewport.visibleArea.bottomRight.y && point3.x > UI.projects.superalgos.spaces.chartingSpace.viewport.visibleArea.bottomLeft.x && point3.y > UI.projects.superalgos.spaces.chartingSpace.viewport.visibleArea.topLeft.y) {
return true
} else {
return false
@@ -204,7 +204,7 @@ function newFrame() {
if (outsideViewPort === true) {
checkPoint = thisObject.container.frame.unframeThisPoint(checkPoint)
} else {
checkPoint = unTransformThisPoint(checkPoint, thisObject.container)
checkPoint = UI.projects.superalgos.utilities.coordinateTransformations.unTransformThisPoint(checkPoint, thisObject.container)
}
}
@@ -290,7 +290,7 @@ function newFrame() {
fitFunction: fitFunction
}
roundedCornersBackground(params)
UI.projects.superalgos.utilities.drawPrint.roundedCornersBackground(params)
titleBarPoint1 = {
x: 0,
@@ -388,10 +388,10 @@ function newFrame() {
}
/* Now the transformations. */
point1 = transformThisPoint(point1, thisObject.container)
point2 = transformThisPoint(point2, thisObject.container)
point3 = transformThisPoint(point3, thisObject.container)
point4 = transformThisPoint(point4, thisObject.container)
point1 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point1, thisObject.container)
point2 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point2, thisObject.container)
point3 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point3, thisObject.container)
point4 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point4, thisObject.container)
if (fitFunction !== undefined) {
point1 = fitFunction(point1)
@@ -437,8 +437,8 @@ function newFrame() {
y: j
}
point1 = transformThisPoint(point1, thisObject.container)
point2 = transformThisPoint(point2, thisObject.container)
point1 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point1, thisObject.container)
point2 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point2, thisObject.container)
if (fitFunction !== undefined) {
point1 = fitFunction(point1)
@@ -459,8 +459,8 @@ function newFrame() {
y: thisObject.height
}
point3 = transformThisPoint(point3, thisObject.container)
point4 = transformThisPoint(point4, thisObject.container)
point3 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point3, thisObject.container)
point4 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point4, thisObject.container)
if (fitFunction !== undefined) {
point3 = fitFunction(point3)
@@ -495,8 +495,8 @@ function newFrame() {
y: j
}
point1 = transformThisPoint(point1, thisObject.container)
point2 = transformThisPoint(point2, thisObject.container)
point1 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point1, thisObject.container)
point2 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point2, thisObject.container)
if (fitFunction !== undefined) {
point1 = fitFunction(point1)
@@ -517,8 +517,8 @@ function newFrame() {
y: thisObject.height
}
point3 = transformThisPoint(point3, thisObject.container)
point4 = transformThisPoint(point4, thisObject.container)
point3 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point3, thisObject.container)
point4 = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(point4, thisObject.container)
if (fitFunction !== undefined) {
point3 = fitFunction(point3)
+12 -19
View File
@@ -1,6 +1,14 @@
let canvas
let PROJECTS_ARRAY
let PROJECTS_SCHEMA
let SCHEMAS_BY_PROJECT = new Map()
/* New Root object*/
let UI = {
projects: {}
}
/* User Interface Colors */
const UI_COLOR = {
DARK: "48, 48, 54",
LIGHT: "234, 226, 222",
@@ -20,30 +28,15 @@ const UI_COLOR = {
};
/* User Interface Fonts */
const UI_FONT = {
PRIMARY: "Saira Condensed",
SECONDARY: "Source Code Pro"
};
const DOCUMENTATION_URL_PREFIX = 'https://docs.superalgos.org/'
const MAC_AMOUNT_FACTOR = 5
const IS_MAC = navigator.platform.toUpperCase().indexOf('MAC') >= 0
const DOUBLE_CLICK_ZOOM_OUT_LEVEL = 0
const DOUBLE_CLICK_ZOOM_IN_LEVEL = 6
const DOUBLE_CLICK_ZOOM_IN_IN_LEVEL = 7
const DEBUG = {}
const ZOOM_OUT_THRESHOLD_FOR_NOT_HIDDING_PANELS = 12
const ZOOM_OUT_THRESHOLD_FOR_HIDDING_PANELS = 7
const ZOOM_OUT_THRESHOLD_FOR_HIDDING_CHARTS_LABELS = 7
const ZOOM_OUT_THRESHOLD_FOR_CHANGING_TIME_FRAME = 3 // This help regulate when to change the Time Frame base on the level of zoom out.
const ZOOM_OUT_THRESHOLD_FOR_PACKING_OBJECTS_AT_THE_BOTTOM_OR_TOP_OF_VIEWPORT = 2
const ZOOM_OUT_THRESHOLD_FOR_PLOTTING_IN_LOW_RESOLUTION = 3
const ZOOM_OUT_THRESHOLD_FOR_DISPLAYING_TIME_MACHINES_ICONIZED = 5
const ZOOM_OUT_THRESHOLD_FOR_DISPLAYING_SCALES = 3
let FONT_ASPECT_RATIO = 0.32;
let ANIMATION_FRAME_PER_SECONDS
@@ -175,9 +168,9 @@ const _1_MINUTE_IN_MILISECONDS = 1 * 60 * 1000;
let NEW_SESSION_INITIAL_DATE = new Date(); // This value will be overwritten at the canvas.chartingSpace.viewport.initialize if the user had a prevous session with this same browser.
let NEW_SESSION_INITIAL_DATE = new Date(); // This value will be overwritten at the UI.projects.superalgos.spaces.chartingSpace.viewport.initialize if the user had a prevous session with this same browser.
let INITIAL_ZOOM_LEVEL = -28.25 // This is the zoom level at the view port in which the APP starts.
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 INITIAL_TIME_PERIOD = ONE_DAY_IN_MILISECONDS // This value will be overwritten at the UI.projects.superalgos.spaces.chartingSpace.viewport.initialize if the user had a prevous session with this same browser.
let VERY_LARGE_NUMBER = 100000000000000
const TOP_MARGIN = 0
@@ -230,7 +223,7 @@ let ARE_WE_RECORDING_A_MARKET_PANORAMA = false
let PANORAMA_WAS_PANNED = false
let CURRENT_PANORAMA_POSITION = 0
let canWeDraw = false // This global variable regulates when spaces can or can not draw their contents.
let CAN_SPACES_DRAW = false // This global variable regulates when spaces can or can not draw their contents.
function toRadians(angle) {
return angle * (Math.PI / 180);
-47
View File
@@ -1,47 +0,0 @@
function newNodesWarnings() {
const MODULE_NAME = 'Nodes Warnings'
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.warnings
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 === '') {
node.payload.uiObject.resetWarningMessage()
} else {
node.payload.uiObject.setWarningMessage(value)
}
}
}
-918
View File
@@ -1,918 +0,0 @@
function newPlotter() {
const MODULE_NAME = 'Plotter'
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
let thisObject = {
currentRecord: undefined,
container: undefined,
fitFunction: undefined,
onDailyFileLoaded: onDailyFileLoaded,
initialize: initialize,
finalize: finalize,
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
setCoordinateSystem: setCoordinateSystem,
draw: draw
}
let container = newContainer()
container.initialize()
thisObject.container = container
let coordinateSystem
let slotHeight = (canvas.chartingSpace.viewport.visibleArea.bottomRight.y - canvas.chartingSpace.viewport.visibleArea.topLeft.y) / 10 // This is the amount of slots available
let mustRecalculateDataPoints = false
let atMousePositionFillStyles = new Map()
let atMousePositionStrokeStyles = new Map()
let timeFrame // This will hold the current Time Frame the user is at.
let datetime // This will hold the current Datetime the user is at.
let marketFile // This is the current Market File being plotted.
let fileCursor // This is the current File Cursor being used to retrieve Daily Files.
let marketFiles // This object will provide the different Market Files at different Time Periods.
let dailyFiles // This object will provide the different File Cursors at different Time Periods.
let productDefinition // Here we store a snapshot of the product definition which references this plotter.
let records = [] // We will have the information to be plotted here.
let userPositionDate
let minUserPositionRate
let maxUserPositionRate
let onMouseOverEventSuscriptionId
let zoomChangedEventSubscriptionId
let offsetChangedEventSubscriptionId
let dragFinishedEventSubscriptionId
let dimmensionsChangedEventSubscriptionId
let marketFilesUpdatedEventSubscriptionId
let dailyFilesUpdatedEventSubscriptionId
let onDisplaceEventSubscriptionId
let scaleChangedEventSubscriptionId
let logged = false
return thisObject
function finalize() {
try {
/* Stop listening to the necesary events. */
thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId)
canvas.chartingSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId)
canvas.chartingSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId)
canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId)
thisObject.container.eventHandler.stopListening(dimmensionsChangedEventSubscriptionId)
marketFiles.eventHandler.stopListening(marketFilesUpdatedEventSubscriptionId)
dailyFiles.eventHandler.stopListening(dailyFilesUpdatedEventSubscriptionId)
thisObject.container.eventHandler.stopListening(onDisplaceEventSubscriptionId)
thisObject.fitFunction = undefined
/* Clear References */
marketFiles = undefined
dailyFiles = undefined
datetime = undefined
timeFrame = undefined
marketFile = undefined
fileCursor = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
slotHeight = undefined
mustRecalculateDataPoints = undefined
atMousePositionFillStyles = undefined
atMousePositionStrokeStyles = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err.stack.stack) }
}
}
function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction, pProductDefinition) {
try {
/* Store the information received. */
marketFiles = pStorage.marketFiles[0]
dailyFiles = pStorage.dailyFiles[0]
datetime = pDatetime
timeFrame = pTimeFrame
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
productDefinition = pProductDefinition
/* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */
marketFile = marketFiles.getFile(ONE_DAY_IN_MILISECONDS) // This file is the one processed faster.
/* Now we set the right files according to current Period. */
marketFile = marketFiles.getFile(pTimeFrame)
fileCursor = dailyFiles.getFileCursor(pTimeFrame)
/* Listen to the necesary events. */
zoomChangedEventSubscriptionId = canvas.chartingSpace.viewport.eventHandler.listenToEvent('Zoom Changed', onViewportZoomChanged)
offsetChangedEventSubscriptionId = canvas.chartingSpace.viewport.eventHandler.listenToEvent('Position Changed', onViewportPositionChanged)
dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent('Drag Finished', onDragFinished)
marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent('Files Updated', onMarketFilesUpdated)
dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent('Files Updated', onDailyFilesUpdated)
onDisplaceEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onDisplace', onDisplace)
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
/* Get ready for plotting. */
recalculate()
dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () {
recalculate()
})
callBackFunction()
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
}
function initializeCoordinateSystem() {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem() {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged() {
mustRecalculateDataPoints = true
recalculate()
}
function onMouseOver(event) {
let userPosition = getDateFromPointAtBrowserCanvas(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
let minPositionPoint = {
x: event.x,
y: event.y + 4
}
minUserPositionRate = getRateFromPointAtBrowserCanvas(minPositionPoint, thisObject.container, coordinateSystem)
let maxPositionPoint = {
x: event.x,
y: event.y - 4
}
maxUserPositionRate = getRateFromPointAtBrowserCanvas(maxPositionPoint, thisObject.container, coordinateSystem)
}
function onMarketFilesUpdated() {
try {
let newMarketFile = marketFiles.getFile(timeFrame)
if (newMarketFile !== undefined) {
marketFile = newMarketFile
mustRecalculateDataPoints = true
recalculate()
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] onMarketFilesUpdated -> err = ' + err.stack.stack) }
}
}
function onDailyFilesUpdated() {
try {
let newFileCursor = dailyFiles.getFileCursor(timeFrame)
if (newFileCursor !== undefined) {
fileCursor = newFileCursor
mustRecalculateDataPoints = true
recalculate()
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] onDailyFilesUpdated -> err = ' + err.stack.stack) }
}
}
function getContainer(point) {
try {
let container
/* First we check if this point is inside this space. */
if (thisObject.container.frame.isThisPointHere(point) === true) {
return thisObject.container
} else {
/* This point does not belong to this space. */
return undefined
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] getContainer -> err = ' + err.stack) }
}
}
function setTimeFrame(pTimeFrame) {
try {
if (timeFrame !== pTimeFrame) {
timeFrame = pTimeFrame
mustRecalculateDataPoints = true
if (timeFrame >= _1_HOUR_IN_MILISECONDS) {
marketFile = marketFiles.getFile(pTimeFrame)
} else {
fileCursor = dailyFiles.getFileCursor(pTimeFrame)
}
recalculate()
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] setTimeFrame -> err = ' + err.stack) }
}
}
function setDatetime(pDatetime) {
datetime = pDatetime
}
function setCoordinateSystem(pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onDailyFileLoaded(event) {
try {
if (event.currentValue === event.totalValue) {
/* This happens only when all of the files in the cursor have been loaded. */
recalculate()
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] onDailyFileLoaded -> err = ' + err.stack) }
}
}
function draw() {
try {
thisObject.container.frame.draw()
plot()
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] draw -> err = ' + err.stack) }
}
}
function recalculate() {
try {
if (timeFrame >= _1_HOUR_IN_MILISECONDS) {
recalculateUsingMarketFiles()
} else {
recalculateUsingDailyFiles()
}
thisObject.container.eventHandler.raiseEvent('CandleStairs Changed', records) // --> Check This
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] recalculate -> err = ' + err.stack) }
}
}
function jsonifyDataFile(dataFile, recordDefinition, farLeftDate, farRightDate) {
/*
This function has as an input the raw data on files and creates with it an array of JSON objects
with not calculated properties for later being consumed by Formulas
*/
let jsonifiedArray = []
let previous
for (let i = 0; i < dataFile.length; i++) {
let record = {}
for (let j = 0; j < recordDefinition.properties.length; j++) {
let property = recordDefinition.properties[j]
if (property.config.isCalculated !== true) {
record[property.config.codeName] = dataFile[i][j]
}
}
if (productDefinition.config.nodePathType === 'array') {
/*
When we have an array configuration, we know that the last field of the record
contains the array index, which is needed to correctly plot this data. Since
this index is not part of the product definition, we will restore its value in
this way:
*/
record.index = dataFile[i][recordDefinition.properties.length]
}
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. productDefinition.config.codeName = ' + productDefinition.config.codeName)
continue
}
if (record.end <= farLeftDate.valueOf()) { continue }
if (record.begin >= farRightDate.valueOf()) { continue }
if (record.end < coordinateSystem.min.x) { continue }
if (record.begin > coordinateSystem.max.x) { continue }
record.previous = previous
jsonifiedArray.push(record)
previous = record
}
return jsonifiedArray
}
function calculationsProcedure(jsonArray, recordDefinition, calculationsProcedure, timeFrame) {
/*
This function has as an input an array of JSON objects, and it adds calculated properties to
complete the set of properties that will be available.
*/
let system = { // These are the available system variables to be used in User Code and Formulas
timeFrame: timeFrame,
ONE_DAY_IN_MILISECONDS: ONE_DAY_IN_MILISECONDS
}
let variable = {} // This is the structure where the user will define its own variables that will be shared across different config blocks and formulas.
let results = []
/* This is Initialization Code */
if (calculationsProcedure.initialization !== undefined) {
if (calculationsProcedure.initialization.javascriptCode !== undefined) {
try {
eval(calculationsProcedure.initialization.javascriptCode.code)
} catch (err) {
logger.write('[ERROR] calculationsProcedure -> initialization -> Error executing User Code. Error = ' + err.stack.stack)
logger.write('[ERROR] calculationsProcedure -> initialization -> Error executing User Code. Code = ' + calculationsProcedure.initialization.javascriptCode.code)
throw ('Error Executing User Code.')
}
}
}
/* This is Initialization Code */
if (calculationsProcedure.loop !== undefined) {
if (calculationsProcedure.loop.javascriptCode !== undefined) {
for (let index = 0; index < jsonArray.length; index++) {
let product = jsonArray[index]
/* This is Loop Code */
try {
eval(calculationsProcedure.loop.javascriptCode.code)
} catch (err) {
logger.write('[ERROR] calculationsProcedure -> loop -> Error executing User Code. Error = ' + err.stack.stack)
logger.write('[ERROR] calculationsProcedure -> loop -> Error executing User Code. product = ' + JSON.stringify(product))
logger.write('[ERROR] calculationsProcedure -> loop -> Error executing User Code. Code = ' + calculationsProcedure.loop.javascriptCode.code)
throw ('Error Executing User Code.')
}
/* For each calculated property we apply its formula */
for (let j = 0; j < recordDefinition.properties.length; j++) {
let property = recordDefinition.properties[j]
if (property.config.isCalculated === true) {
if (property.formula !== undefined) {
if (property.formula.code !== undefined) {
try {
let newValue = eval(property.formula.code)
let currentRecord = product
currentRecord[property.config.codeName] = newValue
} catch (err) {
logger.write('[ERROR] calculationsProcedure -> loop -> formula -> Error executing User Code. Error = ' + err.stack.stack)
logger.write('[ERROR] calculationsProcedure -> loop -> formula -> Error executing User Code. product = ' + JSON.stringify(product))
logger.write('[ERROR] calculationsProcedure -> loop -> formula -> Error executing User Code. Code = ' + property.formula.code)
throw ('Error Executing User Code.')
}
}
}
}
}
/* Adding the new element to the resulting array */
results.push(product)
}
}
}
return results
}
function recalculateUsingDailyFiles() {
try {
if (fileCursor === undefined) {
records = []
return
} // We need to wait until there is a fileCursor available or maybe this indicator does not produce data for the current Time Frame
if (fileCursor.files.size === 0) { return } // We need to wait until there are files in the cursor
let daysOnSides = getSideDays(timeFrame)
let leftDate = getDateFromPointAtBrowserCanvas(canvas.chartingSpace.viewport.visibleArea.topLeft, thisObject.container, coordinateSystem)
let rightDate = getDateFromPointAtBrowserCanvas(canvas.chartingSpace.viewport.visibleArea.topRight, thisObject.container, coordinateSystem)
let dateDiff = rightDate.valueOf() - leftDate.valueOf()
let farLeftDate = new Date(leftDate.valueOf() - dateDiff * 1.5)
let farRightDate = new Date(rightDate.valueOf() + dateDiff * 1.5)
let currentDate = new Date(farLeftDate.valueOf())
records = []
while (currentDate.valueOf() <= farRightDate.valueOf() + ONE_DAY_IN_MILISECONDS) {
let stringDate = currentDate.getFullYear() + '-' + pad(currentDate.getMonth() + 1, 2) + '-' + pad(currentDate.getDate(), 2)
let dailyFile = fileCursor.files.get(stringDate)
if (dailyFile !== undefined) {
/* Transform the current file content into an array of JSON objects */
let jsonData = jsonifyDataFile(dailyFile, productDefinition.record, farLeftDate, farRightDate)
/* Add the calculated properties */
if (productDefinition.calculations !== undefined) {
let calculationsResult = calculationsProcedure(jsonData, productDefinition.record, productDefinition.calculations, timeFrame)
records.push(...calculationsResult) // This adds records to the current array.
} else {
records.push(...jsonData)// This adds records to the current array.
}
}
currentDate = new Date(currentDate.valueOf() + ONE_DAY_IN_MILISECONDS)
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] recalculateUsingDailyFiles -> err = ' + err.stack) }
}
}
function recalculateUsingMarketFiles() {
try {
if (marketFile === undefined) {
records = []
return
} // Initialization not complete yet or this indicator does not produce data for the current time frame
let daysOnSides = getSideDays(timeFrame)
let leftDate = getDateFromPointAtBrowserCanvas(canvas.chartingSpace.viewport.visibleArea.topLeft, thisObject.container, coordinateSystem)
let rightDate = getDateFromPointAtBrowserCanvas(canvas.chartingSpace.viewport.visibleArea.topRight, thisObject.container, coordinateSystem)
let dateDiff = rightDate.valueOf() - leftDate.valueOf()
leftDate = new Date(leftDate.valueOf() - dateDiff * 1.5)
rightDate = new Date(rightDate.valueOf() + dateDiff * 1.5)
for (let i = 0; i < records.length; i++) {
let record = records[i]
record.fillStyle = undefined
record.strokeStyle = undefined
record.dataPoints = undefined
record.previous = undefined
records[i] = {}
}
records = []
/* Transform the current file content into an array of JSON objects */
let jsonData = jsonifyDataFile(marketFile, productDefinition.record, leftDate, rightDate)
/* Add the calculated properties */
if (productDefinition.calculations !== undefined) {
let calculationsResult = calculationsProcedure(jsonData, productDefinition.record, productDefinition.calculations, timeFrame)
records.push(...calculationsResult) // This adds records to the current array.
} else {
records.push(...jsonData)// This adds records to the current array.
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] recalculateUsingMarketFiles -> err = ' + err.stack) }
}
}
function plot() {
try {
/* Clean the pannel at places where there is no record. */
thisObject.container.eventHandler.raiseEvent('Current Record Changed', undefined)
for (let i = 0; i < records.length; i++) {
let record = records[i]
/*
In the formulas to create plotters, we allos users to reference the previous record.
To enable that we need to link all records to the previous one in this way.
*/
if (i == 0) {
record.previous = {} // this way it wont be undefined
} else {
record.previous = records[i - 1]
}
let beginPoint = {
x: record.begin,
y: 0
}
let endPoint = {
x: record.end,
y: 0
}
beginPoint = coordinateSystem.transformThisPoint(beginPoint)
endPoint = coordinateSystem.transformThisPoint(endPoint)
beginPoint = transformThisPoint(beginPoint, thisObject.container)
endPoint = transformThisPoint(endPoint, thisObject.container)
beginPoint = canvas.chartingSpace.viewport.fitIntoVisibleArea(beginPoint)
endPoint = canvas.chartingSpace.viewport.fitIntoVisibleArea(endPoint)
beginPoint = thisObject.fitFunction(beginPoint)
endPoint = thisObject.fitFunction(endPoint)
if (endPoint.x < canvas.chartingSpace.viewport.visibleArea.bottomLeft.x || beginPoint.x > canvas.chartingSpace.viewport.visibleArea.bottomRight.x) {
continue
}
let atMousePosition = false
if (userPositionDate >= record.begin && userPositionDate <= record.end) {
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)
}
}
/* If there is code we execute it now. */
if (productDefinition.referenceParent.javascriptCode !== undefined) {
eval(productDefinition.referenceParent.javascriptCode.code)
}
if (productDefinition.referenceParent.shapes === undefined) { continue }
if (productDefinition.referenceParent.shapes.chartPoints === undefined) { continue }
let dataPoints = new Map()
if (record.dataPoints !== undefined && mustRecalculateDataPoints === false) {
/* We use the datapoints already calculated. */
dataPoints = record.dataPoints
} else {
if (logged === false) {
logged = true
}
/* It seems we need to calculate the data points this time. */
for (let k = 0; k < productDefinition.referenceParent.shapes.chartPoints.length; k++) {
let chartPoints = productDefinition.referenceParent.shapes.chartPoints[k]
for (let j = 0; j < chartPoints.points.length; j++) {
let point = chartPoints.points[j]
if (point.pointFormula !== undefined) {
let x = 0
let y = 0
eval(point.pointFormula.code)
let rawPoint = {
x: x,
y: y
}
/*
The information we store in files is independent from the charing system and its coordinate systems.
That means that the first thing we allways need to do is to trasform these points to the coordinate system of the timeline.
*/
let dataPoint
dataPoint = coordinateSystem.transformThisPoint(rawPoint)
dataPoint = transformThisPoint(dataPoint, thisObject.container)
let testPoint = {
x: dataPoint.x,
y: dataPoint.y
}
dataPoint = canvas.chartingSpace.viewport.fitIntoVisibleArea(dataPoint)
dataPoint = thisObject.fitFunction(dataPoint)
if (testPoint.x === dataPoint.x) {
dataPoint.isInViewPort = true
} else {
dataPoint.isInViewPort = false
}
/* Store the data point at the local map */
dataPoint.rawPoint = rawPoint
dataPoints.set(point.id, dataPoint)
}
}
}
/* Remember this datapoints, so that we do not need to calculate them again. */
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. */
if (polygon.polygonCondition !== undefined) {
let mustPlot = eval(polygon.polygonCondition.code)
if (mustPlot !== true) { continue }
}
let calculatedStyle
/* Finding out the fill style */
let fillStyle = { // default values
opacity: 1,
paletteColor: UI_COLOR.BLACK
}
if (polygon.polygonBody !== undefined) {
if (record.fillStyle === undefined) {
record.fillStyle = new Map()
}
calculatedStyle = record.fillStyle.get(polygon.id)
if (calculatedStyle !== undefined) {
/* We use the already calculated style */
fillStyle = calculatedStyle
} else {
/* Get the default style if exists */
if (polygon.polygonBody.style !== undefined) {
if (polygon.polygonBody.style.config !== undefined) {
if (polygon.polygonBody.style.config.default !== undefined) {
let bodyStyle = polygon.polygonBody.style.config.default
if (bodyStyle.opacity !== undefined) { fillStyle.opacity = bodyStyle.opacity }
if (bodyStyle.paletteColor !== undefined) { fillStyle.paletteColor = eval(bodyStyle.paletteColor) }
}
}
}
/* Apply conditional styles */
if (polygon.polygonBody.styleConditions !== undefined) {
for (let k = 0; k < polygon.polygonBody.styleConditions.length; k++) {
let condition = polygon.polygonBody.styleConditions[k]
let value = eval(condition.code)
if (value === true) {
if (condition.style !== undefined) {
let bodyStyle = condition.style.config
if (bodyStyle.opacity !== undefined) { fillStyle.opacity = bodyStyle.opacity }
if (bodyStyle.paletteColor !== undefined) { fillStyle.paletteColor = eval(bodyStyle.paletteColor) }
}
}
}
}
/* Get the atMousePosition style if exists */
if (polygon.polygonBody.style !== undefined) {
if (polygon.polygonBody.style.config.atMousePosition !== undefined) {
let atMousePositionStyleDefinition = polygon.polygonBody.style.config.atMousePosition
let atMousePositionStyle = {}
if (atMousePositionStyleDefinition.opacity !== undefined) { atMousePositionStyle.opacity = atMousePositionStyleDefinition.opacity }
if (atMousePositionStyleDefinition.paletteColor !== undefined) { atMousePositionStyle.paletteColor = eval(atMousePositionStyleDefinition.paletteColor) }
atMousePositionFillStyles.set(polygon.id, atMousePositionStyle)
}
}
record.fillStyle.set(polygon.id, fillStyle)
}
}
/* Finding out the stroke style */
let strokeStyle = { // default values
opacity: 1,
paletteColor: UI_COLOR.BLACK,
lineWidth: 1,
lineDash: [0, 0]
}
if (polygon.polygonBorder !== undefined) {
if (record.strokeStyle === undefined) {
record.strokeStyle = new Map()
}
calculatedStyle = record.strokeStyle.get(polygon.id)
if (calculatedStyle !== undefined) {
/* We use the already calculated style */
strokeStyle = calculatedStyle
} else {
/* Get the default style if exists */
if (polygon.polygonBorder.style !== undefined) {
if (polygon.polygonBorder.style.config !== undefined) {
if (polygon.polygonBorder.style.config.default !== undefined) {
let borderStyle = polygon.polygonBorder.style.config.default
if (borderStyle.opacity !== undefined) { strokeStyle.opacity = borderStyle.opacity }
if (borderStyle.paletteColor !== undefined) { strokeStyle.paletteColor = eval(borderStyle.paletteColor) }
if (borderStyle.lineWidth !== undefined) { strokeStyle.lineWidth = borderStyle.lineWidth }
if (borderStyle.lineDash !== undefined) { strokeStyle.lineDash = borderStyle.lineDash }
}
}
}
/* Apply conditional styles */
if (polygon.polygonBorder.styleConditions !== undefined) {
for (let k = 0; k < polygon.polygonBorder.styleConditions.length; k++) {
let condition = polygon.polygonBorder.styleConditions[k]
let value = eval(condition.code)
if (value === true) {
if (condition.style !== undefined) {
let borderStyle = condition.style.config
if (borderStyle.opacity !== undefined) { strokeStyle.opacity = borderStyle.opacity }
if (borderStyle.paletteColor !== undefined) { strokeStyle.paletteColor = eval(borderStyle.paletteColor) }
if (borderStyle.lineWidth !== undefined) { strokeStyle.lineWidth = borderStyle.lineWidth }
if (borderStyle.lineDash !== undefined) { strokeStyle.lineDash = borderStyle.lineDash }
}
}
}
}
/* Get the atMousePosition style if exists */
if (polygon.polygonBorder.style !== undefined) {
if (polygon.polygonBorder.style.config.atMousePosition !== undefined) {
let atMousePositionStyleDefinition = polygon.polygonBorder.style.config.atMousePosition
let atMousePositionStyle = {}
if (atMousePositionStyleDefinition.opacity !== undefined) { atMousePositionStyle.opacity = atMousePositionStyleDefinition.opacity }
if (atMousePositionStyleDefinition.paletteColor !== undefined) { atMousePositionStyle.paletteColor = eval(atMousePositionStyleDefinition.paletteColor) }
if (atMousePositionStyleDefinition.lineWidth !== undefined) { atMousePositionStyle.lineWidth = atMousePositionStyleDefinition.lineWidth }
if (atMousePositionStyleDefinition.lineDash !== undefined) { atMousePositionStyle.lineDash = atMousePositionStyleDefinition.lineDash }
atMousePositionStrokeStyles.set(polygon.id, atMousePositionStyle)
}
}
record.strokeStyle.set(polygon.id, strokeStyle)
}
}
/* Draw the Polygon */
browserCanvasContext.beginPath()
for (let k = 0; k < polygon.polygonVertexes.length; k++) {
let polygonVertex = polygon.polygonVertexes[k]
if (polygonVertex.referenceParent !== undefined) {
let dataPointObject = dataPoints.get(polygonVertex.referenceParent.id)
if (dataPointObject === undefined) {
polygonVertex.payload.uiObject.setErrorMessage('Vertex not referencing any Point')
console.log('[WARN] You have a Polygon Vertex not referencing any Point.')
continue
}
let dataPoint = {
x: dataPointObject.x,
y: dataPointObject.y
}
/* We make sure the points do not fall outside the viewport visible area. This step allways need to be done. */
dataPoint = canvas.chartingSpace.viewport.fitIntoVisibleArea(dataPoint)
dataPoint = thisObject.fitFunction(dataPoint)
/*
Contributing to Auto-Scale: A point will contribute to the y coordinate only if the x coordinate is plotted in the screen.
It can happen that objects that span through a long period of time could have its begin point inside the visible
viewport but not its end point. In those cases, the end point should not be reported.
*/
if (dataPointObject.rawPoint.y > 1 && dataPointObject.rawPoint.y !== undefined && isNaN(dataPointObject.rawPoint.y) === false) {
let rawPoint = coordinateSystem.transformThisPoint(dataPointObject.rawPoint)
if (dataPointObject.isInViewPort === true) {
coordinateSystem.reportYValue(dataPointObject.rawPoint.y)
}
}
if (k === 0) {
browserCanvasContext.moveTo(dataPoint.x, dataPoint.y)
} else {
browserCanvasContext.lineTo(dataPoint.x, dataPoint.y)
}
}
}
browserCanvasContext.closePath()
/* Apply the fill style to the canvas object */
if (polygon.polygonBody !== undefined) {
/* Replace the fill style if we are at mouse position */
if (atMousePosition === true) {
let atMousePositionFillStyle = atMousePositionFillStyles.get(polygon.id)
if (atMousePositionFillStyle !== undefined) {
fillStyle = atMousePositionFillStyle
}
}
browserCanvasContext.fillStyle = 'rgba(' + fillStyle.paletteColor + ', ' + fillStyle.opacity + ')'
browserCanvasContext.fill()
}
/* Apply the stroke style to the canvas object */
if (polygon.polygonBorder !== undefined) {
/* Replace the stroke style if we are at mouse position */
if (atMousePosition === true) {
let atMousePositionStrokeStyle = atMousePositionStrokeStyles.get(polygon.id)
if (atMousePositionStrokeStyle !== undefined) {
strokeStyle = atMousePositionStrokeStyle
}
}
browserCanvasContext.lineWidth = strokeStyle.lineWidth
browserCanvasContext.setLineDash(strokeStyle.lineDash)
browserCanvasContext.strokeStyle = 'rgba(' + strokeStyle.paletteColor + ', ' + strokeStyle.opacity + ')'
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 }
if (image.imageCondition !== undefined) {
let mustPlot = eval(image.imageCondition.code)
if (mustPlot !== true) { 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) { 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
}
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 !== undefined) {
if (imageToDraw.canDrawIcon === true) {
browserCanvasContext.drawImage(imageToDraw, imagePosition.x - imageSize / 2 + offsetX, imagePosition.y - imageSize / 2 - offsetY, imageSize, imageSize)
}
} else {
console.log('Can not plot image named ' + imageName + ' of product ' + productDefinition.name + ' because it does not exist.')
}
}
/* 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.autoMaxYScale === true) {
mustRecalculateDataPoints = true
} else {
mustRecalculateDataPoints = false
}
logged = false
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] plot -> err = ' + err.stack) }
}
}
function onViewportZoomChanged(event) {
try {
mustRecalculateDataPoints = true
recalculate()
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] onViewportZoomChanged -> err = ' + err.stack) }
}
}
function onDragFinished() {
if (canvas.chartingSpace.visible === true) {
recalculate()
}
}
function onDisplace(event) {
recalculateAll(event)
}
function onViewportPositionChanged(event) {
recalculateAll(event)
}
function recalculateAll(event) {
mustRecalculateDataPoints = true
if (event !== undefined) {
if (event.recalculate === true) {
recalculate()
return
}
}
if (Math.random() * 100 > 95) {
recalculate()
}
}
}
+99 -56
View File
@@ -1,15 +1,7 @@
let canvas
let markets
let APP_SCHEMA_MAP = new Map()
let APP_SCHEMA_ARRAY = []
let DOC_SCHEMA_MAP = new Map()
let DOC_SCHEMA_ARRAY = []
let CONCEPT_SCHEMA_MAP = new Map()
let CONCEPT_SCHEMA_ARRAY = []
function newDashboard() {
const MODULE_NAME = 'Dashboard'
function newAppPostLoader() {
const MODULE_NAME = 'Post Loader'
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
@@ -18,70 +10,121 @@ function newDashboard() {
start: start
}
const DEBUG_START_UP_DELAY = 0 // 3000; // This is a waiting time in case there is a need to debug the very first steps of initialization, to be able to hit F12 on time.
return thisObject
function start() {
try {
setBrowserEvents()
setUpSchemas()
/* Moving PROJECTS_ARRAY to the global variable */
PROJECTS_ARRAY = window.PROJECTS
window.PROJECTS = undefined
function setUpSchemas() {
APP_SCHEMA_ARRAY = getAppSchema()
for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) {
let nodeDefinition = APP_SCHEMA_ARRAY[i]
let key = nodeDefinition.type
APP_SCHEMA_MAP.set(key, nodeDefinition)
setBrowserEvents()
setupProjectsSchema()
function setupProjectsSchema() {
callWebServer(undefined, 'ProjectsSchema', onResponse)
function onResponse(err, file) {
PROJECTS_SCHEMA = JSON.parse(file)
setupSchemas()
}
DOC_SCHEMA_ARRAY = getDocSchema()
for (let i = 0; i < DOC_SCHEMA_ARRAY.length; i++) {
let nodeDefinition = DOC_SCHEMA_ARRAY[i]
let key = nodeDefinition.type
DOC_SCHEMA_MAP.set(key, nodeDefinition)
}
function setupSchemas() {
let totalWebServerCalls = 0
let webServerResponses = 0
for (let i = 0; i < PROJECTS_ARRAY.length; i++) {
let project = PROJECTS_ARRAY[i]
let schemas = {
array: {
appSchema: [],
docSchema: [],
conceptSchema: []
},
map: {
appSchema: new Map(),
docSchema: new Map(),
conceptSchema: new Map()
}
}
SCHEMAS_BY_PROJECT.set(project, schemas)
totalWebServerCalls++
callWebServer(undefined, 'Schema/' + project + '/AppSchema', onResponseAppSchema)
function onResponseAppSchema(err, schema) {
try {
schemas.array.appSchema = JSON.parse(schema)
for (let j = 0; j < schemas.array.appSchema.length; j++) {
let nodeDefinition = schemas.array.appSchema[j]
let key = nodeDefinition.type
schemas.map.appSchema.set(key, nodeDefinition)
}
} catch (err) {
console.log(err.stack)
}
webServerResponses++
if (webServerResponses === totalWebServerCalls) { startCanvas() }
}
totalWebServerCalls++
callWebServer(undefined, 'Schema/' + project + '/DocSchema', onResponseDocSchema)
function onResponseDocSchema(err, schema) {
try {
schemas.array.docSchema = JSON.parse(schema)
for (let j = 0; j < schemas.array.docSchema.length; j++) {
let nodeDefinition = schemas.array.docSchema[j]
let key = nodeDefinition.type
schemas.map.docSchema.set(key, nodeDefinition)
}
} catch (err) {
console.log(err.stack)
}
webServerResponses++
if (webServerResponses === totalWebServerCalls) { startCanvas() }
}
totalWebServerCalls++
callWebServer(undefined, 'Schema/' + project + '/ConceptSchema', onResponseConceptSchema)
function onResponseConceptSchema(err, schema) {
try {
schemas.array.conceptSchema = JSON.parse(schema)
for (let j = 0; j < schemas.array.conceptSchema.length; j++) {
let nodeDefinition = schemas.array.conceptSchema[j]
let key = nodeDefinition.type
schemas.map.conceptSchema.set(key, nodeDefinition)
}
} catch (err) {
console.log(err.stack)
}
webServerResponses++
if (webServerResponses === totalWebServerCalls) { startCanvas() }
}
}
CONCEPT_SCHEMA_ARRAY = getConceptSchema()
for (let i = 0; i < CONCEPT_SCHEMA_ARRAY.length; i++) {
let nodeDefinition = CONCEPT_SCHEMA_ARRAY[i]
let key = nodeDefinition.type
CONCEPT_SCHEMA_MAP.set(key, nodeDefinition)
}
startCanvas()
}
function startCanvas() {
/* If this method is executed for a second time, it should finalize the current execution structure */
if (canvas !== undefined) { canvas.finalize() }
setTimeout(delayedStart, DEBUG_START_UP_DELAY)
canvas = newCanvas()
canvas.initialize()
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] start -> err = ' + err.stack) }
}
}
function delayedStart() {
try {
/* For now, we are supporting only one market. */
let market = {
id: 2,
baseAsset: 'USDT',
quotedAsset: 'BTC'
}
markets = new Map()
markets.set(market.id, market)
canvas = newCanvas()
canvas.initialize()
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] delayedStart -> err = ' + err.stack) }
}
}
function setBrowserEvents() {
window.onbeforeunload = saveWorkspace
@@ -98,7 +141,7 @@ function newDashboard() {
window.addEventListener('keydown', window.manageBackRefresh)
function saveWorkspace() {
canvas.designSpace.workspace.save()
UI.projects.superalgos.spaces.designSpace.workspace.save()
}
}
}
+5 -5
View File
@@ -74,7 +74,7 @@ function newProductStorage(name) {
}
}
function initialize(dataMine, bot, session, product, exchange, market, pDatetime, pTimeFrame, host, port, eventsServerClient, callBackFunction) {
function initialize(mine, bot, session, product, exchange, market, pDatetime, pTimeFrame, host, port, eventsServerClient, callBackFunction) {
try {
datetime = pDatetime
timeFrame = pTimeFrame
@@ -90,7 +90,7 @@ function newProductStorage(name) {
dataSetsToLoad++
let marketFiles = newMarketFiles()
marketFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onMarketFileReady)
marketFiles.initialize(mine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onMarketFileReady)
thisObject.marketFiles.push(marketFiles)
}
break
@@ -99,7 +99,7 @@ function newProductStorage(name) {
dataSetsToLoad++
let dailyFiles = newDailyFiles()
dailyFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, pDatetime, pTimeFrame, host, port, eventsServerClient, onDailyFileReady)
dailyFiles.initialize(mine, bot, session, product, dataset, exchange, market, pDatetime, pTimeFrame, host, port, eventsServerClient, onDailyFileReady)
thisObject.dailyFiles.push(dailyFiles)
}
break
@@ -108,7 +108,7 @@ function newProductStorage(name) {
dataSetsToLoad++
let singleFile = newSingleFile()
singleFile.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onSingleFileReady)
singleFile.initialize(mine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onSingleFileReady)
thisObject.singleFile.push(singleFile)
}
break
@@ -117,7 +117,7 @@ function newProductStorage(name) {
dataSetsToLoad++
let fileSequences = newFileSequence()
fileSequences.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onFileSequenceReady)
fileSequences.initialize(mine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onFileSequenceReady)
thisObject.fileSequences.push(fileSequences)
}
break
-115
View File
@@ -1,115 +0,0 @@
function newDesignSpace() {
const MODULE_NAME = 'Designe Space'
let thisObject = {
container: undefined,
iconCollection: undefined,
iconByUiObjectType: undefined,
workspace: undefined,
physics: physics,
draw: draw,
getContainer: getContainer,
makeVisible: makeVisible,
makeInvisible: makeInvisible,
initialize: initialize
}
let container = newContainer()
container.initialize()
thisObject.container = container
container.isDraggeable = false
thisObject.iconCollection = new Map()
thisObject.iconByUiObjectType = new Map()
return thisObject
function initialize() {
loadIconCollection(onIconsReady)
function onIconsReady() {
buildIconByUiObjectTypeMap()
thisObject.workspace = newWorkspace()
thisObject.workspace.initialize()
}
function buildIconByUiObjectTypeMap() {
/* Take types-icons relationships defined at the schema */
for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) {
let nodeDefinition = APP_SCHEMA_ARRAY[i]
let iconName = nodeDefinition.icon
if (iconName === undefined) {
iconName = nodeDefinition.type.toLowerCase()
iconName = iconName.split(" ").join("-")
}
let icon = thisObject.iconCollection.get(iconName)
if (icon !== undefined) {
thisObject.iconByUiObjectType.set(nodeDefinition.type, icon)
}
}
}
}
function loadIconCollection(callBack) {
callServer(undefined, 'ImagesNames', onResponse)
function onResponse(err, data) {
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
console.log('Failed to Fetch Image Names from the Backend')
return
}
let imageNames = JSON.parse(data)
let imageLoadedCounter = 0
for (let i = 0; i < imageNames.length; i++) {
let name = imageNames[i]
loadImage(name)
}
function loadImage(name) {
imageLoadedCounter++
const PATH = 'Images/Icons/style-01/'
let image = new Image()
image.onload = onImageLoad
image.fileName = name
function onImageLoad() {
image.canDrawIcon = true
}
image.src = PATH + name
let key = name.substring(0, name.length - 4)
thisObject.iconCollection.set(key, image)
if (imageLoadedCounter === imageNames.length) {
callBack()
}
}
}
}
function physics() {
if (thisObject.workspace === undefined) { return }
thisObject.workspace.physics()
}
function makeVisible() {
visible = true
}
function makeInvisible() {
visible = false
}
function getContainer(point) {
}
function draw() {
if (thisObject.workspace === undefined) { return }
if (canWeDraw === false) { return }
thisObject.workspace.draw()
}
}
-160
View File
@@ -1,160 +0,0 @@
/*
The Splash Screen is to show some 'loading...' controls while the app is being loaded on the background. After the loading is complete the Splash Screens dissapears for good.
*/
function newSplashScreen() {
let thisObject = {
container: undefined,
draw: draw,
timeMachines: [],
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize
}
let container = newContainer()
container.initialize()
thisObject.container = container
resize()
container.frame.containerName = 'Splash Screen'
container.frame.position.x = 0
container.frame.position.y = 0
container.isDraggeable = false
let fadeOutCounter = 0
let opacity = 1
let logo
let canDrawLogo = false
let isInitialized = false
let splashScreenNeeded = true
return thisObject
function initialize() {
logo = new Image()
logo.onload = onImageLoad
function onImageLoad() {
canDrawLogo = true
}
logo.src = 'Images/superalgos-logo.png'
canvas.eventHandler.listenToEvent('Browser Resized', resize)
isInitialized = true
}
function resize() {
thisObject.container.frame.width = browserCanvas.width
thisObject.container.frame.height = browserCanvas.height
}
function draw() {
if (isInitialized === false) { return }
if (splashScreenNeeded === false) {
stepsInitializationCounter = 100
canDrawLogo = false
fadeOutCounter++
if (fadeOutCounter > 2) {
return
}
opacity = opacity - 1
}
thisObject.container.frame.draw(false, false)
/* Set the background. */
browserCanvasContext.beginPath()
browserCanvasContext.rect(0, 0, thisObject.container.frame.width, thisObject.container.frame.height)
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + opacity + ')'
browserCanvasContext.closePath()
browserCanvasContext.fill()
if (canDrawLogo === false) { return }
/* First the AA Logo. */
let imageHeight = 192 / 2
let imageWidth = 720 / 2
let yDisplacement = -60
let xDisplacement = -60
let imagePoint = {
x: thisObject.container.frame.width * 1 / 2 - imageWidth / 2 + xDisplacement,
y: thisObject.container.frame.height * 1 / 2 - imageHeight / 2 + yDisplacement
}
imagePoint = thisObject.container.frame.frameThisPoint(imagePoint)
browserCanvasContext.drawImage(logo, imagePoint.x, imagePoint.y, imageWidth, imageHeight)
/* Second the % of Advance. */
let label = '' + Math.trunc(stepsInitializationCounter) + ' %'
stepsInitializationCounter = stepsInitializationCounter + 5.0
if (stepsInitializationCounter > 99) {
splashScreenNeeded = false
canWeDraw = true
stepsInitializationCounter = 99
}
let fontSize = 15
let labelPoint = {
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO - 22,
y: thisObject.container.frame.height / 2 + fontSize / 2 + fontSize * 0.1 + 90 + yDisplacement
}
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
browserCanvasContext.fillStyle = 'rgba(0, 0, 0, ' + opacity + ')'
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
let title
let titlePoint
/* Algo Bots Competitions Sub Title */
fontSize = 35
title = 'Beta 6'
titlePoint = {
x: thisObject.container.frame.width / 2 - title.length / 2 * fontSize * FONT_ASPECT_RATIO - 20,
y: thisObject.container.frame.height / 2 + 70 + yDisplacement
}
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
browserCanvasContext.font = 'Saira Condensed'
browserCanvasContext.fillStyle = 'rgba(0, 0, 0, ' + opacity + ')'
browserCanvasContext.fillText(title, titlePoint.x, titlePoint.y)
}
function getContainer(point) {
var container
/* First we check if this point is inside this space. */
if (thisObject.container.frame.isThisPointHere(point) === true) {
/* Now we see which is the inner most container that has it */
// add validation of inner most containers here.
/* The point does not belong to any inner container, so we return the current container. */
return thisObject.container
} else {
/* This point does not belong to this space. */
return undefined
}
}
}
+53 -13
View File
@@ -1,6 +1,12 @@
function getNodeDefinition(node) {
let key = node.type
return APP_SCHEMA_MAP.get(key)
function getNodeDefinition(node, project) {
if (project === undefined) { project = node.project }
let APP_SCHEMA = SCHEMAS_BY_PROJECT.get(project)
if (APP_SCHEMA !== undefined) {
return SCHEMAS_BY_PROJECT.get(project).map.appSchema.get(node.type)
} else {
console.log('[Error] Could not get APP Scchema for project ' + node.project)
}
}
function dynamicDecimals(value, minDecimals) {
@@ -9,12 +15,17 @@ function dynamicDecimals(value, minDecimals) {
}
let decimals = 0
if (value < 1) { decimals = 2 }
if (Math.abs(Math.trunc(value * 100)) < 1) { decimals = 4 }
if (Math.abs(Math.trunc(value * 10000)) < 1) { decimals = 6 }
if (Math.abs(Math.trunc(value * 1000000)) < 1) { decimals = 8 }
if (Math.abs(Math.trunc(value * 100000000)) < 1) { decimals = 10 }
if (Math.abs(Math.trunc(value * 10000000000)) < 1) { value = 0; decimals = 0 }
if (decimals < minDecimals) {decimals = minDecimals}
if (Math.abs(Math.trunc(value * 10)) < 1) { decimals = 4 }
if (Math.abs(Math.trunc(value * 100)) < 1) { decimals = 5 }
if (Math.abs(Math.trunc(value * 1000)) < 1) { decimals = 6 }
if (Math.abs(Math.trunc(value * 10000)) < 1) { decimals = 7 }
if (Math.abs(Math.trunc(value * 100000)) < 1) { decimals = 8 }
if (Math.abs(Math.trunc(value * 1000000)) < 1) { decimals = 9 }
if (Math.abs(Math.trunc(value * 10000000)) < 1) { decimals = 10 }
if (Math.abs(Math.trunc(value * 100000000000)) < 1) { value = 0; decimals = 0 }
if (decimals < minDecimals) { decimals = minDecimals }
let returnValue = Number(value).toFixed(decimals)
return returnValue
@@ -55,14 +66,14 @@ function moveToUserPosition(container, currentDate, currentRate, coordinateSyste
y: currentRate
}
/* Put this point in the coordinate system of the canvas.chartingSpace.viewport */
/* Put this point in the coordinate system of the UI.projects.superalgos.spaces.chartingSpace.viewport */
targetPoint = coordinateSystem.transformThisPoint(targetPoint)
targetPoint = transformThisPoint(targetPoint, container)
targetPoint = UI.projects.superalgos.utilities.coordinateTransformations.transformThisPoint(targetPoint, container)
let displaceVector
let targetNoZoom = canvas.chartingSpace.viewport.unTransformThisPoint(targetPoint)
let mouseNoZoom = canvas.chartingSpace.viewport.unTransformThisPoint(mousePosition)
let targetNoZoom = UI.projects.superalgos.spaces.chartingSpace.viewport.unTransformThisPoint(targetPoint)
let mouseNoZoom = UI.projects.superalgos.spaces.chartingSpace.viewport.unTransformThisPoint(mousePosition)
displaceVector = {
x: mouseNoZoom.x - targetNoZoom.x,
@@ -89,3 +100,32 @@ function newUniqueId() {
return v.toString(16)
})
}
function splitTextIntoPhrases(text, wordsPerLine) {
let splittedLabel = text.split(' ')
let phrases = []
let phrase = ''
let wordCount = 0
for (let i = 0; i < splittedLabel.length; i++) {
phrase = phrase + splittedLabel[i]
wordCount++
if (i < splittedLabel.length - 1 && wordCount < wordsPerLine) {
phrase = phrase + ' '
}
if (wordCount >= wordsPerLine) {
phrases.push(phrase)
phrase = ''
wordCount = 0
}
}
if (wordCount > 0) {
phrases.push(phrase)
}
return phrases
}
function getTextWidth(text) {
var metrics = browserCanvasContext.measureText(text);
return metrics.width;
}
-57
View File
@@ -1,57 +0,0 @@
function nodeBranchToArray(node, nodeType) {
/*
This function scans a node branch for a certain node type and
return an array of with all the nodes of that type found.
*/
if (node === undefined) { return }
if (nodeType === undefined) { return }
let resultArray = []
scanNodeBranch(node, nodeType)
return resultArray
function scanNodeBranch(startingNode) {
if (startingNode === undefined) {return}
let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type)
if (nodeDefinition === undefined) { return }
if (startingNode.type === nodeType) {
resultArray.push(startingNode)
return
}
if (nodeDefinition.properties === undefined) { return }
let lastNodePropertyName
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
if (lastNodePropertyName === property.name) {continue} // Some nodes have a single property por multiple child node types. We need to check repeated properties only once so as no to duplicate results.
switch (property.type) {
case 'node': {
scanNodeBranch(startingNode[property.name])
lastNodePropertyName = property.name
}
break
case 'array': {
let startingNodePropertyArray = startingNode[property.name]
for (let m = 0; m < startingNodePropertyArray.length; m++) {
scanNodeBranch(startingNodePropertyArray[m])
}
break
}
}
}
}
}
function findInBranch(startingNode, nodeType, errorNode, connectedViaPayload) {
/*
This function finds a node in a brach and reports an error if it could not be found.
*/
let nodeFound = findNodeInNodeMesh(startingNode, nodeType, undefined, connectedViaPayload, true, false, false)
if (nodeFound === undefined) {
errorNode.payload.uiObject.setErrorMessage('Could not find ' + nodeType + ' at ' + startingNode.type + ' ' + startingNode.name)
return
} else {
return nodeFound
}
}
-35
View File
@@ -1,35 +0,0 @@
function fallbackCopyTextToClipboard(text) {
var textArea = document.createElement("textarea");
textArea.value = text;
// Avoid scrolling to bottom
textArea.style.top = "0";
textArea.style.left = "0";
textArea.style.position = "fixed";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
//console.log('Fallback: Copying text command was ' + msg);
} catch (err) {
console.error('Fallback: Oops, unable to copy', err);
}
document.body.removeChild(textArea);
}
function copyTextToClipboard(text) {
if (!navigator.clipboard) {
fallbackCopyTextToClipboard(text);
return;
}
navigator.clipboard.writeText(text).then(function() {
//console.log('Async: Copying to clipboard was successful!');
}, function(err) {
console.error('Async: Could not copy text: ', err);
});
}
@@ -1,17 +0,0 @@
function transformThisPoint(point, container) {
/* We make the point relative to the current frame */
point = container.frame.frameThisPoint(point)
/* We pass this point through the canvas.chartingSpace.viewport lends, meaning we apply the canvas.chartingSpace.viewport zoom and displacement. */
point = canvas.chartingSpace.viewport.transformThisPoint(point)
return point
}
function unTransformThisPoint(point, container) {
point = canvas.chartingSpace.viewport.unTransformThisPoint(point)
point = container.frame.unframeThisPoint(point)
return point
}
@@ -1,53 +0,0 @@
function getDateFromPointAtBrowserCanvas(point, container, coordinateSystem) {
point = unTransformThisPoint(point, container)
point = coordinateSystem.unInverseTransform(point, container.frame.height)
let date = new Date(point.x)
return date
}
function getDateFromPointAtChartsSpace(point, container, coordinateSystem) {
point = container.frame.unframeThisPoint(point)
point = coordinateSystem.unInverseTransform(point, container.frame.height)
let date = new Date(point.x)
return date
}
function getDateFromPointAtContainer(point, container, coordinateSystem) {
point = coordinateSystem.unInverseTransform(point, container.frame.height)
let date = new Date(point.x)
return date
}
function getRateFromPointAtBrowserCanvas(point, container, coordinateSystem) {
point = unTransformThisPoint(point, container)
point = coordinateSystem.unInverseTransform(point, container.frame.height)
return point.y
}
function getRateFromPointAtChartingSpace(point, container, coordinateSystem) {
point = container.frame.unframeThisPoint(point)
point = coordinateSystem.unInverseTransform(point, container.frame.height)
return point.y
}
function getRateFromPointAtContainer(point, container, coordinateSystem) {
point = coordinateSystem.unInverseTransform(point, container.frame.height)
return point.y
}
function getMilisecondsFromPoint(point, container, coordinateSystem) {
point = unTransformThisPoint(point, container)
point = coordinateSystem.unInverseTransform(point, container.frame.height)
return point.x
}
-13
View File
@@ -1,13 +0,0 @@
function formatDate(date) {
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2)
month = '0' + month;
if (day.length < 2)
day = '0' + day;
return [year, month, day].join('-');
}
-58
View File
@@ -1,58 +0,0 @@
function downloadText(filename, text) {
let element = document.createElement('a')
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text))
element.setAttribute('download', filename)
element.style.display = 'none'
document.body.appendChild(element)
element.click()
document.body.removeChild(element)
}
function downloadCanvas(filename, canvasToUse) {
let data = canvasToUse.toDataURL('image/png', 1)
/* Change MIME type to trick the browser to downlaod the file instead of displaying it */
data = data.replace(/^data:image\/[^;]*/, 'data:application/octet-stream')
/* In addition to <a>'s "download" attribute, you can define HTTP-style headers */
data = data.replace(/^data:application\/octet-stream/, 'data:application/octet-stream;headers=Content-Disposition%3A%20attachment%3B%20filename=' + filename + '.png')
let element = document.createElement('a')
element.setAttribute('href', data)
element.setAttribute('download', filename + '.PNG')
element.style.display = 'none'
document.body.appendChild(element)
element.click()
document.body.removeChild(element)
};
function downloadPanorama(filename) {
let INITIAL_WIDTH = 800
let FINAL_WIDTH = browserCanvas.width - INITIAL_WIDTH
if (ARE_WE_RECORDING_A_MARKET_PANORAMA === false) {
/* We start recording the panorame. */
ARE_WE_RECORDING_A_MARKET_PANORAMA = true
marketPanoramaCanvas = document.createElement('canvas')
marketPanoramaCanvas.width = INITIAL_WIDTH * 50
marketPanoramaCanvas.height = browserCanvas.height
marketPanoramaCanvas.getContext('2d').drawImage(browserCanvas, 0, 0, INITIAL_WIDTH, browserCanvas.height, 0, 0, INITIAL_WIDTH, browserCanvas.height)
CURRENT_PANORAMA_POSITION = INITIAL_WIDTH
} else {
/* We stop recording and download the resulting image. */
ARE_WE_RECORDING_A_MARKET_PANORAMA = false
marketPanoramaCanvas.getContext('2d').drawImage(browserCanvas, browserCanvas.width - FINAL_WIDTH, 0, FINAL_WIDTH, browserCanvas.height, CURRENT_PANORAMA_POSITION, 0, FINAL_WIDTH, browserCanvas.height)
let finalResultCanvas = document.createElement('canvas')
finalResultCanvas.width = CURRENT_PANORAMA_POSITION + FINAL_WIDTH
finalResultCanvas.height = browserCanvas.height
finalResultCanvas.getContext('2d').drawImage(marketPanoramaCanvas, 0, 0, finalResultCanvas.width, browserCanvas.height, 0, 0, finalResultCanvas.width, browserCanvas.height)
downloadCanvas(filename, finalResultCanvas)
marketPanoramaCanvas = undefined
}
}
function addToMarketPanorama() {
let SECTION_WIDTH = 80 * 2
let INITIAL_POSITION = 800 - SECTION_WIDTH
marketPanoramaCanvas.getContext('2d').drawImage(browserCanvas, INITIAL_POSITION, 0, SECTION_WIDTH, browserCanvas.height, CURRENT_PANORAMA_POSITION, 0, SECTION_WIDTH, browserCanvas.height)
CURRENT_PANORAMA_POSITION = CURRENT_PANORAMA_POSITION + SECTION_WIDTH
}
-221
View File
@@ -1,221 +0,0 @@
function roundedCornersBackground(params) {
if (params.xOffset === undefined) { params.xOffset = 0 }
borderPoint1 = {
x: params.cornerRadius + params.xOffset,
y: params.cornerRadius
}
borderPoint2 = {
x: params.container.frame.width - params.cornerRadius,
y: params.cornerRadius
}
borderPoint3 = {
x: params.container.frame.width - params.cornerRadius,
y: params.container.frame.height - params.cornerRadius
}
borderPoint4 = {
x: params.cornerRadius + params.xOffset,
y: params.container.frame.height - params.cornerRadius
}
/* Now the transformations. */
if (params.coordinateSystem !== undefined) { // For instance Candles would use this
borderPoint1 = params.coordinateSystem.transformThisPoint(borderPoint1)
borderPoint2 = params.coordinateSystem.transformThisPoint(borderPoint2)
borderPoint3 = params.coordinateSystem.transformThisPoint(borderPoint3)
borderPoint4 = params.coordinateSystem.transformThisPoint(borderPoint4)
} else {
if (params.outsideViewPort === true) { // If the element is not affected by zoom
borderPoint1 = transformThisPoint(borderPoint1, params.container)
borderPoint2 = transformThisPoint(borderPoint2, params.container)
borderPoint3 = transformThisPoint(borderPoint3, params.container)
borderPoint4 = transformThisPoint(borderPoint4, params.container)
} else { // For instance Panels use this
borderPoint1 = params.container.frame.frameThisPoint(borderPoint1)
borderPoint2 = params.container.frame.frameThisPoint(borderPoint2)
borderPoint3 = params.container.frame.frameThisPoint(borderPoint3)
borderPoint4 = params.container.frame.frameThisPoint(borderPoint4)
}
}
if (params.fitFunction !== undefined) {
borderPoint1 = params.fitFunction(borderPoint1)
borderPoint2 = params.fitFunction(borderPoint2)
borderPoint3 = params.fitFunction(borderPoint3)
borderPoint4 = params.fitFunction(borderPoint4)
}
browserCanvasContext.setLineDash([0, 0])
/* Shadow */
if (params.castShadow === true) {
let SHADOW_OFFSET = 2
browserCanvasContext.beginPath()
browserCanvasContext.arc(borderPoint1.x + SHADOW_OFFSET, borderPoint1.y + SHADOW_OFFSET, params.cornerRadius, 1.0 * Math.PI, 1.5 * Math.PI)
browserCanvasContext.lineTo(borderPoint2.x + SHADOW_OFFSET, borderPoint2.y - params.cornerRadius + SHADOW_OFFSET)
browserCanvasContext.arc(borderPoint2.x + SHADOW_OFFSET, borderPoint2.y + SHADOW_OFFSET, params.cornerRadius, 1.5 * Math.PI, 2.0 * Math.PI)
browserCanvasContext.lineTo(borderPoint3.x + params.cornerRadius + SHADOW_OFFSET, borderPoint3.y + SHADOW_OFFSET)
browserCanvasContext.arc(borderPoint3.x + SHADOW_OFFSET, borderPoint3.y + SHADOW_OFFSET, params.cornerRadius, 0 * Math.PI, 0.5 * Math.PI)
browserCanvasContext.lineTo(borderPoint4.x + SHADOW_OFFSET, borderPoint4.y + params.cornerRadius + SHADOW_OFFSET)
browserCanvasContext.arc(borderPoint4.x + SHADOW_OFFSET, borderPoint4.y + SHADOW_OFFSET, params.cornerRadius, 0.5 * Math.PI, 1.0 * Math.PI)
browserCanvasContext.lineTo(borderPoint1.x - params.cornerRadius + SHADOW_OFFSET, borderPoint1.y + SHADOW_OFFSET)
browserCanvasContext.closePath()
browserCanvasContext.lineWidth = 10
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.BLACK + ', ' + 0.01 + ')'
browserCanvasContext.stroke()
browserCanvasContext.lineWidth = 5
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.BLACK + ', ' + 0.01 + ')'
browserCanvasContext.stroke()
browserCanvasContext.lineWidth = 1
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.BLACK + ', ' + 0.15 + ')'
browserCanvasContext.stroke()
}
/* Background */
browserCanvasContext.beginPath()
browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, params.cornerRadius, 1.0 * Math.PI, 1.5 * Math.PI)
browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - params.cornerRadius)
browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, params.cornerRadius, 1.5 * Math.PI, 2.0 * Math.PI)
browserCanvasContext.lineTo(borderPoint3.x + params.cornerRadius, borderPoint3.y)
browserCanvasContext.arc(borderPoint3.x, borderPoint3.y, params.cornerRadius, 0 * Math.PI, 0.5 * Math.PI)
browserCanvasContext.lineTo(borderPoint4.x, borderPoint4.y + params.cornerRadius)
browserCanvasContext.arc(borderPoint4.x, borderPoint4.y, params.cornerRadius, 0.5 * Math.PI, 1.0 * Math.PI)
browserCanvasContext.lineTo(borderPoint1.x - params.cornerRadius, borderPoint1.y)
browserCanvasContext.closePath()
browserCanvasContext.fillStyle = 'rgba(' + params.backgroundColor + ', ' + params.opacity + ')'
browserCanvasContext.fill()
browserCanvasContext.lineWidth = params.lineWidth
browserCanvasContext.strokeStyle = 'rgba(' + params.borderColor + ', ' + params.opacity + ')'
browserCanvasContext.stroke()
}
function drawLabel(label, xFactor, yFactor, xOffset, yOffset, fontSize, container, fontColor, noFrameX, noFrameY, opacity) {
if (label === undefined) { return }
if (fontColor === undefined) { fontColor = UI_COLOR.WHITE }
let fontOffset = label.length * fontSize * FONT_ASPECT_RATIO + 10
if (opacity === undefined) { opacity = 1 }
let labelPoint = {
x: container.frame.width * xFactor + xOffset - fontOffset / 2,
y: container.frame.height * yFactor + yOffset
}
labelPoint = container.frame.frameThisPoint(labelPoint)
if (noFrameX !== undefined) {
labelPoint.x = noFrameX + xOffset
}
if (noFrameY !== undefined) {
labelPoint.y = noFrameY + yOffset
}
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
browserCanvasContext.fillStyle = 'rgba(' + fontColor + ', ' + opacity + ')'
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
}
function drawIcon(icon, xFactor, yFactor, xOffset, yOffset, imageSize, container) {
if (icon !== undefined) {
if (icon.canDrawIcon === true) {
let imagePosition = {
x: container.frame.width * xFactor + xOffset - imageSize / 2,
y: container.frame.height * yFactor + yOffset - imageSize / 2
}
imagePosition = container.frame.frameThisPoint(imagePosition)
browserCanvasContext.drawImage(
icon, imagePosition.x,
imagePosition.y,
imageSize,
imageSize)
}
}
}
function drawContainerBackground(container, color, opacity, fitFunction) {
let fromPoint = {
x: 0,
y: 0
}
let toPoint = {
x: container.frame.width,
y: container.frame.height
}
fromPoint = transformThisPoint(fromPoint, container)
toPoint = transformThisPoint(toPoint, container)
fromPoint = fitFunction(fromPoint)
toPoint = fitFunction(toPoint)
browserCanvasContext.beginPath()
browserCanvasContext.rect(fromPoint.x, fromPoint.y, toPoint.x - fromPoint.x, toPoint.y - fromPoint.y)
browserCanvasContext.fillStyle = 'rgba(' + color + ', ' + opacity + ')'
browserCanvasContext.closePath()
browserCanvasContext.fill()
}
function printLabel(labelToPrint, x, y, opacity, fontSize, color, center, container, fitFunction, noDecimals, fixedDecimals) {
if (labelToPrint === undefined) { return }
let labelPoint
if (color === undefined) { color = UI_COLOR.DARK }
if (fontSize === undefined) { fontSize = 10 };
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
let label = labelToPrint
if (isNaN(label) === false && label !== '') {
if (fixedDecimals !== true) {
label = dynamicDecimals(labelToPrint)
}
label = label.toLocaleString()
if (noDecimals === true) {
label = Math.trunc(label)
}
}
let xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO
if (center === true) {
labelPoint = {
x: x - xOffset,
y: y
}
} else {
labelPoint = {
x: x,
y: y
}
}
if (container !== undefined) {
labelPoint = container.frame.frameThisPoint(labelPoint)
}
if (fitFunction !== undefined) {
labelPoint = fitFunction(labelPoint)
}
browserCanvasContext.fillStyle = 'rgba(' + color + ', ' + opacity + ')'
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
}
-93
View File
@@ -1,93 +0,0 @@
function asymetricalFolderStructureCloning(
originNode,
destinationNode,
originObjectsArrayPropertyName,
originFoldersArrayPropertyName,
destinationFoldersArrayPropertyName,
clonedObjectType,
destinationFolderType,
originObjectArrayPropertyName,
functionLibraryUiObjectsFromNodes
) {
/*
This function will scan one branch of the workspace, and recreate
a similar structure in some other place, based on the parameters
sent to the function is what types of nodes are going to be mapped
into which other types.
*/
if (originNode === undefined) { return }
if (destinationNode === undefined) { return }
/* Now we go down through all the children of the origin node, recreating at the destination node the same children structure*/
let nodeDefinition = getNodeDefinition(originNode)
if (nodeDefinition === undefined) { return }
if (nodeDefinition.properties !== undefined) {
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
switch (property.name) {
case originObjectsArrayPropertyName: {
let originNodePropertyArray = originNode[property.name]
for (let m = 0; m < originNodePropertyArray.length; m++) {
let originObject = originNodePropertyArray[m]
if (originObjectArrayPropertyName === undefined) {
/*
In this first Use Case, we are going to connect each orgin object clone
to its origin object counter part.
*/
let clonedObject = functionLibraryUiObjectsFromNodes.addUIObject(destinationNode, clonedObjectType)
clonedObject.payload.referenceParent = originObject
} else {
/*
In this second Use Case, we are going to connect an inner object that is
inside the origin object at an array. We recognize we have to do this
because we did receive this array proeprty name.
*/
let originObjectArray = originObject[originObjectArrayPropertyName]
for (let n = 0; n < originObjectArray.length; n++) {
let originObjectArrayItem = originObjectArray[n]
let clonedObject = functionLibraryUiObjectsFromNodes.addUIObject(destinationNode, clonedObjectType)
clonedObject.payload.referenceParent = originObjectArrayItem
}
}
}
break
}
case originFoldersArrayPropertyName: {
let originNodePropertyArray = originNode[property.name]
let destinationNodePropertyArray = destinationNode[destinationFoldersArrayPropertyName]
for (let m = 0; m < originNodePropertyArray.length; m++) {
let originFolder = originNodePropertyArray[m]
let found = false
let destinationFolder
for (let n = 0; n < destinationNodePropertyArray.length; n++) {
destinationFolder = destinationNodePropertyArray[n]
if (originFolder.name === destinationFolder.name) {
found = true
}
}
if (found === false) {
destinationFolder = functionLibraryUiObjectsFromNodes.addUIObject(destinationNode, destinationFolderType)
destinationFolder.name = originFolder.name
}
asymetricalFolderStructureCloning(
originFolder,
destinationFolder,
originObjectsArrayPropertyName,
originFoldersArrayPropertyName,
destinationFoldersArrayPropertyName,
clonedObjectType,
destinationFolderType,
originObjectArrayPropertyName,
functionLibraryUiObjectsFromNodes
)
}
break
}
}
}
}
}
-64
View File
@@ -1,64 +0,0 @@
function getHiriarchyMap(rootNode) {
/*
This function scans a node hiriatchy recursively and creates a Map by Id of all the nodes of it.
*/
let hiriatchyMap = new Map()
evalNode(rootNode)
return hiriatchyMap
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
}
}
}
}
}
}
function getHiriarchyHead(initialNode) {
let headNode
stepBackwards(initialNode)
return headNode
function stepBackwards(node) {
if (node === undefined) {return}
if (node.payload === undefined) {return}
if (node.payload.parentNode === undefined) {
headNode = node
} else {
stepBackwards(node.payload.parentNode)
}
}
}
-24
View File
@@ -1,24 +0,0 @@
function saveFrame(payload, frame) {
payload.frame = {
position: {
x: frame.position.x,
y: frame.position.y
},
width: frame.width,
height: frame.height,
radius: frame.radius
}
}
function loadFrame(payload, frame) {
if (payload.node.savedPayload !== undefined) {
if (payload.node.savedPayload.frame !== undefined) {
frame.position.x = payload.node.savedPayload.frame.position.x
frame.position.y = payload.node.savedPayload.frame.position.y
frame.width = payload.node.savedPayload.frame.width
frame.height = payload.node.savedPayload.frame.height
frame.radius = payload.node.savedPayload.frame.radius
payload.node.savedPayload.frame = undefined
}
}
}
-18
View File
@@ -1,18 +0,0 @@
function saveTutorial(payload, tutorial) {
payload.tutorial = {
status: tutorial.status
}
}
function loadTutorial(payload, tutorial) {
if (payload.tutorial !== undefined) {
tutorial.status = payload.tutorial.status
return
}
if (payload.node.savedPayload !== undefined) {
if (payload.node.savedPayload.tutorial !== undefined) {
tutorial.status = payload.node.savedPayload.tutorial.status
payload.node.savedPayload.tutorial = undefined
}
}
}
-14
View File
@@ -1,14 +0,0 @@
function menuClickOfNodeArray(nodeArray, action, confirm) {
for (let j=0; j < nodeArray.length; j++) {
let node = nodeArray[j]
menuClick(node, action, confirm)
}
}
function menuClick(node, action, confirm) {
let menu = node.payload.uiObject.menu
menu.internalClick(action)
if (confirm === true) {
menu.internalClick(action)
}
}
-88
View File
@@ -1,88 +0,0 @@
function findNodeInNodeMesh(node, nodeType, nodeName, connectedViaPayload, findInChildren, findInParents, findInReferenceParents) {
/*
This function scans a node mesh for a certain node type and
returns the first instance found. Please specify either nodeType
or nodeName.
*/
const MAX_DEPTH = 100
let nodeFound
scanNodeMesh(node, 0)
return nodeFound
function scanNodeMesh(startingNode, depth) {
if (startingNode === undefined) { return }
if (connectedViaPayload === true) {
if (startingNode.payload === undefined) { return }
}
if (nodeFound !== undefined) { return }
if (depth >= MAX_DEPTH) {return}
let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type)
if (nodeDefinition === undefined) { return }
if (nodeType !== undefined) {
if (startingNode.type === nodeType) {
nodeFound = startingNode
return
}
}
if (nodeName !== undefined) {
if (startingNode.name === nodeName) {
nodeFound = startingNode
return
}
}
/* We scan through this node children */
if (findInChildren === true) {
if (nodeDefinition.properties !== undefined) {
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
switch (property.type) {
case 'node': {
scanNodeMesh(startingNode[property.name], depth + 1)
}
break
case 'array': {
let startingNodePropertyArray = startingNode[property.name]
if (startingNodePropertyArray !== undefined) {
for (let m = 0; m < startingNodePropertyArray.length; m++) {
scanNodeMesh(startingNodePropertyArray[m], depth + 1)
}
}
break
}
}
}
}
}
/* We scan parents nodes. */
if (findInParents === true) {
if (connectedViaPayload === true) {
if (startingNode.payload.parentNode !== undefined) {
scanNodeMesh(startingNode.payload.parentNode, depth + 1)
}
} else {
if (startingNode.parentNode !== undefined) {
scanNodeMesh(startingNode.parentNode, depth + 1)
}
}
}
/* We scan reference parents too. */
if (findInReferenceParents === true) {
if (connectedViaPayload === true) {
if (startingNode.payload.referenceParent !== undefined) {
scanNodeMesh(startingNode.payload.referenceParent, depth + 1)
}
} else {
if (startingNode.referenceParent !== undefined) {
scanNodeMesh(startingNode.referenceParent, depth + 1)
}
}
}
}
}
-229
View File
@@ -1,229 +0,0 @@
function isMissingChildren(startingNode, checkNode, checkReferenceParent) {
/*
This functioin scan all the children of a node and returns true or false
depending if the checkNode is a missing children.
*/
if (startingNode === undefined) { return }
if (checkNode === undefined) { return }
let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type)
if (nodeDefinition === undefined) { return }
/* We scan through this node children */
if (nodeDefinition.properties !== undefined) {
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
switch (property.type) {
case 'node': {
let child = startingNode[property.name]
if (child === undefined) { continue }
if (checkReferenceParent !== true) {
if (child.id === checkNode.id) {
return false
}
} else {
if (child.payload !== undefined) {
if (child.payload.referenceParent !== undefined) {
if (child.payload.referenceParent.id === checkNode.id) {
return false
}
}
}
}
}
break
case 'array': {
let startingNodePropertyArray = startingNode[property.name]
if (startingNodePropertyArray !== undefined) {
for (let m = 0; m < startingNodePropertyArray.length; m++) {
let arrayItem = startingNodePropertyArray[m]
if (checkReferenceParent !== true) {
if (arrayItem.id === checkNode.id) {
return false
}
} else {
if (arrayItem.payload !== undefined) {
if (arrayItem.payload.referenceParent !== undefined) {
if (arrayItem.payload.referenceParent.id === checkNode.id) {
return false
}
}
}
}
}
}
break
}
}
}
return true
}
}
function findChildReferencingThisNode(startingNode, checkNode) {
/*
This functioin scan all the children of a node and returns the child
that is referencing the checkNode.
*/
if (startingNode === undefined) { return }
if (checkNode === undefined) { return }
let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type)
if (nodeDefinition === undefined) { return }
/* We scan through this node children */
if (nodeDefinition.properties !== undefined) {
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
switch (property.type) {
case 'node': {
let child = startingNode[property.name]
if (child.payload !== undefined) {
if (child.payload.referenceParent !== undefined) {
if (child.payload.referenceParent.id === checkNode.id) {
return child
}
}
}
}
break
case 'array': {
let startingNodePropertyArray = startingNode[property.name]
if (startingNodePropertyArray !== undefined) {
for (let m = 0; m < startingNodePropertyArray.length; m++) {
let arrayItem = startingNodePropertyArray[m]
if (arrayItem.payload !== undefined) {
if (arrayItem.payload.referenceParent !== undefined) {
if (arrayItem.payload.referenceParent.id === checkNode.id) {
return arrayItem
}
}
}
}
}
break
}
}
}
return true
}
}
function findOrCreateChildWithReference(startingNode, childType, referencedNode, functionLibraryUiObjectsFromNodes) {
/*
This function find the child node of starting node that references
refereced node. If there is none, then it creates a child and stablish
the referecen.
*/
let child
if (isMissingChildren(startingNode, referencedNode, true) === true) {
child = functionLibraryUiObjectsFromNodes.addUIObject(startingNode, childType)
child.payload.referenceParent = referencedNode
} else {
child = findChildReferencingThisNode(startingNode, referencedNode)
}
return child
}
function findAndRecreateChildWithReference(startingNode, childType, referencedNode, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter) {
/*
This function finds the child of the starting node that references
the reference node and if found it deletes it. Existing or not
it creates it again with the child type specified.
*/
let child
child = findChildReferencingThisNode(startingNode, referencedNode)
if (child !== undefined) {
functionLibraryNodeDeleter.deleteUIObject(child, rootNodes)
}
child = functionLibraryUiObjectsFromNodes.addUIObject(startingNode, childType)
child.payload.referenceParent = referencedNode
return child
}
function findChildIndexAtParentNode(startingNode) {
/*
This functioin scan all the children of a node's parent and returns the child
index at the node property array that contains it.
*/
if (startingNode === undefined) { return }
if (startingNode.payload === undefined) { return }
if (startingNode.payload.parentNode === undefined) { return }
let parentNode = startingNode.payload.parentNode
let nodeDefinition = APP_SCHEMA_MAP.get(parentNode.type)
if (nodeDefinition === undefined) { return }
/* We scan through this parent node children */
if (nodeDefinition.properties !== undefined) {
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
switch (property.type) {
case 'node': {
/* We ignore these types of children. */
}
break
case 'array': {
let startingNodePropertyArray = parentNode[property.name]
if (startingNodePropertyArray !== undefined) {
for (let m = 0; m < startingNodePropertyArray.length; m++) {
let arrayItem = startingNodePropertyArray[m]
if (arrayItem.id === startingNode.id) {
return m
}
}
}
break
}
}
}
}
}
function isMissingChildrenByName(startingNode, nodeName) {
/*
This functioin scan all the children of a node and returns true or false
depending if the node has a children with a certain name.
*/
if (startingNode === undefined) { return }
let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type)
if (nodeDefinition === undefined) { return }
/* We scan through this node children */
if (nodeDefinition.properties !== undefined) {
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
switch (property.type) {
case 'node': {
let child = startingNode[property.name]
if (child.name === nodeName) {
return false
}
}
break
case 'array': {
let startingNodePropertyArray = startingNode[property.name]
if (startingNodePropertyArray !== undefined) {
for (let m = 0; m < startingNodePropertyArray.length; m++) {
let arrayItem = startingNodePropertyArray[m]
if (arrayItem.name === nodeName) {
return false
}
}
}
break
}
}
}
return true
}
}
-18
View File
@@ -1,18 +0,0 @@
function savePropertyAtNodeConfig(payload, propertyName, value) {
try {
let config = JSON.parse(payload.node.config)
config[propertyName] = value
payload.node.config = JSON.stringify(config, null, 4)
} catch (err) {
// we ignore errors here since most likely they will be parsing errors.
}
}
function loadPropertyFromNodeConfig(payload, propertyName) {
try {
let config = JSON.parse(payload.node.config)
return config[propertyName]
} catch (err) {
// we ignore errors here since most likely they will be parsing errors.
}
}
+19 -19
View File
@@ -20,12 +20,12 @@ function newVideoRecorder() {
const DISTANCE_BETWEEN_ICONS = 35
const ICON_SIZES = 50
let mousePointerIcon = canvas.designSpace.iconCollection.get('mouse-pointer')
let draggingIcon = canvas.designSpace.iconCollection.get('hand-drag')
let mousePointerIcon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'mouse-pointer')
let draggingIcon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'hand-drag')
let leftClickIcon = canvas.designSpace.iconCollection.get('mouse-left-click')
let rightClickIcon = canvas.designSpace.iconCollection.get('mouse-right-click')
let wheelClickIcon = canvas.designSpace.iconCollection.get('mouse-wheel-click')
let leftClickIcon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'mouse-left-click')
let rightClickIcon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'mouse-right-click')
let wheelClickIcon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'mouse-wheel-click')
let imagePosition
let buttonPressedIcon
@@ -45,10 +45,10 @@ function newVideoRecorder() {
case 'wheel': {
wheelAnimationCounter = 25
if (canvas.mouse.event.delta > 0) {
pointerIcon = canvas.designSpace.iconCollection.get('mouse-wheel-up')
pointerIcon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'mouse-wheel-up')
lastWheelPointerIcon = pointerIcon
} else {
pointerIcon = canvas.designSpace.iconCollection.get('mouse-wheel-down')
pointerIcon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'mouse-wheel-down')
lastWheelPointerIcon = pointerIcon
}
@@ -65,27 +65,27 @@ function newVideoRecorder() {
switch (key.toLowerCase()) {
case 'escape':
{
pointerIcon = canvas.designSpace.iconCollection.get('key-m')
pointerIcon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'key-m')
break
}
case 'm':
{
pointerIcon = canvas.designSpace.iconCollection.get('key-m')
pointerIcon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'key-m')
break
}
case 'a':
{
pointerIcon = canvas.designSpace.iconCollection.get('key-a')
pointerIcon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'key-a')
break
}
case 'r':
{
pointerIcon = canvas.designSpace.iconCollection.get('key-r')
pointerIcon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'key-r')
break
}
case 'c':
{
pointerIcon = canvas.designSpace.iconCollection.get('key-r')
pointerIcon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'key-r')
break
}
}
@@ -139,7 +139,7 @@ function newVideoRecorder() {
drawMousePointer(buttonPressedIcon, imagePosition, ICON_SIZES)
if (canvas.mouse.event.shiftKey === true) {
icon = canvas.designSpace.iconCollection.get('key-shift')
icon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'key-shift')
imagePosition = {
x: canvas.mouse.position.x - DISTANCE_BETWEEN_ICONS * 3,
y: canvas.mouse.position.y + firstRow
@@ -148,7 +148,7 @@ function newVideoRecorder() {
}
if (canvas.mouse.event.ctrlKey === true || canvas.mouse.event.metaKey === true) {
icon = canvas.designSpace.iconCollection.get('key-ctrl')
icon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'key-ctrl')
imagePosition = {
x: canvas.mouse.position.x - DISTANCE_BETWEEN_ICONS * 3,
y: canvas.mouse.position.y + secondRow
@@ -157,7 +157,7 @@ function newVideoRecorder() {
}
if (canvas.mouse.event.altKey === true) {
icon = canvas.designSpace.iconCollection.get('key-alt')
icon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'key-alt')
imagePosition = {
x: canvas.mouse.position.x + DISTANCE_BETWEEN_ICONS * 3 + ICON_SIZES * 0,
y: canvas.mouse.position.y + secondRow
@@ -166,7 +166,7 @@ function newVideoRecorder() {
}
if (canvas.mouse.event.code === 'ArrowUp') {
icon = canvas.designSpace.iconCollection.get('key-up')
icon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'key-up')
imagePosition = {
x: canvas.mouse.position.x - 0,
y: canvas.mouse.position.y + firstRow
@@ -175,7 +175,7 @@ function newVideoRecorder() {
}
if (canvas.mouse.event.code === 'ArrowDown') {
icon = canvas.designSpace.iconCollection.get('key-down')
icon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'key-down')
imagePosition = {
x: canvas.mouse.position.x - 0,
y: canvas.mouse.position.y + secondRow
@@ -184,7 +184,7 @@ function newVideoRecorder() {
}
if (canvas.mouse.event.code === 'ArrowLeft') {
icon = canvas.designSpace.iconCollection.get('key-left')
icon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'key-left')
imagePosition = {
x: canvas.mouse.position.x - DISTANCE_BETWEEN_ICONS * 0 - ICON_SIZES * 1,
y: canvas.mouse.position.y + secondRow
@@ -193,7 +193,7 @@ function newVideoRecorder() {
}
if (canvas.mouse.event.code === 'ArrowRight') {
icon = canvas.designSpace.iconCollection.get('key-right')
icon = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName( 'Superalgos', 'key-right')
imagePosition = {
x: canvas.mouse.position.x + DISTANCE_BETWEEN_ICONS * 0 + ICON_SIZES * 1,
y: canvas.mouse.position.y + secondRow
+4 -4
View File
@@ -45,7 +45,7 @@ function newDailyFiles() {
}
}
function initialize(pDataMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, pDatetime, pTimeFrame, pHost, pPort, pEventsServerClient, callBackFunction) {
function initialize(pMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, pDatetime, pTimeFrame, pHost, pPort, pEventsServerClient, callBackFunction) {
try {
callBackWhenFileReceived = callBackFunction
@@ -69,7 +69,7 @@ function newDailyFiles() {
function getDataRangeFile() {
/* First we will get the Data Range */
fileCloud.getFile(pDataMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, undefined, undefined, undefined, true, undefined, onDataRangeReceived)
fileCloud.getFile(pMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, undefined, undefined, undefined, true, undefined, onDataRangeReceived)
function onDataRangeReceived(err, pFile) {
switch (err.result) {
@@ -109,7 +109,7 @@ function newDailyFiles() {
function getTimeFramesFile() {
/* First we will get the Data Range */
fileCloud.getFile(pDataMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, undefined, undefined, undefined, undefined, true, onTimeFramesReceived)
fileCloud.getFile(pMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, undefined, undefined, undefined, undefined, true, onTimeFramesReceived)
function onTimeFramesReceived(err, pFile) {
switch (err.result) {
@@ -165,7 +165,7 @@ function newDailyFiles() {
let fileCursor = newFileCursor()
fileCursor.eventHandler = thisObject.eventHandler // We share our event handler with each file cursor, so that they can raise events there when files are changed.s
fileCursor.initialize(fileCloud, pDataMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, periodName, periodTime, pDatetime, pTimeFrame, beginDateRange, endDateRange, pEventsServerClient, onInitialized)
fileCursor.initialize(fileCloud, pMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, periodName, periodTime, pDatetime, pTimeFrame, beginDateRange, endDateRange, pEventsServerClient, onInitialized)
function onInitialized(err) {
try {
switch (err.result) {
+7 -7
View File
@@ -21,12 +21,12 @@ function newFileCloud () {
fileStorage = newFileStorage(pHost, pPort)
}
function getFile (pDataMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, pTimeFrames, callBackFunction) {
function getFile (pMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, pTimeFrames, callBackFunction) {
try {
const MAX_RETRIES = 3
getFileRecursively(0, pDataMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, pTimeFrames, callBackFunction)
getFileRecursively(0, pMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, pTimeFrames, callBackFunction)
function getFileRecursively (pRetryCounter, pDataMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, pTimeFrames, callBackFunction) {
function getFileRecursively (pRetryCounter, pMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, pTimeFrames, callBackFunction) {
try {
let fileName
let filePath
@@ -78,7 +78,7 @@ function newFileCloud () {
if (fileName === undefined) {
logger.write('[ERROR] getFile -> getFileRecursively -> Inconsistant data. Check the following: ')
logger.write('[ERROR] getFile -> getFileRecursively -> pDataMine = ' + JSON.stringify(pDataMine))
logger.write('[ERROR] getFile -> getFileRecursively -> pMine = ' + JSON.stringify(pMine))
logger.write('[ERROR] getFile -> getFileRecursively -> pBot = ' + JSON.stringify(pBot))
logger.write('[ERROR] getFile -> getFileRecursively -> pDataset = ' + JSON.stringify(pDataset))
logger.write('[ERROR] getFile -> getFileRecursively -> pExchange = ' + JSON.stringify(pExchange))
@@ -93,8 +93,8 @@ function newFileCloud () {
filePath = filePath.replace('@QuotedAsset', pMarket.quotedAsset)
}
if (pDataMine !== undefined) {
filePath = filePath.replace('@DataMine', pDataMine.config.codeName)
if (pMine !== undefined) {
filePath = filePath.replace('@DataMine', pMine.config.codeName)
}
if (pBot !== undefined) {
@@ -161,7 +161,7 @@ function newFileCloud () {
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> MAX_RETRIES = ' + MAX_RETRIES) }
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> pRetryCounter = ' + pRetryCounter) }
getFileRecursively(pRetryCounter + 1, pDataMine, pBot, pDataset, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction)
getFileRecursively(pRetryCounter + 1, pMine, pBot, pDataset, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction)
return
} else {
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> Could not get this file from storage. ') }
+8 -8
View File
@@ -25,7 +25,7 @@ function newFileCursor() {
let market
let exchange
let fileCloud
let dataMine
let mine
let bot
let session
let product
@@ -53,7 +53,7 @@ function newFileCursor() {
market = undefined
exchange = undefined
fileCloud = undefined
dataMine = undefined
mine = undefined
bot = undefined
session = undefined
product = undefined
@@ -77,7 +77,7 @@ function newFileCursor() {
function initialize(
pFileCloud,
pDataMine,
pMine,
pBot,
pSession,
pProduct,
@@ -96,7 +96,7 @@ function newFileCursor() {
market = pMarket
exchange = pExchange
fileCloud = pFileCloud
dataMine = pDataMine
mine = pMine
bot = pBot
session = pSession
product = pProduct
@@ -108,11 +108,11 @@ function newFileCursor() {
endDateRange = pEndDateRange
eventsServerClient = pEventsServerClient
let key = dataMine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + dataset.config.codeName + '-' + exchange.name + '-' + market.baseAsset + '/' + market.quotedAsset
let key = mine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + dataset.config.codeName + '-' + exchange.name + '-' + market.baseAsset + '/' + market.quotedAsset
let callerId = key + '-' + periodName + newUniqueId()
eventsServerClient.listenToEvent(key, 'Dataset Updated', undefined, callerId, onResponseDataSet, updateFiles)
key = dataMine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + exchange.name + '-' + market.baseAsset + '/' + market.quotedAsset
key = mine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + exchange.name + '-' + market.baseAsset + '/' + market.quotedAsset
callerId = key + '-' + periodName + newUniqueId()
eventsServerClient.listenToEvent(key, 'Data Range Updated', undefined, callerId, onResponseDataRange, updateDataRange)
@@ -168,7 +168,7 @@ function newFileCursor() {
dateString = targetDate.getUTCFullYear() + '-' + pad(targetDate.getUTCMonth() + 1, 2) + '-' + pad(targetDate.getUTCDate(), 2)
fileCloud.getFile(dataMine, bot, session, product, dataset, exchange, market, periodName, targetDate, undefined, undefined, undefined, onFileReceived)
fileCloud.getFile(mine, bot, session, product, dataset, exchange, market, periodName, targetDate, undefined, undefined, undefined, onFileReceived)
function onFileReceived(err, file) {
try {
@@ -468,7 +468,7 @@ function newFileCursor() {
if (thisObject.files.get(dateString) === undefined) {
// We dont reload files we already have.
fileCloud.getFile(dataMine, bot, session, product, dataset, exchange, market, periodName, targetDate, undefined, undefined, undefined, onFileReceived)
fileCloud.getFile(mine, bot, session, product, dataset, exchange, market, periodName, targetDate, undefined, undefined, undefined, onFileReceived)
} else {
controlLoop()
}
+9 -9
View File
@@ -20,7 +20,7 @@ function newFileSequence () {
let files = new Map()
let maxSequence = -1 // This is replaced by the content of the sequence file, which contains an index that starts on zero. In the case that the sequence file is not found the default value is -1 so when you add 1 it gives you the amount of files in the sequence, zero.
let market
let dataMine
let mine
let bot
let session
let dataset
@@ -48,7 +48,7 @@ function newFileSequence () {
files = undefined
maxSequence = undefined
market = undefined
dataMine = undefined
mine = undefined
bot = undefined
session = undefined
dataset = undefined
@@ -62,7 +62,7 @@ function newFileSequence () {
}
function initialize (
pDataMine,
pMine,
pBot,
pSession,
pProduct,
@@ -76,7 +76,7 @@ function newFileSequence () {
try {
exchange = pExchange
market = pMarket
dataMine = pDataMine
mine = pMine
bot = pBot
session = pSession
dataset = pDataset
@@ -88,7 +88,7 @@ function newFileSequence () {
callerId = newUniqueId()
let key = dataMine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + dataset.config.codeName + '-' + exchange.name + '-' + market.baseAsset + '/' + market.quotedAsset
let key = mine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + dataset.config.codeName + '-' + exchange.name + '-' + market.baseAsset + '/' + market.quotedAsset
eventsServerClient.listenToEvent(key, 'Dataset Updated', undefined, callerId, onResponse, updateFiles)
function onResponse (message) {
@@ -97,7 +97,7 @@ function newFileSequence () {
/* First we will get the sequence max number */
fileCloud.getFile(dataMine, bot, session, product, dataset, exchange, market, undefined, undefined, 'Sequence', undefined, undefined, onSequenceFileReceived)
fileCloud.getFile(mine, bot, session, product, dataset, exchange, market, undefined, undefined, 'Sequence', undefined, undefined, onSequenceFileReceived)
function onSequenceFileReceived (err, file) {
try {
@@ -142,7 +142,7 @@ function newFileSequence () {
/* Now we will get the sequence of files */
for (let i = 0; i <= maxSequence; i++) {
fileCloud.getFile(dataMine, bot, session, product, dataset, exchange, market, undefined, undefined, i, undefined, undefined, onFileReceived)
fileCloud.getFile(mine, bot, session, product, dataset, exchange, market, undefined, undefined, i, undefined, undefined, onFileReceived)
function onFileReceived (err, file) {
try {
@@ -207,7 +207,7 @@ function newFileSequence () {
let currentMaxSequence = maxSequence
fileCloud.getFile(dataMine, bot, session, product, dataset, exchange, market, undefined, undefined, 'Sequence', undefined, undefined, onSequenceFileReceived)
fileCloud.getFile(mine, bot, session, product, dataset, exchange, market, undefined, undefined, 'Sequence', undefined, undefined, onSequenceFileReceived)
function onSequenceFileReceived (err, sequenceFile) {
try {
@@ -243,7 +243,7 @@ function newFileSequence () {
/* Now we will get the sequence of files, but in this case only from the currentMaxSequence and above. */
for (let i = currentMaxSequence; i <= maxSequence; i++) {
fileCloud.getFile(dataMine, bot, session, product, dataset, exchange, market, undefined, undefined, i, undefined, undefined, onFileReceived)
fileCloud.getFile(mine, bot, session, product, dataset, exchange, market, undefined, undefined, i, undefined, undefined, onFileReceived)
function onFileReceived (err, file) {
try {
+1 -1
View File
@@ -44,7 +44,7 @@ function newFileStorage(host, port) {
url = folder + filePath
}
callServer(undefined, url, (response, fileContent) => {
callWebServer(undefined, url, (response, fileContent) => {
if (response.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, fileContent)
} else {
+8 -8
View File
@@ -25,7 +25,7 @@ function newMarketFiles() {
let market
let exchange
let dataMine
let mine
let bot
let session
let dataset
@@ -55,7 +55,7 @@ function newMarketFiles() {
market = undefined
exchange = undefined
dataMine = undefined
mine = undefined
bot = undefined
session = undefined
dataset = undefined
@@ -70,7 +70,7 @@ function newMarketFiles() {
}
function initialize(
pDataMine,
pMine,
pBot,
pSession,
pProduct,
@@ -86,7 +86,7 @@ function newMarketFiles() {
exchange = pExchange
market = pMarket
dataMine = pDataMine
mine = pMine
bot = pBot
session = pSession
dataset = pDataset
@@ -108,7 +108,7 @@ function newMarketFiles() {
function getTimeFramesFile() {
/* First we will get the Data Range */
fileCloud.getFile(pDataMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, undefined, undefined, undefined, undefined, true, onTimeFramesReceived)
fileCloud.getFile(pMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, undefined, undefined, undefined, undefined, true, onTimeFramesReceived)
function onTimeFramesReceived(err, pFile) {
switch (err.result) {
@@ -164,7 +164,7 @@ function newMarketFiles() {
}
filesExpected++
fileCloud.getFile(dataMine, bot, session, product, dataset, exchange, market, periodName, undefined, undefined, undefined, undefined, onFileReceived)
fileCloud.getFile(mine, bot, session, product, dataset, exchange, market, periodName, undefined, undefined, undefined, undefined, onFileReceived)
function onFileReceived(err, file) {
try {
@@ -177,7 +177,7 @@ function newMarketFiles() {
}
if (filesLoaded + filesNotLoaded === marketFilesPeriods.length) {
let key = dataMine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + dataset.config.codeName + '-' + exchange.name + '-' + market.baseAsset + '/' + market.quotedAsset
let key = mine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + dataset.config.codeName + '-' + exchange.name + '-' + market.baseAsset + '/' + market.quotedAsset
let callerId = key + '-' + periodName + newUniqueId()
eventsServerClient.listenToEvent(key, 'Dataset Updated', undefined, callerId, onResponse, updateFiles)
@@ -219,7 +219,7 @@ function newMarketFiles() {
if (message.event.timeFrames.includes(periodName) !== true) { continue }
}
}
fileCloud.getFile(dataMine, bot, session, product, dataset, exchange, market, periodName, undefined, undefined, undefined, undefined, onFileReceived)
fileCloud.getFile(mine, bot, session, product, dataset, exchange, market, periodName, undefined, undefined, undefined, undefined, onFileReceived)
function onFileReceived(err, file) {
try {
+3 -3
View File
@@ -17,7 +17,7 @@ function newSingleFile () {
return thisObject
function initialize (
pDataMine,
pMine,
pBot,
pSession,
pProduct,
@@ -30,7 +30,7 @@ function newSingleFile () {
callBackFunction) {
try {
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
if (INFO_LOG === true) { logger.write('[INFO] initialize -> key = ' + pDataMine.config.codeName + '-' + pBot.config.codeName + '-' + pProduct.config.codeName) }
if (INFO_LOG === true) { logger.write('[INFO] initialize -> key = ' + pMine.config.codeName + '-' + pBot.config.codeName + '-' + pProduct.config.codeName) }
let exchange = pExchange
@@ -39,7 +39,7 @@ function newSingleFile () {
/* Now we will get the file */
fileCloud.getFile(pDataMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, undefined, undefined, undefined, undefined, undefined, onFileReceived)
fileCloud.getFile(pMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, undefined, undefined, undefined, undefined, undefined, onFileReceived)
function onFileReceived (err, pFile) {
try {
@@ -0,0 +1,37 @@
function newEthereumActionSwitch() {
let thisObject = {
executeAction: executeAction,
initialize: initialize,
finalize: finalize
}
let functionLibraryGeth = newGeth()
return thisObject
function finalize() {
functionLibraryGeth = undefined
}
function initialize() {
/* Nothing to initialize since a Function Library does not hold any state. */
}
async function executeAction(action) {
switch (action.name) {
case 'Install Geth': {
functionLibraryGeth.install(action.node)
break
}
case 'Run Geth': {
functionLibraryGeth.run(action.node)
break
}
case 'Stop Geth': {
functionLibraryGeth.stop(action.node)
break
}
}
}
}
@@ -0,0 +1,21 @@
function newGeth() {
thisObject = {
install: install,
run: run,
stop: stop
}
return thisObject
function install(node) {
callWebServer('ExecuteTerminalCommand/dir')
}
function run(node) {
}
function stop(node) {
}
}
@@ -0,0 +1,18 @@
function newEthereumGlobalsChainIds() {
thisObject = {
chainNameById: chainNameById
}
return thisObject
function chainNameById(chainId) {
switch(chainId) {
case 1: return 'Ethereum Mainnet'
case 3: return 'Ethereum Ropsten'
case 4: return 'Ethereum Rinkeby'
case 42: return 'Ethereum Kovan'
case 61: return 'Ethereum Classic Mainnet'
case 62: return 'Ethereum Classic Morden'
default: return 'Unknown Network'
}
}
}
@@ -0,0 +1 @@
{"type":"Workspace","name":"Ethereum Integration Demo","rootNodes":[{"type":"Network","name":"My Network","project":"Superalgos","networkNodes":[{"type":"Network Node","name":"My Computer","config":"{ \n\"host\": \"localhost\", \n\"webPort\": \"34248\", \n\"webSocketsPort\": \"18041\"\n}","project":"Superalgos","dataMining":{"type":"Data Mining","name":"New Data Mining","project":"Superalgos","exchangeDataTasks":[{"type":"Exchange Data Tasks","name":"Binance","project":"Superalgos","marketDataTasks":[{"type":"Market Data Tasks","name":"Binance BTC/USDT","project":"Superalgos","dataMineTasks":[{"type":"Data Mine Tasks","name":"Masters","project":"Superalgos","taskManagers":[{"type":"Task Manager","name":"Masters","project":"Superalgos","tasks":[{"type":"Task","name":"Exchange Raw Data","project":"Superalgos","bot":{"type":"Sensor Bot Instance","name":"Exchange Raw Data","config":"{ \n\"startDate\": \"2020-01-01\"\n}","project":"Superalgos","processes":[{"type":"Sensor Process Instance","name":"Exchange Raw Data Historic-OHLCVs","project":"Superalgos","id":"da7e6d2a-76d5-431c-ba48-aa98ebd2a907","savedPayload":{"position":{"x":23623.030015561097,"y":29888.16403283887},"targetPosition":{"x":23918.47234146476,"y":29836.06957953879},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process Definition","name":"Historic-OHLCVs","id":"5eb11d6a-022e-4f60-97c4-d6cf90b249dc"}}}],"id":"f9daa393-935e-4a9d-bdc5-706d97ac5530","savedPayload":{"position":{"x":23918.47234146476,"y":29836.06957953879},"targetPosition":{"x":24213.914667368423,"y":29783.97512623871},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"5827edbc-89f8-495a-953a-a568f2fca44e","savedPayload":{"position":{"x":24213.914667368423,"y":29783.97512623871},"targetPosition":{"x":24509.356993272086,"y":29731.88067293863},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Task","name":"Candles Volumes","project":"Superalgos","bot":{"type":"Indicator Bot Instance","name":"Candles Volumes","config":"{}","project":"Superalgos","processes":[{"type":"Indicator Process Instance","name":"Candles Volumes Multi-Period-Market","project":"Superalgos","id":"243ecbf4-cb69-42e2-9acb-b03c7c481b79","savedPayload":{"position":{"x":23619.613932037235,"y":29653.83848916277},"targetPosition":{"x":23918.47234146476,"y":29627.69176633847},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process Definition","name":"Multi-Period-Market","id":"9f683143-a33f-42c1-9fa8-c601f01ee4e1"}}},{"type":"Indicator Process Instance","name":"Candles Volumes Multi-Period-Daily","project":"Superalgos","id":"c90cb0e5-3e49-40ba-b919-38b0e5f7fcee","savedPayload":{"position":{"x":23646.580005353764,"y":29500.906287816262},"targetPosition":{"x":23918.47234146476,"y":29627.69176633847},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process Definition","name":"Multi-Period-Daily","id":"980ceb1d-7be6-454f-90d9-01ba1fd4a65d"}}}],"id":"ac31f04b-4d79-4e18-9262-1a9a933b6156","savedPayload":{"position":{"x":23918.47234146476,"y":29627.69176633847},"targetPosition":{"x":24213.914667368423,"y":29679.78621963855},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"46c3f665-a9e2-46dc-b569-2a928d2067af","savedPayload":{"position":{"x":24213.914667368423,"y":29679.78621963855},"targetPosition":{"x":24509.356993272086,"y":29731.88067293863},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Task","name":"Bollinger Bands","project":"Superalgos","bot":{"type":"Indicator Bot Instance","name":"Bollinger Bands","config":"{}","project":"Superalgos","processes":[{"type":"Indicator Process Instance","name":"Bollinger Bands Multi-Period-Market","project":"Superalgos","id":"12498614-646b-411c-9c82-747bacb8d7a6","savedPayload":{"position":{"x":23699.9640031147,"y":29354.234959407873},"targetPosition":{"x":23989.74175100142,"y":29431.88067293863},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process Definition","name":"Multi-Period-Market","id":"941a0543-0cc0-4a5d-a782-728d2835c100"}}},{"typeLine truncated
@@ -0,0 +1,766 @@
[
{
"type": "Ethereum Project",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Blockchain",
"relatedUiObject": "Ethereum Blockchain",
"actionFunction": "payload.executeAction"
},
{
"action": "Add UI Object",
"label": "Add Decentralized Application",
"relatedUiObject": "Ethereum Decentralized Application",
"actionFunction": "payload.executeAction"
},
{
"action": "Add UI Object",
"label": "Add Token Definitions",
"relatedUiObject": "Ethereum Token Definitions",
"actionFunction": "payload.executeAction"
},
{
"action": "Add UI Object",
"label": "Add Wallet",
"relatedUiObject": "Ethereum Wallet",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"actionFunction": "payload.executeAction",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete"
}
],
"isProjectHead": true,
"isTitleAllwaysVisible": false,
"addLeftIcons": true,
"isPinned": true,
"positionLocked": true,
"icon": "ethereum"
},
{
"type": "Ethereum Wallet",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Network Reference",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "networkReference",
"relatedUiObject": "Network Reference",
"actionFunction": "payload.executeAction"
},
{
"action": "Add UI Object",
"label": "Add Wallet Keys",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "walletKeys",
"relatedUiObject": "Wallet Keys",
"actionFunction": "payload.executeAction"
},
{
"action": "Add UI Object",
"label": "Add Wallet Account",
"relatedUiObject": "Wallet Account",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"isHierarchyHead": true,
"addLeftIcons": true,
"level": 0,
"properties": [
{
"name": "networkReference",
"type": "node",
"childType": "Network Reference",
"autoAdd": true
},
{
"name": "walletKeys",
"type": "node",
"childType": "Wallet Keys",
"autoAdd": true
},
{
"name": "walletAccount",
"type": "array",
"childType": "Wallet Account"
}
],
"icon": "ethereum"
},
{
"type": "Network Reference",
"menuItems": [
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"title": [
"Use Reference Parent"
],
"referenceAttachesTo": {
"compatibleTypes": "->Blockchain Network->"
},
"addLeftIcons": true,
"level": 3,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Wallet->"
},
"propertyNameAtParent": "networkReference",
"icon": "ethereum"
},
{
"type": "Wallet Keys",
"menuItems": [
{
"action": "Configure",
"label": "Configure",
"iconPathOn": "configuration",
"iconPathOff": "configuration",
"dontShowAtFullscreen": true,
"actionFunction": "uiObject.configEditor.activate"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"editors": {
"config": true
},
"initialValues": {
"config": "{ \n\"privateKey\": \"\", \n\"publicKey\": \"\"\n}"
},
"addLeftIcons": true,
"level": 3,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Wallet->"
},
"propertyNameAtParent": "walletKeys",
"isPersonalData": true,
"icon": "ethereum"
},
{
"type": "Wallet Account",
"menuItems": [
{
"action": "Configure",
"label": "Configure",
"iconPathOn": "configuration",
"iconPathOff": "configuration",
"dontShowAtFullscreen": true,
"actionFunction": "uiObject.configEditor.activate"
},
{
"action": "Add UI Object",
"label": "Add ETH Balance",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "ethBalance",
"relatedUiObject": "ETH Balance",
"actionFunction": "payload.executeAction"
},
{
"action": "Add UI Object",
"label": "Add Token Balance",
"relatedUiObject": "Token Balance",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"editors": {
"config": true
},
"initialValues": {
"config": "{ \n\"value\": \"\"\n}"
},
"addLeftIcons": true,
"level": 3,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Wallet->"
},
"propertyNameAtParent": "walletAccount",
"properties": [
{
"name": "ethBalance",
"type": "node",
"childType": "ETH Balance"
},
{
"name": "tokenBalance",
"type": "array",
"childType": "Token Balance"
}
],
"icon": "ethereum"
},
{
"type": "ETH Balance",
"menuItems": [
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"addLeftIcons": true,
"level": 4,
"chainAttachesTo": {
"compatibleTypes": "->Wallet Account->"
},
"propertyNameAtParent": "ethBalance",
"icon": "ethereum"
},
{
"type": "Token Balance",
"menuItems": [
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"title": [
"Use Reference Parent"
],
"addLeftIcons": true,
"level": 4,
"referenceAttachesTo": {
"compatibleTypes": "->Ethereum Token->"
},
"chainAttachesTo": {
"compatibleTypes": "->Wallet Account->"
},
"propertyNameAtParent": "tokenBalance",
"icon": "ethereum"
},
{
"type": "Ethereum Token Definitions",
"menuItems": [
{
"action": "Add Missing Children",
"label": "Add Missing Children",
"relatedUiObject": "Ethereum Token Definitions",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"isHierarchyHead": true,
"addLeftIcons": true,
"level": 0,
"properties": [
{
"name": "erc-20TokenType",
"type": "node",
"childType": "ERC-20 Token Type"
},
{
"name": "erc-223TokenType",
"type": "node",
"childType": "ERC-223 Token Type"
},
{
"name": "erc-721TokenType",
"type": "node",
"childType": "ERC-721 Token Type"
},
{
"name": "erc-777TokenType",
"type": "node",
"childType": "ERC-777 Token Type"
}
],
"icon": "ethereum"
},
{
"type": "ERC-20 Token Type",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Token Definition",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "ethereumToken",
"relatedUiObject": "Ethereum Token",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"addLeftIcons": true,
"level": 1,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Token Definitions->"
},
"propertyNameAtParent": "erc-20TokenType",
"properties": [
{
"name": "ethereumToken",
"type": "node",
"childType": "Ethereum Token"
}
],
"icon": "ethereum"
},
{
"type": "ERC-223 Token Type",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Token Definition",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "ethereumToken",
"relatedUiObject": "Ethereum Token",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"addLeftIcons": true,
"level": 1,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Token Definitions->"
},
"propertyNameAtParent": "erc-223TokenType",
"properties": [
{
"name": "ethereumToken",
"type": "node",
"childType": "Ethereum Token"
}
],
"icon": "ethereum"
},
{
"type": "ERC-721 Token Type",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Token Definition",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "ethereumToken",
"relatedUiObject": "Ethereum Token",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"addLeftIcons": true,
"level": 1,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Token Definitions->"
},
"propertyNameAtParent": "erc-721TokenType",
"properties": [
{
"name": "ethereumToken",
"type": "node",
"childType": "Ethereum Token"
}
],
"icon": "ethereum"
},
{
"type": "ERC-777 Token Type",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Token Definition",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "ethereumToken",
"relatedUiObject": "Ethereum Token",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"addLeftIcons": true,
"level": 1,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Token Definitions->"
},
"propertyNameAtParent": "erc-777TokenType",
"properties": [
{
"name": "ethereumToken",
"type": "node",
"childType": "Ethereum Token"
}
],
"icon": "ethereum"
},
{
"type": "Ethereum Token",
"menuItems": [
{
"action": "Configure",
"label": "Configure",
"iconPathOn": "configuration",
"iconPathOff": "configuration",
"dontShowAtFullscreen": true,
"actionFunction": "uiObject.configEditor.activate"
},
{
"action": "Add UI Object",
"label": "Add Smart Contract",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "smartContract",
"relatedUiObject": "Smart Contract",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"editors": {
"config": true
},
"initialValues": {
"config": "{ \n\"codeName\": \"\"\n}"
},
"addLeftIcons": true,
"level": 2,
"chainAttachesTo": {
"compatibleTypes": "->ERC-20 Token Type->ERC-223 Token Type->ERC-721 Token Type->ERC-777 Token Type->"
},
"propertyNameAtParent": "ethereumToken",
"properties": [
{
"name": "smartContracts",
"type": "node",
"childType": "Smart Contract"
}
],
"icon": "ethereum"
},
{
"type": "Ethereum Blockchain",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Blockchain Network",
"relatedUiObject": "Blockchain Network",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"isHierarchyHead": true,
"addLeftIcons": true,
"level": 0,
"properties": [
{
"name": "blockchainNetworks",
"type": "array",
"childType": "Blockchain Network"
}
],
"icon": "ethereum"
},
{
"type": "Blockchain Network",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Network Client",
"relatedUiObject": "Network Client",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"addLeftIcons": true,
"level": 1,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Blockchain->"
},
"propertyNameAtParent": "blockchainNetworks",
"properties": [
{
"name": "networkClients",
"type": "array",
"childType": "Network Client"
}
],
"icon": "ethereum"
},
{
"type": "Network Client",
"menuItems": [
{
"action": "Configure",
"label": "Configure",
"iconPathOn": "configuration",
"iconPathOff": "configuration",
"dontShowAtFullscreen": true,
"actionFunction": "uiObject.configEditor.activate"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"editors": {
"config": true
},
"initialValues": {
"config": "{ \n\"host\": \"localhost\", \n\"httpPort\": \"8545\"\n}"
},
"addLeftIcons": true,
"level": 1,
"chainAttachesTo": {
"compatibleTypes": "->Blockchain Network->"
},
"propertyNameAtParent": "networkClients",
"icon": "ethereum"
},
{
"type": "Ethereum Decentralized Application",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Smart Contract",
"relatedUiObject": "Smart Contract",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"isHierarchyHead": true,
"addLeftIcons": true,
"level": 0,
"properties": [
{
"name": "smartContracts",
"type": "array",
"childType": "Smart Contract"
}
],
"icon": "ethereum"
},
{
"type": "Smart Contract",
"menuItems": [
{
"action": "Add UI Object",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "smartContractAccount",
"label": "Add Smart Contract Account",
"relatedUiObject": "Smart Contract Account",
"actionFunction": "payload.executeAction"
},
{
"action": "Add UI Object",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "solidityCode",
"label": "Add Solidity Code",
"relatedUiObject": "Solidity Code",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"chainAttachesTo": {
"compatibleTypes": "->Token Definition->Ethereum Decentralized Application->"
},
"propertyNameAtParent": "smartContracts",
"addLeftIcons": true,
"level": 1,
"properties": [
{
"name": "smartContractAccount",
"type": "node",
"childType": "Smart Contract Account"
},
{
"name": "solidityCode",
"type": "node",
"childType": "Solidity Code"
}
],
"icon": "ethereum"
},
{
"type": "Smart Contract Account",
"menuItems": [
{
"action": "Configure",
"label": "Configure",
"iconPathOn": "configuration",
"iconPathOff": "configuration",
"dontShowAtFullscreen": true,
"actionFunction": "uiObject.configEditor.activate"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"editors": {
"config": true
},
"initialValues": {
"config": "{ \n\"value\": \"\"\n}"
},
"addLeftIcons": true,
"level": 3,
"chainAttachesTo": {
"compatibleTypes": "->Smart Contract->"
},
"propertyNameAtParent": "smartContractAccount",
"icon": "ethereum"
},
{
"type": "Solidity Code",
"menuItems": [
{
"action": "Edit",
"actionFunction": "uiObject.codeEditor.activate",
"label": "Edit",
"iconPathOn": "ethereum",
"iconPathOff": "ethereum"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"editors": {
"code": true
},
"initialValues": {
"code": "// Type your smart contract code here."
},
"chainAttachesTo": {
"compatibleTypes": "->Smart Contract->"
},
"propertyNameAtParent": "solidityCode",
"addLeftIcons": true,
"level": 2,
"icon": "ethereum"
}
]
@@ -0,0 +1,2 @@
[
]
@@ -0,0 +1,2 @@
[
]
@@ -0,0 +1,150 @@
function newEthereumBlockchainSpace() {
const MODULE_NAME = 'Blockchain Space'
let thisObject = {
container: undefined,
physics: physics,
draw: draw,
getContainer: getContainer,
finalize: finalize,
initialize: initialize
}
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
let clientMap = new Map()
let lastTryToReconnectDatetime
return thisObject
function finalize() {
thisObject.container.finalize()
thisObject.container = undefined
clientMap = undefined
}
function initialize() {
}
function physics() {
/* We will query the node only every 3 seconds */
if (lastTryToReconnectDatetime === undefined) {
connectingPhysics()
lastTryToReconnectDatetime = (new Date()).valueOf()
} else {
let now = (new Date()).valueOf()
if (now - lastTryToReconnectDatetime > 3000) {
connectingPhysics()
lastTryToReconnectDatetime = now
}
}
}
async function connectingPhysics() {
try {
if (UI.projects.superalgos.spaces.designSpace.workspace === undefined) { return }
let blockchain = UI.projects.superalgos.spaces.designSpace.workspace.getHierarchyHeadsByType('Ethereum Blockchain')
if (blockchain === undefined) { return }
for (let i = 0; i < blockchain.blockchainNetworks.length; i++) {
let blockchainNetwork = blockchain.blockchainNetworks[i]
for (let j = 0; j < blockchainNetwork.networkClients.length; j++) {
let networkClient = blockchainNetwork.networkClients[j]
/*
We will check now if this network client is already at the networkClientsMap,
if not, we will add it and stablish the connection to the ethereum node.
*/
let client = clientMap.get(networkClient.id)
if (client === undefined) {
client = {}
let config = JSON.parse(networkClient.config)
if (config.host === undefined) {
networkClient.payload.uiObject.setErrorMessage('Property host not defined at node config.')
continue
}
if (config.httpPort === undefined) {
networkClient.payload.uiObject.setErrorMessage('Property httpPort not defined at node config.')
continue
}
try {
client.web3 = new window.Web3('http://' + config.host + ':' + config.httpPort + '');
if (client.web3.currentProvider.currentProvider === false) {
networkClient.payload.uiObject.setErrorMessage('Can not connect to this client.')
return
}
client.chainId = await client.web3.eth.getChainId()
clientMap.set(networkClient.id, client)
setStatus()
} catch (err) {
networkClient.payload.uiObject.setErrorMessage('Error connecting to this client: ' + err.message)
}
} else {
setStatus()
}
async function setStatus() {
networkClient.payload.uiObject.resetErrorMessage()
try {
client.isSyncing = await client.web3.eth.isSyncing()
client.chainId = await client.web3.eth.getChainId()
} catch {
networkClient.payload.uiObject.resetStatus()
networkClient.payload.uiObject.setErrorMessage('Connection to client lost.')
clientMap.delete(networkClient.id)
return
}
client.networkName = UI.projects.ethereum.globals.chainIds.chainNameById(client.chainId)
if (client.isSyncing === false) {
networkClient.payload.uiObject.setStatus('Client is looking for peers...')
return
}
/* If it is not syncing, then we have the current block and the highets block too */
let percentage = (client.isSyncing.currentBlock * 100 / client.isSyncing.highestBlock).toFixed(4)
let extraStatus = ''
if (client.isSyncing.highestBlock - client.isSyncing.currentBlock < 100) {
extraStatus = 'Block Download Finished. Downloading Trie Data Structure.'
} else {
extraStatus = 'Block Download Phase.'
networkClient.payload.uiObject.setPercentage(percentage)
}
networkClient.payload.uiObject.valueAtAngle = false
networkClient.payload.uiObject.setValue('Block ' + client.isSyncing.currentBlock + ' from ' + client.isSyncing.highestBlock + '. State ' + client.isSyncing.pulledStates + ' from ' + client.isSyncing.knownStates)
if (client.isSyncing.currentBlock !== client.isSyncing.highestBlock) {
networkClient.payload.uiObject.setStatus('Connected via http. Client is Syncing... ' + extraStatus)
} else {
networkClient.payload.uiObject.setStatus('Connected to ' + client.networkName + ' via http. ')
}
}
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] physics -> err = ' + err.stack) }
}
}
function getContainer(point) {
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
thisObject.container.space = MODULE_NAME
return thisObject.container
} else {
return undefined
}
}
function draw() {
}
}
@@ -0,0 +1,45 @@
function newEthereumWalletSpace() {
const MODULE_NAME = 'Wallet Space'
let thisObject = {
container: undefined,
physics: physics,
draw: draw,
getContainer: getContainer,
finalize: finalize,
initialize: initialize
}
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
return thisObject
function finalize() {
thisObject.container.finalize()
thisObject.container = undefined
}
function initialize() {
}
function physics() {
}
function getContainer(point) {
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
thisObject.container.space = MODULE_NAME
return thisObject.container
} else {
return undefined
}
}
function draw() {
}
}
Whitespace-only changes.
+258
View File
@@ -0,0 +1,258 @@
[
{
"name": "Superalgos",
"propertyName": "superalgos",
"globals": [
{
"name": "Docs",
"propertyName": "docs",
"functionName": "newSuperalgosGlobalsDocs"
},
{
"name": "Zoom",
"propertyName": "zoom",
"functionName": "newSuperalgosGlobalsZoom"
}
],
"utilities": [
{
"name": "Branches",
"propertyName": "branches",
"functionName": "newSuperalgosUtilitiesBranches"
},
{
"name": "Clipboard",
"propertyName": "clipboard",
"functionName": "newSuperalgosUtilitiesClipboard"
},
{
"name": "Coordinate Transformations",
"propertyName": "coordinateTransformations",
"functionName": "newSuperalgosUtilitiesCoordinateTransformations"
},
{
"name": "Date Rate Transformations",
"propertyName": "dateRateTransformations",
"functionName": "newSuperalgosUtilitiesDateRateTransformations"
},
{
"name": "Dates",
"propertyName": "dates",
"functionName": "newSuperalgosUtilitiesDates"
},
{
"name": "Download",
"propertyName": "download",
"functionName": "newSuperalgosUtilitiesDownload"
},
{
"name": "Draw Print",
"propertyName": "drawPrint",
"functionName": "newSuperalgosUtilitiesDrawPrint"
},
{
"name": "Hierarchy",
"propertyName": "hierarchy",
"functionName": "newSuperalgosUtilitiesHierarchy"
},
{
"name": "Load Save Frame",
"propertyName": "loadSaveFrame",
"functionName": "newSuperalgosUtilitiesLoadSaveFrame"
},
{
"name": "Tutorial",
"propertyName": "tutorial",
"functionName": "newSuperalgosUtilitiesTutorial"
},
{
"name": "Menu",
"propertyName": "menu",
"functionName": "newSuperalgosUtilitiesMenu"
},
{
"name": "Meshes",
"propertyName": "meshes",
"functionName": "newSuperalgosUtilitiesMeshes"
},
{
"name": "Children",
"propertyName": "children",
"functionName": "newSuperalgosUtilitiesNodeChildren"
},
{
"name": "Node Config",
"propertyName": "nodeConfig",
"functionName": "newSuperalgosUtilitiesNodeConfig"
},
{
"name": "Folders",
"propertyName": "folders",
"functionName": "newSuperalgosUtilitiesFolders"
}
],
"spaces": [
{
"name": "Floating Space",
"folderName": "Floating-Space",
"propertyName": "floatingSpace",
"functionName": "newSuperalgosFloatingSpace",
"initializationIndex": 0,
"animationPhysicsIndex": 1,
"animationDrawIndex": 0,
"onMouseWheelIndex": 6,
"onMouseOverIndex": 8,
"onMouseClickIndex": 8,
"onMouseDownIndex": 8
},
{
"name": "Top Space",
"folderName": "Top-Space",
"propertyName": "topSpace",
"functionName": "newSuperalgosTopSpace",
"initializationIndex": 1,
"animationPhysicsIndex": 7,
"animationDrawIndex": 6,
"onMouseOverIndex": 4,
"onMouseClickIndex": 4,
"onMouseDownIndex": 4
},
{
"name": "Cockpit Space",
"folderName": "Cocksit-Space",
"propertyName": "cockpitSpace",
"functionName": "newSuperalgosCockpitSpace",
"initializationIndex": 2,
"animationPhysicsIndex": 0,
"animationDrawIndex": 7,
"onMouseWheelIndex": 4,
"onMouseOverIndex": 5,
"onMouseClickIndex": 5,
"onMouseDownIndex": 5
},
{
"name": "Design Space",
"folderName": "Design-Space",
"propertyName": "designSpace",
"functionName": "newSuperalgosDesignSpace",
"initializationIndex": 3,
"animationPhysicsIndex": 3,
"animationDrawIndex": 2,
"onMouseWheelIndex": 0,
"onMouseOverIndex": 3,
"onMouseClickIndex": 3,
"onMouseDownIndex": 3
},
{
"name": "Panel Space",
"folderName": "Panel-Space",
"propertyName": "panelSpace",
"functionName": "newSuperalgosPanelSpace",
"initializationIndex": 4,
"animationPhysicsIndex": 4,
"animationDrawIndex": 3,
"onMouseWheelIndex": 3,
"onMouseOverIndex": 6,
"onMouseClickIndex": 6,
"onMouseDownIndex": 6
},
{
"name": "Charting Space",
"folderName": "Charting-Space",
"propertyName": "chartingSpace",
"functionName": "newSuperalgosChartingSpace",
"initializationIndex": 5,
"animationPhysicsIndex": 2,
"animationDrawIndex": 1,
"onMouseWheelIndex": 5,
"onMouseOverIndex": 7,
"onMouseClickIndex": 7,
"onMouseDownIndex": 7
},
{
"name": "Side Space",
"folderName": "Floating-Space",
"propertyName": "sideSpace",
"functionName": "newSuperalgosSideSpace",
"initializationIndex": 6,
"animationPhysicsIndex": 8,
"animationDrawIndex": 8,
"onMouseWheelIndex": 2,
"onMouseOverIndex": 2,
"onMouseClickIndex": 2,
"onMouseDownIndex": 2
},
{
"name": "Doc Space",
"folderName": "Doc-Space",
"propertyName": "docSpace",
"functionName": "newSuperalgosDocSpace",
"initializationIndex": 7,
"animationPhysicsIndex": 5,
"animationDrawIndex": 4,
"onMouseWheelIndex": 1,
"onMouseOverIndex": 1,
"onMouseClickIndex": 1,
"onMouseDownIndex": 1
},
{
"name": "Chat Space",
"folderName": "Chat-Space",
"propertyName": "chatSpace",
"functionName": "newSuperalgosChatSpace"
},
{
"name": "Tutorial Space",
"folderName": "Tutorial-Space",
"propertyName": "tutorialSpace",
"functionName": "newSuperalgosTutorialSpace",
"initializationIndex": 8,
"animationPhysicsIndex": 6,
"animationDrawIndex": 5,
"onMouseWheelIndex": 0,
"onMouseOverIndex": 0,
"onMouseClickIndex": 0,
"onMouseDownIndex": 0
}
]
},
{
"name": "Ethereum",
"propertyName": "ethereum",
"globals": [
{
"name": "ChainIds",
"propertyName": "chainIds",
"functionName": "newEthereumGlobalsChainIds"
}
],
"spaces": [
{
"name": "Blockchain Space",
"folderName": "Blockchain-Space",
"propertyName": "blockchainSpace",
"functionName": "newEthereumBlockchainSpace",
"initializationIndex": 0,
"animationPhysicsIndex": 0,
"animationDrawIndex": 0,
"onMouseWheelIndex": 0,
"onMouseOverIndex": 0,
"onMouseClickIndex": 0,
"onMouseDownIndex": 0
},
{
"name": "Wallet Space",
"folderName": "Wallet-Space",
"propertyName": "walletSpace",
"functionName": "newEthereumWalletSpace",
"initializationIndex": 1,
"animationPhysicsIndex": 1,
"animationDrawIndex": 1,
"onMouseWheelIndex": 1,
"onMouseOverIndex": 1,
"onMouseClickIndex": 1,
"onMouseDownIndex": 1
}
]
}
]
@@ -0,0 +1,661 @@
function newSuperalgosActionSwitch() {
let thisObject = {
executeAction: executeAction,
initialize: initialize,
finalize: finalize
}
let functionLibraryReferenceAttachDetach = newReferenceAttachDetach()
let functionLibraryChainAttachDetach = newChainAttachDetach()
let functionLibraryNodeDeleter = newNodeDeleter()
let functionLibraryUiObjectsFromNodes = newUiObjectsFromNodes()
let functionLibraryProtocolNode = newProtocolNode()
let functionLibraryNodeCloning = newNodeCloning()
let functionLibraryShortcutKeys = newShortcutKeys()
let functionLibraryOnFocus = newOnFocus()
let functionLibrarySuperScripts = newSuperScriptsFunctions()
let functionLibraryWebhookFunctions = newWebhookFunctions()
let functionLibraryDependenciesFilter = newDependenciesFilter()
let functionLibraryNodePath = newNodePath()
let functionLibraryTaskFunctions = newTaskFunctions()
let functionLibraryTradingSessionFunctions = newTradingSessionFunctions()
let functionLibraryLearningSessionFunctions = newLearningSessionFunctions()
let functionLibraryCryptoEcosystemFunctions = newCryptoEcosystemFunctions()
let functionLibraryMineFunctions = newMineFunctions()
let functionLibraryDataStorageFunctions = newDataStorageFunctions()
let functionLibraryChartingSpaceFunctions = newChartingSpaceFunctions()
let functionLibraryPluginsFunctions = newPluginsFunctions()
let functionLibraryWorkspaceFunctions = newWorkspaceFunctions()
return thisObject
function finalize() {
functionLibraryReferenceAttachDetach = undefined
functionLibraryChainAttachDetach = undefined
functionLibraryNodeDeleter = undefined
functionLibraryUiObjectsFromNodes = undefined
functionLibraryProtocolNode = undefined
functionLibraryNodeCloning = undefined
functionLibraryShortcutKeys = undefined
functionLibraryOnFocus = undefined
functionLibrarySuperScripts = undefined
functionLibraryWebhookFunctions = undefined
functionLibraryDependenciesFilter = undefined
functionLibraryNodePath = undefined
functionLibraryTaskFunctions = undefined
functionLibraryTradingSessionFunctions = undefined
functionLibraryLearningSessionFunctions = undefined
functionLibraryCryptoEcosystemFunctions = undefined
functionLibraryMineFunctions = undefined
functionLibraryDataStorageFunctions = undefined
functionLibraryChartingSpaceFunctions = undefined
functionLibraryPluginsFunctions = undefined
functionLibraryWorkspaceFunctions = undefined
}
function initialize() {
/* Nothing to initialize since a Function Library does not hold any state. */
}
async function executeAction(action) {
switch (action.name) {
case 'Get Node On Focus': {
return functionLibraryOnFocus.getNodeThatIsOnFocus(action.node)
}
case 'Get Node By Shortcut Key': {
return functionLibraryShortcutKeys.getNodeByShortcutKey(action.node, action.extraParameter)
}
case 'Get Node Data Structure': {
return functionLibraryProtocolNode.getProtocolNode(action.node, action.extraParameter, false, true, true, true)
}
case 'Create UI Object': {
functionLibraryUiObjectsFromNodes.createUiObjectFromNode(action.node, undefined, undefined, action.extraParameter)
}
break
case 'Connect Children to Reference Parents': {
functionLibraryUiObjectsFromNodes.tryToConnectChildrenWithReferenceParents()
}
break
case 'Get Node By Id': {
return functionLibraryUiObjectsFromNodes.getNodeById(action.relatedNodeId)
}
case 'Syncronize Tasks': {
functionLibraryUiObjectsFromNodes.syncronizeTasksFoundAtWorkspaceWithBackEnd(functionLibraryTaskFunctions)
}
break
case 'Syncronize Trading Sessions': {
functionLibraryUiObjectsFromNodes.syncronizeTradingSessionsFoundAtWorkspaceWithBackEnd(functionLibraryTradingSessionFunctions)
}
break
case 'Syncronize Learning Sessions': {
functionLibraryUiObjectsFromNodes.syncronizeLearningSessionsFoundAtWorkspaceWithBackEnd(functionLibraryLearningSessionFunctions)
}
break
case 'Play Tutorials': {
functionLibraryUiObjectsFromNodes.playTutorials()
}
break
case 'Recreate Workspace': {
functionLibraryUiObjectsFromNodes.recreateWorkspace(action.node, action.callBackFunction)
}
break
case 'Delete Workspace': {
return functionLibraryNodeDeleter.deleteWorkspace(action.node, action.rootNodes)
}
break
case 'Copy Node Path':
{
let nodePath = functionLibraryNodePath.getNodePath(action.node)
UI.projects.superalgos.utilities.clipboard.copyTextToClipboard(nodePath)
UI.projects.superalgos.spaces.cockpitSpace.setStatus(
nodePath + ' copied to the Clipboard.'
, 50, UI.projects.superalgos.spaces.cockpitSpace.statusTypes.ALL_GOOD)
}
break
case 'Copy Node Value':
{
let value = action.node.payload.uiObject.getValue()
UI.projects.superalgos.utilities.clipboard.copyTextToClipboard(value)
UI.projects.superalgos.spaces.cockpitSpace.setStatus(
value + ' copied to the Clipboard.'
, 50, UI.projects.superalgos.spaces.cockpitSpace.statusTypes.ALL_GOOD)
}
break
case 'Copy Node Type':
{
let value = action.node.type
UI.projects.superalgos.utilities.clipboard.copyTextToClipboard(value)
UI.projects.superalgos.spaces.cockpitSpace.setStatus(
value + ' copied to the Clipboard.'
, 50, UI.projects.superalgos.spaces.cockpitSpace.statusTypes.ALL_GOOD)
}
break
case 'Add UI Object':
{
functionLibraryUiObjectsFromNodes.addUIObject(action.node, action.relatedNodeType, action.rootNodes)
}
break
case 'Add Missing Children':
{
functionLibraryUiObjectsFromNodes.addMissingChildren(action.node, action.rootNodes)
}
break
case 'Delete UI Object':
{
functionLibraryNodeDeleter.deleteUIObject(action.node, action.rootNodes)
}
break
case 'Edit Code':
break
case 'Share':
{
let text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(action.node, true, false, true, true, true))
let nodeName = action.node.name
if (nodeName === undefined) {
nodeName = ''
} else {
nodeName = '.' + nodeName
}
let fileName = 'Share - ' + action.node.type + ' - ' + nodeName + '.json'
UI.projects.superalgos.utilities.download.downloadText(fileName, text)
}
break
case 'Backup':
{
let text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(action.node, false, false, true, true, true))
let nodeName = action.node.name
if (nodeName === undefined) {
nodeName = ''
} else {
nodeName = ' ' + nodeName
}
let fileName = 'Backup - ' + action.node.type + ' - ' + nodeName + '.json'
UI.projects.superalgos.utilities.download.downloadText(fileName, text)
}
break
case 'Clone':
{
let text = JSON.stringify(functionLibraryNodeCloning.getNodeClone(action.node))
let nodeName = action.node.name
if (nodeName === undefined) {
nodeName = ''
} else {
nodeName = ' ' + nodeName
}
let fileName = 'Clone - ' + action.node.type + ' - ' + nodeName + '.json'
UI.projects.superalgos.utilities.download.downloadText(fileName, text)
}
break
case 'Debug Task':
{
functionLibraryTaskFunctions.runTask(action.node, functionLibraryProtocolNode, true, action.callBackFunction)
}
break
case 'Run Task':
{
functionLibraryTaskFunctions.runTask(action.node, functionLibraryProtocolNode, false, action.callBackFunction)
}
break
case 'Stop Task':
{
functionLibraryTaskFunctions.stopTask(action.node, functionLibraryProtocolNode, action.callBackFunction)
}
break
case 'Run All Tasks':
{
functionLibraryTaskFunctions.runAllTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Stop All Tasks':
{
functionLibraryTaskFunctions.stopAllTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Run All Task Managers':
{
functionLibraryTaskFunctions.runAllTaskManagers(action.node, functionLibraryProtocolNode)
}
break
case 'Stop All Task Managers':
{
functionLibraryTaskFunctions.stopAllTaskManagers(action.node, functionLibraryProtocolNode)
}
break
case 'Run All Exchange Data Tasks':
{
functionLibraryTaskFunctions.runAllExchangeDataTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Stop All Exchange Data Tasks':
{
functionLibraryTaskFunctions.stopAllExchangeDataTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Run All Exchange Trading Tasks':
{
functionLibraryTaskFunctions.runAllExchangeTradingTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Stop All Exchange Trading Tasks':
{
functionLibraryTaskFunctions.stopAllExchangeTradingTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Run All Exchange Learning Tasks':
{
functionLibraryTaskFunctions.runAllExchangeLearningTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Stop All Exchange Learning Tasks':
{
functionLibraryTaskFunctions.stopAllExchangeLearningTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Run All Market Data Tasks':
{
functionLibraryTaskFunctions.runAllMarketDataTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Stop All Market Data Tasks':
{
functionLibraryTaskFunctions.stopAllMarketDataTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Run All Market Trading Tasks':
{
functionLibraryTaskFunctions.runAllMarketTradingTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Stop All Market Trading Tasks':
{
functionLibraryTaskFunctions.stopAllMarketTradingTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Run All Market Learning Tasks':
{
functionLibraryTaskFunctions.runAllMarketLearningTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Stop All Market Learning Tasks':
{
functionLibraryTaskFunctions.stopAllMarketLearningTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Run All Data Mine Tasks':
{
functionLibraryTaskFunctions.runAllDataMineTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Stop All Data Mine Tasks':
{
functionLibraryTaskFunctions.stopAllDataMineTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Run All Trading Mine Tasks':
{
functionLibraryTaskFunctions.runAllTradingMineTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Stop All Trading Mine Tasks':
{
functionLibraryTaskFunctions.stopAllTradingMineTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Run All Learning Mine Tasks':
{
functionLibraryTaskFunctions.runAllLearningMineTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Stop All Learning Mine Tasks':
{
functionLibraryTaskFunctions.stopAllLearningMineTasks(action.node, functionLibraryProtocolNode)
}
break
case 'Add Missing Exchange Data Tasks':
{
functionLibraryTaskFunctions.addMissingExchangeDataTasks(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Market Data Tasks':
{
functionLibraryTaskFunctions.addMissingMarketDataTasks(action.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Data Mine Tasks':
{
functionLibraryTaskFunctions.addMissingDataMineTasks(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Exchange Trading Tasks':
{
functionLibraryTaskFunctions.addMissingExchangeTradingTasks(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Market Trading Tasks':
{
functionLibraryTaskFunctions.addMissingMarketTradingTasks(action.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Trading Mine Tasks':
{
functionLibraryTaskFunctions.addMissingTradingMineTasks(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Exchange Learning Tasks':
{
functionLibraryTaskFunctions.addMissingExchangeLearningTasks(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Market Learning Tasks':
{
functionLibraryTaskFunctions.addMissingMarketLearningTasks(action.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Learning Mine Tasks':
{
functionLibraryTaskFunctions.addMissingLearningMineTasks(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Tasks':
{
functionLibraryTaskFunctions.addAllTasks(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Crypto Exchanges':
{
functionLibraryCryptoEcosystemFunctions.addMissingExchanges(action.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Assets':
{
functionLibraryCryptoEcosystemFunctions.addMissingAssets(action.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Markets':
{
functionLibraryCryptoEcosystemFunctions.addMissingMarkets(action.node, functionLibraryUiObjectsFromNodes, functionLibraryNodeCloning)
}
break
case 'Install Market':
{
functionLibraryCryptoEcosystemFunctions.installMarket(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter, functionLibraryChartingSpaceFunctions, functionLibraryDataStorageFunctions)
}
break
case 'Uninstall Market':
{
functionLibraryCryptoEcosystemFunctions.uninstallMarket(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter, functionLibraryChartingSpaceFunctions, functionLibraryDataStorageFunctions)
}
break
case 'Add All Output Datasets':
{
functionLibraryMineFunctions.addAllOutputDatasets(action.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Data Products':
{
functionLibraryDataStorageFunctions.addAllDataProducts(action.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Data Mine Products':
{
functionLibraryDataStorageFunctions.addAllDataMineProducts(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Learning Mine Products':
{
functionLibraryDataStorageFunctions.addAllLearningMineProducts(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Trading Mine Products':
{
functionLibraryDataStorageFunctions.addAllTradingMineProducts(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Trading Session References':
{
functionLibraryDataStorageFunctions.addMissingTradingSessionReferences(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Learning Session References':
{
functionLibraryDataStorageFunctions.addMissingLearningSessionReferences(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Market Data Products':
{
functionLibraryDataStorageFunctions.addMissingMarketDataProducts(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Market Trading Products':
{
functionLibraryDataStorageFunctions.addMissingMarketTradingProducts(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Exchange Trading Products':
{
functionLibraryDataStorageFunctions.addMissingExchangeTradingProducts(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Exchange Data Products':
{
functionLibraryDataStorageFunctions.addMissingExchangeDataProducts(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Data Dependencies':
{
functionLibraryMineFunctions.addAllDataDependencies(action.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Data Mine Dependencies':
{
functionLibraryMineFunctions.addAllDataMineDataDependencies(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Layer Panels':
{
functionLibraryChartingSpaceFunctions.addAllLayerPanels(action.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Layer Polygons':
{
functionLibraryChartingSpaceFunctions.addAllLayerPolygons(action.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Mine Layers':
{
functionLibraryChartingSpaceFunctions.addAllMineLayers(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
}
break
case 'Add Missing Time Machines':
{
functionLibraryChartingSpaceFunctions.addMissingTimeMachines(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
}
break
case 'Add Missing Dashboards':
{
functionLibraryChartingSpaceFunctions.addMissingDashboards(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
}
break
case 'Play Tutorial':
{
UI.projects.superalgos.spaces.tutorialSpace.playTutorial(action.node)
}
break
case 'Play Tutorial Topic':
{
UI.projects.superalgos.spaces.tutorialSpace.playTutorialTopic(action.node)
}
break
case 'Play Tutorial Step':
{
UI.projects.superalgos.spaces.tutorialSpace.playTutorialStep(action.node)
}
break
case 'Resume Tutorial':
{
UI.projects.superalgos.spaces.tutorialSpace.resumeTutorial(action.node)
}
break
case 'Resume Tutorial Topic':
{
UI.projects.superalgos.spaces.tutorialSpace.resumeTutorialTopic(action.node)
}
break
case 'Resume Tutorial Step':
{
UI.projects.superalgos.spaces.tutorialSpace.resumeTutorialStep(action.node)
}
break
case 'Reset Tutorial Progress':
{
UI.projects.superalgos.spaces.tutorialSpace.resetTutorialProgress(action.node)
}
break
case 'Send Webhook Test Message':
{
functionLibraryWebhookFunctions.sendTestMessage(action.node, action.callBackFunction)
}
break
case 'Run Trading Session':
{
functionLibraryTradingSessionFunctions.runSession(action.node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, false, action.callBackFunction)
}
break
case 'Resume Trading Session':
{
functionLibraryTradingSessionFunctions.runSession(action.node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, true, action.callBackFunction)
}
break
case 'Stop Trading Session':
{
functionLibraryTradingSessionFunctions.stopSession(action.node, functionLibraryProtocolNode, action.callBackFunction)
}
break
case 'Run Learning Session':
{
functionLibraryLearningSessionFunctions.runSession(action.node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, false, action.callBackFunction)
}
break
case 'Resume Learning Session':
{
functionLibraryLearningSessionFunctions.runSession(action.node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, true, action.callBackFunction)
}
break
case 'Stop Learning Session':
{
functionLibraryLearningSessionFunctions.stopSession(action.node, functionLibraryProtocolNode, action.callBackFunction)
}
break
case 'Run Super Action':
{
functionLibrarySuperScripts.runSuperScript(action.node, action.rootNodes, functionLibraryNodeCloning, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
}
break
case 'Parent Attach': {
functionLibraryChainAttachDetach.chainAttachNode(action.node, action.relatedNode, action.rootNodes)
}
break
case 'Reference Attach': {
functionLibraryReferenceAttachDetach.referenceAttachNode(action.node, action.relatedNode, action.rootNodes)
}
break
case 'Parent Detach':
{
functionLibraryChainAttachDetach.chainDetachNode(action.node, action.rootNodes)
}
break
case 'Reference Detach':
{
functionLibraryReferenceAttachDetach.referenceDetachNode(action.node)
}
break
case 'Push Code to Javascript Code':
{
action.node.javascriptCode.code = action.node.code
}
break
case 'Fetch Code to Javascript Code':
{
action.node.code = action.node.javascriptCode.code
}
break
case 'Open Documentation':
{
let definition = getNodeDefinition(action.node)
if (definition !== undefined) {
if (definition.docURL !== undefined) {
UI.projects.superalgos.spaces.docSpace.navigateTo(definition.docURL)
} else {
let headName = UI.projects.superalgos.utilities.hierarchy.getHiriarchyHead(action.node).type
headName = headName.toLowerCase()
headName = headName.split(" ").join("-")
let nodeName = action.node.type
nodeName = nodeName.toLowerCase()
nodeName = nodeName.split(" ").join("-")
url = UI.projects.superalgos.globals.docs.DOCUMENTATION_URL_PREFIX + "suite-hierarchy-" + headName + ".html#" + nodeName
UI.projects.superalgos.spaces.docSpace.navigateTo(url)
}
}
}
break
case 'Add Missing Plugin Projects':
{
functionLibraryPluginsFunctions.pluginMissingProjects(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Plugin Data Mines':
{
functionLibraryPluginsFunctions.pluginMissingDataMines(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Plugin Trading Mines':
{
functionLibraryPluginsFunctions.pluginMissingTradingMines(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Plugin Trading Systems':
{
functionLibraryPluginsFunctions.pluginMissingTradingSystems(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Plugin Trading Engines':
{
functionLibraryPluginsFunctions.pluginMissingTradingEngines(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Plugin Super Scripts':
{
functionLibraryPluginsFunctions.pluginMissingSuperScripts(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Plugin Tutorials':
{
functionLibraryPluginsFunctions.pluginMissingTutorials(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Workspace Projects':
{
functionLibraryWorkspaceFunctions.addMissingWorkspaceProjects(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
}
}
}
@@ -1,5 +1,7 @@
function newChartingSpaceFunctions() {
thisObject = {
addAllLayerPanels: addAllLayerPanels,
addAllLayerPolygons: addAllLayerPolygons,
addAllMineLayers: addAllMineLayers,
addMissingDashboards: addMissingDashboards,
addMissingTimeMachines: addMissingTimeMachines,
@@ -27,8 +29,8 @@ function newChartingSpaceFunctions() {
we find there inside the layers manager. We will end up having at the end
all layers referencing the data products inside the referenced branch.
*/
let dataMine = node.payload.referenceParent
scanBotArray(dataMine.botProducts)
let mine = node.payload.referenceParent
scanBotArray(mine.botProducts)
function scanBotArray(botArray) {
for (let i = 0; i < botArray.length; i++) {
@@ -36,7 +38,7 @@ function newChartingSpaceFunctions() {
let botLayers = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Bot Layers')
botLayers.name = bot.name
asymetricalFolderStructureCloning(
UI.projects.superalgos.utilities.folders.asymetricalFolderStructureCloning(
bot,
botLayers,
'dataProducts',
@@ -52,16 +54,38 @@ function newChartingSpaceFunctions() {
that do not have a plotter module. Since our previous action created all layers no matter
what, we need now to delete all the ones that do not have a plotter module.
*/
let allLayers = nodeBranchToArray(botLayers, 'Layer')
let allLayers = UI.projects.superalgos.utilities.branches.nodeBranchToArray(botLayers, 'Layer')
for (let j = 0; j < allLayers.length; j++) {
let layer = allLayers[j]
layer.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_45
let plotterModule = findNodeInNodeMesh(layer, 'Plotter Module', undefined, true, false, false, true)
let plotterModule = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(layer, 'Plotter Module', undefined, true, false, false, true)
if (plotterModule === undefined) {
functionLibraryNodeDeleter.deleteUIObject(layer, rootNodes)
}
}
/*
For each of the layers we will not create the Layer Panels and Layer Polygons.
*/
allLayers = UI.projects.superalgos.utilities.branches.nodeBranchToArray(botLayers, 'Layer')
for (let j = 0; j < allLayers.length; j++) {
let layer = allLayers[j]
let menu = layer.payload.uiObject.menu
menu.internalClick('Add Missing Children')
layer.layerPanels.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
layer.layerPolygons.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
menu = layer.layerPanels.payload.uiObject.menu
menu.internalClick('Add All Layer Panels')
menu = layer.layerPolygons.payload.uiObject.menu
menu.internalClick('Add All Layer Polygons')
layer.layerPanels.payload.floatingObject.collapseToggle()
layer.layerPolygons.payload.floatingObject.collapseToggle()
layer.payload.floatingObject.collapseToggle()
}
}
}
}
@@ -83,25 +107,27 @@ function newChartingSpaceFunctions() {
function scanNetworkNode(networkNode) {
if (networkNode === undefined) { return }
let backtestingSessionsArray = nodeBranchToArray(networkNode, 'Backtesting Session')
let fordwardTestingSessionsArray = nodeBranchToArray(networkNode, 'Forward Testing Session')
let paperTradingSessionsArray = nodeBranchToArray(networkNode, 'Paper Trading Session')
let liveTradingSessionsArray = nodeBranchToArray(networkNode, 'Live Trading Session')
let backtestingSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Backtesting Session')
let fordwardTestingSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Forward Testing Session')
let paperTradingSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Paper Trading Session')
let liveTradingSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Live Trading Session')
let learningSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Learning Session')
scanSessionArray(backtestingSessionsArray)
scanSessionArray(fordwardTestingSessionsArray)
scanSessionArray(paperTradingSessionsArray)
scanSessionArray(liveTradingSessionsArray)
scanSessionArray(learningSessionsArray)
function scanSessionArray(sessionsArray) {
for (let i = 0; i < sessionsArray.length; i++) {
let session = sessionsArray[i]
let environment = findNodeInNodeMesh(session, node.payload.referenceParent.type, undefined, true, false, true, false)
let environment = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(session, node.payload.referenceParent.type, undefined, true, false, true, false)
if (environment === undefined) { continue }
if (environment.id !== node.payload.referenceParent.id) { continue }
let market = findNodeInNodeMesh(session, 'Market Trading Tasks', undefined, true, false, true, false)
let market = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(session, 'Market Trading Tasks', undefined, true, false, true, false)
if (market.payload.referenceParent === undefined) { continue }
if (isMissingChildren(node, session, true) === true) {
if (UI.projects.superalgos.utilities.children.isMissingChildren(node, session, true) === true) {
createTimeMachine(node, session, market.payload.referenceParent, networkNode, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
}
}
@@ -112,46 +138,18 @@ function newChartingSpaceFunctions() {
function createTimeMachine(dashboard, session, market, networkNode, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter) {
let mineProducts
let timeMachine = functionLibraryUiObjectsFromNodes.addUIObject(dashboard, 'Time Machine')
let exchange = market.payload.parentNode.payload.parentNode
timeMachine.payload.referenceParent = session
timeMachine.name = session.name + ' ' + session.type + ' ' + networkNode.name
timeMachine.name = session.name + ' ' + session.type + ' ' + networkNode.name + ' ' + exchange.name + ' ' + market.name
timeMachine.payload.floatingObject.collapseToggle()
timeMachine.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
timeMachine.timeFrameScale.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
timeMachine.timeScale.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
timeMachine.rateScale.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
/*
We need to create a Timeline Chart for each Data Mine Indicators.
We will create 3 Time Line Charts for the Trading Mine Products
*/
mineProducts = nodeBranchToArray(networkNode, 'Data Mine Products')
for (let j = 0; j < mineProducts.length; j++) {
let mineProduct = mineProducts[j]
/*
We need to filter out the ones that do not belong to the market where
the session is running at.
*/
if (mineProduct.payload.parentNode.payload.referenceParent === undefined) { continue }
if (mineProduct.payload.parentNode.payload.referenceParent.id !== market.id) { continue }
let timelineChart = functionLibraryUiObjectsFromNodes.addUIObject(timeMachine, 'Timeline Chart')
/*
The Mine Product Node might be collapesd and since its creation it never
received the physics call, so we will do the call so that it properly
sets its own name, which we are going to reuse here.
*/
mineProduct.payload.uiObject.invisiblePhysics()
timelineChart.name = mineProduct.name
timelineChart.layerManager.payload.referenceParent = mineProduct
timelineChart.payload.floatingObject.collapseToggle()
timelineChart.layerManager.payload.floatingObject.collapseToggle()
timelineChart.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
timelineChart.layerManager.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
let menu = timelineChart.layerManager.payload.uiObject.menu
menu.internalClick('Add All Mine Layers')
menu.internalClick('Add All Mine Layers')
}
mineProducts = nodeBranchToArray(networkNode, 'Trading Mine Products')
mineProducts = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Trading Mine Products')
for (let j = 0; j < mineProducts.length; j++) {
let mineProduct = mineProducts[j]
/*
@@ -201,12 +199,74 @@ function newChartingSpaceFunctions() {
}
}
function deleteNodeByName(nodeName) {
let nodeToDelete = findNodeInNodeMesh(timelineChart.layerManager, undefined, nodeName, true, true, false, false)
let nodeToDelete = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(timelineChart.layerManager, undefined, nodeName, true, true, false, false)
if (nodeToDelete === undefined) { return }
functionLibraryNodeDeleter.deleteUIObject(nodeToDelete, rootNodes)
}
}
}
/*
We need to create a Timeline Chart for each Data Mine Products.
*/
mineProducts = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Data Mine Products')
for (let j = 0; j < mineProducts.length; j++) {
let mineProduct = mineProducts[j]
/*
We need to filter out the ones that do not belong to the market where
the session is running at.
*/
if (mineProduct.payload.parentNode.payload.referenceParent === undefined) { continue }
if (mineProduct.payload.parentNode.payload.referenceParent.id !== market.id) { continue }
let timelineChart = functionLibraryUiObjectsFromNodes.addUIObject(timeMachine, 'Timeline Chart')
/*
The Mine Product Node might be collapesd and since its creation it never
received the physics call, so we will do the call so that it properly
sets its own name, which we are going to reuse here.
*/
mineProduct.payload.uiObject.invisiblePhysics()
timelineChart.name = mineProduct.name + ' Data'
timelineChart.layerManager.payload.referenceParent = mineProduct
timelineChart.payload.floatingObject.collapseToggle()
timelineChart.layerManager.payload.floatingObject.collapseToggle()
timelineChart.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
timelineChart.layerManager.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
let menu = timelineChart.layerManager.payload.uiObject.menu
menu.internalClick('Add All Mine Layers')
menu.internalClick('Add All Mine Layers')
}
/*
We need to create a Timeline Chart for each Learning Mine Products.
*/
mineProducts = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Learning Mine Products')
for (let j = 0; j < mineProducts.length; j++) {
let mineProduct = mineProducts[j]
/*
We need to filter out the ones that do not belong to the market where
the session is running at.
*/
if (mineProduct.payload.parentNode.payload.parentNode.payload.referenceParent === undefined) { continue }
if (mineProduct.payload.parentNode.payload.parentNode.payload.referenceParent.id !== market.id) { continue }
let timelineChart = functionLibraryUiObjectsFromNodes.addUIObject(timeMachine, 'Timeline Chart')
/*
The Mine Product Node might be collapesd and since its creation it never
received the physics call, so we will do the call so that it properly
sets its own name, which we are going to reuse here.
*/
mineProduct.payload.uiObject.invisiblePhysics()
timelineChart.name = mineProduct.name + ' Learning'
timelineChart.layerManager.payload.referenceParent = mineProduct
timelineChart.payload.floatingObject.collapseToggle()
timelineChart.layerManager.payload.floatingObject.collapseToggle()
timelineChart.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
timelineChart.layerManager.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
let menu = timelineChart.layerManager.payload.uiObject.menu
menu.internalClick('Add All Mine Layers')
menu.internalClick('Add All Mine Layers')
}
}
function addMissingDashboards(node, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter) {
@@ -227,16 +287,16 @@ function newChartingSpaceFunctions() {
}
function scanNetworkNode(networkNode) {
let testingEnvironment = findInBranch(networkNode, 'Testing Environment', node, true)
let productionEnvironment = findInBranch(networkNode, 'Production Environment', node, true)
let testingEnvironment = UI.projects.superalgos.utilities.branches.findInBranch(networkNode, 'Testing Environment', node, true)
let productionEnvironment = UI.projects.superalgos.utilities.branches.findInBranch(networkNode, 'Production Environment', node, true)
if (isMissingChildren(node, testingEnvironment, true) === true) {
if (UI.projects.superalgos.utilities.children.isMissingChildren(node, testingEnvironment, true) === true) {
let dashboard = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Dashboard')
dashboard.payload.referenceParent = testingEnvironment
dashboard.name = testingEnvironment.type + ' ' + networkNode.name
}
if (isMissingChildren(node, productionEnvironment, true) === true) {
if (UI.projects.superalgos.utilities.children.isMissingChildren(node, productionEnvironment, true) === true) {
let dashboard = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Dashboard')
dashboard.payload.referenceParent = productionEnvironment
dashboard.name = productionEnvironment.type + ' ' + networkNode.name
@@ -244,4 +304,77 @@ function newChartingSpaceFunctions() {
}
}
}
function addAllLayerPanels(node, functionLibraryUiObjectsFromNodes) {
if (validateReferences(node) !== true) { return }
let layerNode = node.payload.parentNode
let plotterModule = layerNode.payload.referenceParent.payload.referenceParent.payload.referenceParent
for (let i = 0; i < plotterModule.panels.length; i++) {
let plotterPanel = plotterModule.panels[i]
let layerPanel = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Layer Panel')
layerPanel.payload.referenceParent = plotterPanel
}
}
function addAllLayerPolygons(node, functionLibraryUiObjectsFromNodes) {
if (validateReferences(node) !== true) { return }
let layerNode = node.payload.parentNode
let plotterModule = layerNode.payload.referenceParent.payload.referenceParent.payload.referenceParent
if (plotterModule.shapes === undefined) {
node.payload.uiObject.setWarningMessage('Referenced Plotter Module does not have a Shapes child.')
return
}
for (let i = 0; i < plotterModule.shapes.polygons.length; i++) {
let polygon = plotterModule.shapes.polygons[i]
let layerPolygon = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Layer Polygon')
layerPolygon.payload.referenceParent = polygon
}
}
function validateReferences(node) {
/* Validations to see if we can do this or not. */
if (node.payload === undefined) { return }
if (node.payload.uiObject === undefined) { return }
if (node.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('You need to have a Layer node as a parent to execute this action.')
return
}
if (node.payload.parentNode.payload === undefined) {
node.payload.uiObject.setErrorMessage('You need to have a Layer node as a parent to execute this action.')
return
}
let layerNode = node.payload.parentNode
if (layerNode.payload.referenceParent === undefined) {
node.payload.uiObject.setErrorMessage('The Layer node needs to have a reference parent node to execute this action.')
return
}
if (layerNode.payload.referenceParent.payload === undefined) {
node.payload.uiObject.setErrorMessage('The Layer node needs to have a reference parent node to execute this action.')
return
}
if (layerNode.payload.referenceParent.payload.referenceParent === undefined) {
node.payload.uiObject.setErrorMessage('The Layer node needs to have a reference grand parent node to execute this action.')
return
}
if (layerNode.payload.referenceParent.payload.referenceParent.payload === undefined) {
node.payload.uiObject.setErrorMessage('The Layer node needs to have a reference grand parent node to execute this action.')
return
}
if (layerNode.payload.referenceParent.payload.referenceParent.payload.referenceParent === undefined) {
node.payload.uiObject.setErrorMessage('The Layer node to have a reference grand grand parent node to execute this action.')
return
}
if (layerNode.payload.referenceParent.payload.referenceParent.payload.referenceParent.payload === undefined) {
node.payload.uiObject.setErrorMessage('The Layer node to have a reference grand grand parent node to execute this action.')
return
}
return true
}
}
@@ -0,0 +1,576 @@
function newCryptoEcosystemFunctions() {
thisObject = {
addMissingExchanges: addMissingExchanges,
addMissingAssets: addMissingAssets,
addMissingMarkets: addMissingMarkets,
installMarket: installMarket,
uninstallMarket: uninstallMarket
}
return thisObject
function addMissingExchanges(node, functionLibraryUiObjectsFromNodes) {
currentExchanges = new Map()
let parent = node.payload.parentNode
if (parent !== undefined) {
for (let i = 0; i < parent.cryptoExchanges.length; i++) {
let cryptoExchanges = parent.cryptoExchanges[i]
for (let j = 0; j < cryptoExchanges.exchanges.length; j++) {
let exchange = cryptoExchanges.exchanges[j]
let codeName = UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(exchange.payload, 'codeName')
currentExchanges.set(codeName, exchange)
}
}
}
let params = {
method: 'listExchanges',
has: {
fetchOHLCV: true,
fetchMarkets: true
}
}
callWebServer(JSON.stringify(params), 'CCXT', onResponse)
function onResponse(err, data) {
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
return
}
let exchanges = JSON.parse(data)
for (let i = 0; i < exchanges.length; i++) {
let exchange = exchanges[i]
let existingExchange = currentExchanges.get(exchange.id)
if (existingExchange === undefined) {
let newExchange = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Crypto Exchange')
newExchange.name = exchange.name
newExchange.config = '{ \n\"codeName\": \"' + exchange.id + '\"\n}'
newExchange.payload.floatingObject.collapseToggle()
newExchange.exchangeAssets.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
newExchange.exchangeMarkets.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
newExchange.exchangeAccounts.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
newExchange.exchangeAssets.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_050X
newExchange.exchangeMarkets.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
newExchange.exchangeAccounts.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_025X
newExchange.exchangeAssets.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
newExchange.exchangeMarkets.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
newExchange.exchangeAccounts.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
}
}
}
}
function addMissingAssets(node, functionLibraryUiObjectsFromNodes) {
if (node.payload.parentNode === undefined) { return }
let currentAssets = new Map()
for (let j = 0; j < node.assets.length; j++) {
let asset = node.assets[j]
let codeName = UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(asset.payload, 'codeName')
currentAssets.set(codeName, asset)
}
let exchangeId = UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(node.payload.parentNode.payload, 'codeName')
try {
let params = {
exchangeId: exchangeId,
method: 'fetchMarkets'
}
callWebServer(JSON.stringify(params), 'CCXT', onResponse)
function onResponse(err, data) {
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
return
}
let queryParams = UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(node.payload, 'addMissingAssetsFilter')
let markets = JSON.parse(data)
let totalAdded = 0
for (let i = 0; i < markets.length; i++) {
let market = markets[i]
if (queryParams !== undefined) {
if (queryParams.baseAsset !== undefined) {
if (market.base.indexOf(queryParams.baseAsset) < 0) {
continue
}
}
if (queryParams.quotedAsset !== undefined) {
if (market.quote.indexOf(queryParams.quotedAsset) < 0) {
continue
}
}
}
if (currentAssets.get(market.base) === undefined) {
addAsset(market.base)
totalAdded++
currentAssets.set(market.base, market.base)
}
if (currentAssets.get(market.quote) === undefined) {
addAsset(market.quote)
totalAdded++
currentAssets.set(market.quote, market.quote)
}
function addAsset(name) {
let newAsseet = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Asset')
newAsseet.name = name
newAsseet.config = '{ \n\"codeName\": \"' + name + '\"\n}'
}
}
node.payload.uiObject.setInfoMessage(node.payload.parentNode.name + ' supports ' + markets.length + ' markets. Applying the filters at this node config ' + node.config + ' this process added ' + totalAdded + ' assets.', 4)
}
} catch (err) {
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
console.log(err.stack)
}
}
function addMissingMarkets(node, functionLibraryUiObjectsFromNodes, functionLibraryNodeCloning) {
if (node.payload.parentNode === undefined) { return }
if (node.payload.parentNode.exchangeAssets === undefined) { return }
if (node.payload.parentNode.payload.parentNode === undefined) { return }
if (node.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { return }
let currentAssets = new Map()
let exchangeAssets = node.payload.parentNode.exchangeAssets
for (let j = 0; j < exchangeAssets.assets.length; j++) {
let asset = exchangeAssets.assets[j]
let codeName = UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(asset.payload, 'codeName')
currentAssets.set(codeName, asset)
}
let currentMarkets = new Map()
let exchangeMarkets = node
for (let j = 0; j < exchangeMarkets.markets.length; j++) {
let asset = exchangeMarkets.markets[j]
let codeName = UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(asset.payload, 'codeName')
currentMarkets.set(codeName, asset)
}
let exchangeId = UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(node.payload.parentNode.payload, 'codeName')
try {
let params = {
exchangeId: exchangeId,
method: 'fetchMarkets'
}
callWebServer(JSON.stringify(params), 'CCXT', onResponse)
function onResponse(err, data) {
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
return
}
let markets = JSON.parse(data)
for (let i = 0; i < markets.length; i++) {
let market = markets[i]
let baseAsset = currentAssets.get(market.base)
let quotedAsset = currentAssets.get(market.quote)
if (baseAsset === undefined) {
continue
}
if (quotedAsset === undefined) {
continue
}
if (currentMarkets.get(market.symbol) === undefined) {
addMarket(market.symbol, baseAsset, quotedAsset)
}
function addMarket(name, baseAsset, quotedAsset) {
let newMarket = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Market')
newMarket.name = name
newMarket.config = '{ \n\"codeName\": \"' + name + '\"\n}'
newMarket.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
newMarket.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
newMarket.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
newMarket.baseAsset.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_45
newMarket.quotedAsset.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_45
newMarket.baseAsset.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
newMarket.quotedAsset.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
newMarket.baseAsset.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
newMarket.quotedAsset.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
newMarket.baseAsset.payload.referenceParent = baseAsset
newMarket.quotedAsset.payload.referenceParent = quotedAsset
currentMarkets.set(name, newMarket)
}
}
}
} catch (err) {
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
console.log(err.stack)
}
}
function installMarket(
node,
rootNodes,
functionLibraryUiObjectsFromNodes,
functionLibraryNodeDeleter,
functionLibraryChartingSpaceFunctions,
functionLibraryDataStorageFunctions
) {
let market = node
let cryptoExchange = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(node, 'Crypto Exchange', undefined, true, false, true, false)
if (cryptoExchange === undefined) {
node.payload.uiObject.setErrorMessage('Market must be a descendant of a Crypto Exchange')
return
}
node.payload.uiObject.setInfoMessage('This market is being installed. This might take a minute or two. Please hold on while we connect all the dots for you. ')
setTimeout(installMarketProcedure, 500)
function installMarketProcedure() {
let dashboardsArray = []
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === 'Network') {
installInNetwork(rootNode)
}
}
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === 'Charting Space') {
installInChartingSpace(rootNode)
}
}
node.payload.uiObject.setInfoMessage('Market installation is complete.')
function installInNetwork(network) {
for (let j = 0; j < network.networkNodes.length; j++) {
let networkNode = network.networkNodes[j]
installInNetworkNode(networkNode)
}
function installInNetworkNode(networkNode) {
let tradingSessionsCreatedArray = []
let learningSessionsCreatedArray = []
installDataMiningTasks()
installLearningMiningTasks()
isntallTradingMiningTasks()
installDataMinesData()
installLearningMinesData()
installTradingMineData()
function installDataMiningTasks() {
/*
Here we complete the missing stuff at Data Mining
*/
let dataMining = UI.projects.superalgos.utilities.branches.findInBranch(networkNode, 'Data Mining', node, true)
if (dataMining === undefined) {
node.payload.uiObject.setErrorMessage('Data Mining node not found at Network Node ' + networkNode.name)
return
}
let exchangeDataTasks = UI.projects.superalgos.utilities.children.findOrCreateChildWithReference(dataMining, 'Exchange Data Tasks', cryptoExchange, functionLibraryUiObjectsFromNodes)
exchangeDataTasks.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
let marketDataTask = UI.projects.superalgos.utilities.children.findAndRecreateChildWithReference(exchangeDataTasks, 'Market Data Tasks', market, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
UI.projects.superalgos.utilities.menu.menuClick(marketDataTask, 'Add Missing Data Mine Tasks', true)
UI.projects.superalgos.utilities.menu.menuClickOfNodeArray(marketDataTask.dataMineTasks, 'Add All Tasks', true)
}
function installLearningMiningTasks() {
/*
Here we complete the missing stuff at Learning Mining
*/
let learningMining = UI.projects.superalgos.utilities.branches.findInBranch(networkNode, 'Learning Mining', node, true)
if (learningMining === undefined) {
node.payload.uiObject.setErrorMessage('Learning Mining node not found at Network Node ' + networkNode.name)
return
}
let exchangeLearningTasks = UI.projects.superalgos.utilities.children.findOrCreateChildWithReference(learningMining, 'Exchange Learning Tasks', cryptoExchange, functionLibraryUiObjectsFromNodes)
exchangeLearningTasks.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
let marketLearningTask = UI.projects.superalgos.utilities.children.findAndRecreateChildWithReference(exchangeLearningTasks, 'Market Learning Tasks', market, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
UI.projects.superalgos.utilities.menu.menuClick(marketLearningTask, 'Add Missing Learning Mine Tasks', true)
UI.projects.superalgos.utilities.menu.menuClickOfNodeArray(marketLearningTask.learningMineTasks, 'Add All Tasks', true)
/* This will be needed at the charting space, for creating Dashboards */
let learningSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(marketLearningTask, 'Learning Session')
learningSessionsCreatedArray = learningSessionsCreatedArray.concat(learningSessionsArray)
}
function isntallTradingMiningTasks() {
/*
Next we complete the missing stuff at Testing Environment
*/
installEnvironment('Testing Environment')
/*
Next we complete the missing stuff at Production Environment
*/
installEnvironment('Production Environment')
function installEnvironment(environment) {
/*
Now we install the environmnet at the current Network Node
*/
let environmentFound = UI.projects.superalgos.utilities.branches.findInBranch(networkNode, environment, node, true)
if (environmentFound === undefined) {
node.payload.uiObject.setErrorMessage(environment + ' node not found at Network Node ' + networkNode.name)
return
}
let exchangeTradingTasks = UI.projects.superalgos.utilities.children.findOrCreateChildWithReference(environmentFound, 'Exchange Trading Tasks', cryptoExchange, functionLibraryUiObjectsFromNodes)
exchangeTradingTasks.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
let marketTradingTask = UI.projects.superalgos.utilities.children.findAndRecreateChildWithReference(exchangeTradingTasks, 'Market Trading Tasks', market, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
UI.projects.superalgos.utilities.menu.menuClick(marketTradingTask, 'Add Missing Trading Mine Tasks', true)
UI.projects.superalgos.utilities.menu.menuClickOfNodeArray(marketTradingTask.tradingMineTasks, 'Add All Tasks', true)
/* This will be needed at the charting space, for creating Dashboards */
let backtestingSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(marketTradingTask, 'Backtesting Session')
let liveTradingSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(marketTradingTask, 'Live Trading Session')
let paperTradingSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(marketTradingTask, 'Paper Trading Session')
let forwardSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(marketTradingTask, 'Forward Testing Session')
let allSessionsArray = backtestingSessionsArray
.concat(liveTradingSessionsArray)
.concat(paperTradingSessionsArray)
.concat(forwardSessionsArray)
tradingSessionsCreatedArray = tradingSessionsCreatedArray.concat(allSessionsArray)
dashboardsArray.push({ environmentNode: environmentFound, networkNode: networkNode, sessionsArray: allSessionsArray })
}
}
function installDataMinesData() {
/*
Here we complete the missing stuff at Data Mines Data
*/
let dataMinesData = UI.projects.superalgos.utilities.branches.findInBranch(networkNode, 'Data Mines Data', node, true)
if (dataMinesData === undefined) {
node.payload.uiObject.setErrorMessage('Data Mines Data node not found at Network Node ' + networkNode.name)
return
}
let exchangeDataProducts = UI.projects.superalgos.utilities.children.findOrCreateChildWithReference(dataMinesData, 'Exchange Data Products', cryptoExchange, functionLibraryUiObjectsFromNodes)
exchangeDataProducts.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
let marketDataProducts = UI.projects.superalgos.utilities.children.findAndRecreateChildWithReference(exchangeDataProducts, 'Market Data Products', market, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
marketDataProducts.payload.floatingObject.collapseToggle()
UI.projects.superalgos.utilities.menu.menuClick(marketDataProducts, 'Add All Data Mine Products', true)
UI.projects.superalgos.utilities.menu.menuClickOfNodeArray(marketDataProducts.dataMineProducts, 'Add All Data Products', true)
}
function installLearningMinesData() {
/*
Here we complete the missing stuff at Learning Mines Data
*/
let learningMinesData = UI.projects.superalgos.utilities.branches.findInBranch(networkNode, 'Learning Mines Data', node, true)
if (learningMinesData === undefined) {
node.payload.uiObject.setErrorMessage('Learning Mines Data node not found at Network Node ' + networkNode.name)
return
}
let exchangeLearningProducts = UI.projects.superalgos.utilities.children.findOrCreateChildWithReference(learningMinesData, 'Exchange Learning Products', cryptoExchange, functionLibraryUiObjectsFromNodes)
exchangeLearningProducts.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
let marketLearningProducts = UI.projects.superalgos.utilities.children.findAndRecreateChildWithReference(exchangeLearningProducts, 'Market Learning Products', market, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
marketLearningProducts.payload.floatingObject.collapseToggle()
/*
Create the new session references.
*/
for (let i = 0; i < learningSessionsCreatedArray.length; i++) {
let session = learningSessionsCreatedArray[i]
if (UI.projects.superalgos.utilities.children.isMissingChildren(marketLearningProducts, session, true) === true) {
functionLibraryDataStorageFunctions.createSessionReference(marketLearningProducts, session, 'Learning Session Reference', functionLibraryUiObjectsFromNodes)
}
}
/*
Create everything inside the session references.
*/
for (let j = 0; j < marketLearningProducts.learningSessionReferences.length; j++) {
let sessionReference = marketLearningProducts.learningSessionReferences[j]
UI.projects.superalgos.utilities.menu.menuClick(sessionReference, 'Add All Learning Mine Products', true)
UI.projects.superalgos.utilities.menu.menuClickOfNodeArray(sessionReference.learningMineProducts, 'Add All Data Products', true)
sessionReference.payload.floatingObject.collapseToggle()
}
}
function installTradingMineData() {
/*
Finally we complete the missing stuff at Trading Mines Data
*/
let tradingMinesData = UI.projects.superalgos.utilities.branches.findInBranch(networkNode, 'Trading Mines Data', node, true)
if (tradingMinesData === undefined) {
node.payload.uiObject.setErrorMessage('Trading Mines Data node not found at Network Node ' + networkNode.name)
return
}
let exchangeTradingProducts = UI.projects.superalgos.utilities.children.findOrCreateChildWithReference(tradingMinesData, 'Exchange Trading Products', cryptoExchange, functionLibraryUiObjectsFromNodes)
exchangeTradingProducts.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
let marketTradingProducts = UI.projects.superalgos.utilities.children.findAndRecreateChildWithReference(exchangeTradingProducts, 'Market Trading Products', market, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
marketTradingProducts.payload.floatingObject.collapseToggle()
/*
Create the new session references.
*/
for (let i = 0; i < tradingSessionsCreatedArray.length; i++) {
let session = tradingSessionsCreatedArray[i]
if (UI.projects.superalgos.utilities.children.isMissingChildren(marketTradingProducts, session, true) === true) {
functionLibraryDataStorageFunctions.createSessionReference(marketTradingProducts, session, 'Trading Session Reference', functionLibraryUiObjectsFromNodes)
}
}
/*
Create everything inside the session references.
*/
for (let j = 0; j < marketTradingProducts.tradingSessionReferences.length; j++) {
let sessionReference = marketTradingProducts.tradingSessionReferences[j]
UI.projects.superalgos.utilities.menu.menuClick(sessionReference, 'Add All Trading Mine Products', true)
UI.projects.superalgos.utilities.menu.menuClickOfNodeArray(sessionReference.tradingMineProducts, 'Add All Data Products', true)
sessionReference.payload.floatingObject.collapseToggle()
}
}
}
}
function installInChartingSpace(chartingSpace) {
for (let i = 0; i < dashboardsArray.length; i++) {
/*
If the Dashboard we need is not already there we create a new one.
*/
let arrayItem = dashboardsArray[i]
let dashboard = UI.projects.superalgos.utilities.children.findOrCreateChildWithReference(chartingSpace, 'Dashboard', arrayItem.environmentNode, functionLibraryUiObjectsFromNodes)
dashboard.name = arrayItem.environmentNode.type + ' ' + arrayItem.networkNode.name
/*
We delete all the existing Time Machines related to the market we are currently installing.
For that, we make a new array with the existing Time Machines so that the deleting
of each node does not affect the proccessing of the whole set.
*/
let timeMachines = []
for (let i = 0; i < dashboard.timeMachines.length; i++) {
let timeMachine = dashboard.timeMachines[i]
timeMachines.push(timeMachine)
}
for (let i = 0; i < timeMachines.length; i++) {
let timeMachine = timeMachines[i]
let session = timeMachine.payload.referenceParent
if (session === undefined || session.cleaned === true) {
/*
This is what usually happens, that the intall process make these
time machines to lose their reference parent since the install
process deletes them.
*/
functionLibraryNodeDeleter.deleteUIObject(timeMachine, rootNodes)
continue
}
let marketTradingTasks = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(session, 'Market Trading Tasks', undefined, true, false, true, false)
if (marketTradingTasks === undefined) { continue }
if (marketTradingTasks.payload === undefined) { continue }
if (marketTradingTasks.payload.referenceParent === undefined) { continue }
if (marketTradingTasks.payload.referenceParent.id === market.id) {
functionLibraryNodeDeleter.deleteUIObject(timeMachine, rootNodes)
}
}
/*
We create a time machine for each session added during the previous processing.
*/
for (let j = 0; j < arrayItem.sessionsArray.length; j++) {
let session = arrayItem.sessionsArray[j]
functionLibraryChartingSpaceFunctions.createTimeMachine(dashboard, session, node, arrayItem.networkNode, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
}
}
}
}
}
function uninstallMarket(node, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter, functionLibraryChartingSpaceFunctions, functionLibraryDataStorageFunctions) {
node.payload.uiObject.setInfoMessage('This market is being uninstalled. Please hold on that it might take a while.')
setTimeout(uninstallMarketProcedure, 500)
function uninstallMarketProcedure() {
let market = node
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === 'Charting Space') {
uninstallInChartingSpace(rootNode)
}
}
node.payload.uiObject.setInfoMessage('Market uninstall is complete.')
function uninstallInChartingSpace(chartingSpace) {
/* Delete all time machines which are referencing sessions inside the market being unistalled. */
let timeMachines = UI.projects.superalgos.utilities.branches.nodeBranchToArray(chartingSpace, 'Time Machine')
for (let i = 0; i < timeMachines.length; i++) {
let timeMachine = timeMachines[i]
let session = timeMachine.payload.referenceParent
if (session === undefined) { continue }
let marketTradingTasks = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(session, 'Market Trading Tasks', undefined, true, false, true, false)
if (marketTradingTasks === undefined) { continue }
if (marketTradingTasks.payload === undefined) { continue }
if (marketTradingTasks.payload.referenceParent === undefined) { continue }
if (marketTradingTasks.payload.referenceParent.id === market.id) {
functionLibraryNodeDeleter.deleteUIObject(timeMachine, rootNodes)
}
}
/* Delete all Dashboards that does not have time machines inside. */
let dashboardArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(chartingSpace, 'Dashboard')
for (let i = 0; i < dashboardArray.length; i++) {
let dashboard = dashboardArray[i]
if (dashboard.timeMachines.length === 0) {
functionLibraryNodeDeleter.deleteUIObject(dashboard, rootNodes)
}
}
/* Scan Networks for the market being unistalled to delete it. */
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === 'Network') {
uninstallInNetwork(rootNode)
}
}
}
function uninstallInNetwork(network) {
let marketDataTasksArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(network, 'Market Data Tasks')
let marketTradingTasksArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(network, 'Market Trading Tasks')
let marketLearningTasksArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(network, 'Market Learning Tasks')
let marketDataProductsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(network, 'Market Data Products')
let marketTradingProductsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(network, 'Market Trading Products')
let marketLearningProductsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(network, 'Market Learning Products')
uninstalMarketArray(marketDataTasksArray)
uninstalMarketArray(marketTradingTasksArray)
uninstalMarketArray(marketLearningTasksArray)
uninstalMarketArray(marketDataProductsArray)
uninstalMarketArray(marketTradingProductsArray)
uninstalMarketArray(marketLearningProductsArray)
function uninstalMarketArray(marketArray) {
for (let i = 0; i < marketArray.length; i++) {
let marketReference = marketArray[i]
if (marketReference.payload === undefined) { continue }
if (marketReference.payload.referenceParent === undefined) { continue }
if (marketReference.payload.referenceParent.id === market.id) {
functionLibraryNodeDeleter.deleteUIObject(marketReference, rootNodes)
}
}
}
}
}
}
}
@@ -3,7 +3,9 @@ function newDataStorageFunctions() {
addAllDataProducts: addAllDataProducts,
addAllDataMineProducts: addAllDataMineProducts,
addAllTradingMineProducts: addAllTradingMineProducts,
addMissingSessionReferences: addMissingSessionReferences,
addAllLearningMineProducts: addAllLearningMineProducts,
addMissingTradingSessionReferences: addMissingTradingSessionReferences,
addMissingLearningSessionReferences: addMissingLearningSessionReferences,
addMissingMarketDataProducts: addMissingMarketDataProducts,
addMissingMarketTradingProducts: addMissingMarketTradingProducts,
addMissingExchangeTradingProducts: addMissingExchangeTradingProducts,
@@ -37,6 +39,7 @@ function newDataStorageFunctions() {
scanBotArray(mine.sensorBots)
scanBotArray(mine.indicatorBots)
scanBotArray(mine.tradingBots)
scanBotArray(mine.learningBots)
function scanBotArray(botArray) {
if (botArray === undefined) { return }
@@ -47,7 +50,7 @@ function newDataStorageFunctions() {
botProducts.name = bot.name
botProducts.payload.floatingObject.collapseToggle()
asymetricalFolderStructureCloning(
UI.projects.superalgos.utilities.folders.asymetricalFolderStructureCloning(
bot,
botProducts,
'products',
@@ -84,14 +87,25 @@ function newDataStorageFunctions() {
}
}
function addMissingSessionReferences(node, rootNodes, functionLibraryUiObjectsFromNodes) {
let networkNode = findNodeInNodeMesh(node, 'Network Node', undefined, true, false, true, false)
function addAllLearningMineProducts(node, rootNodes, functionLibraryUiObjectsFromNodes) {
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === 'Learning Mine') {
let learningMineProducts = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Learning Mine Products')
learningMineProducts.payload.referenceParent = rootNode
}
}
}
function addMissingTradingSessionReferences(node, rootNodes, functionLibraryUiObjectsFromNodes) {
let networkNode = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(node, 'Network Node', undefined, true, false, true, false)
if (networkNode === undefined) { return }
let backtestingSessionsArray = nodeBranchToArray(networkNode, 'Backtesting Session')
let fordwardTestingSessionsArray = nodeBranchToArray(networkNode, 'Forward Testing Session')
let paperTradingSessionsArray = nodeBranchToArray(networkNode, 'Paper Trading Session')
let liveTradingSessionsArray = nodeBranchToArray(networkNode, 'Live Trading Session')
let backtestingSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Backtesting Session')
let fordwardTestingSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Forward Testing Session')
let paperTradingSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Paper Trading Session')
let liveTradingSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Live Trading Session')
addMissingSession(backtestingSessionsArray)
addMissingSession(fordwardTestingSessionsArray)
@@ -102,17 +116,38 @@ function newDataStorageFunctions() {
for (let i = 0; i < sessionsArray.length; i++) {
let session = sessionsArray[i]
/* We will filter out all the sessions that does not belong to the market we are in */
let marketTradingTasks = findNodeInNodeMesh(session, 'Market Trading Tasks', undefined, true, false, true, false)
let marketTradingTasks = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(session, 'Market Trading Tasks', undefined, true, false, true, false)
if (node.payload.referenceParent.id !== marketTradingTasks.payload.referenceParent.id) { continue }
if (isMissingChildren(node, session, true) === true) {
createSessionReference(node, session, functionLibraryUiObjectsFromNodes)
if (UI.projects.superalgos.utilities.children.isMissingChildren(node, session, true) === true) {
createSessionReference(node, session, 'Trading Session Reference', functionLibraryUiObjectsFromNodes)
}
}
}
}
function createSessionReference(node, session, functionLibraryUiObjectsFromNodes) {
let sessionReference = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Session Reference')
function addMissingLearningSessionReferences(node, rootNodes, functionLibraryUiObjectsFromNodes) {
let networkNode = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(node, 'Network Node', undefined, true, false, true, false)
if (networkNode === undefined) { return }
let learningSessionsArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Learning Session')
addMissingSession(learningSessionsArray)
function addMissingSession(sessionsArray) {
for (let i = 0; i < sessionsArray.length; i++) {
let session = sessionsArray[i]
/* We will filter out all the sessions that does not belong to the market we are in */
let marketLearningTasks = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(session, 'Market Learning Tasks', undefined, true, false, true, false)
if (node.payload.referenceParent.id !== marketLearningTasks.payload.referenceParent.id) { continue }
if (UI.projects.superalgos.utilities.children.isMissingChildren(node, session, true) === true) {
createSessionReference(node, session, 'Learning Session Reference', functionLibraryUiObjectsFromNodes)
}
}
}
}
function createSessionReference(node, session, nodeType, functionLibraryUiObjectsFromNodes) {
let sessionReference = functionLibraryUiObjectsFromNodes.addUIObject(node, nodeType)
sessionReference.payload.referenceParent = session
}
@@ -131,7 +166,7 @@ function newDataStorageFunctions() {
for (let i = 0; i < marketsArray.length; i++) {
let market = marketsArray[i]
if (isMissingChildren(node, market, true) === true) {
if (UI.projects.superalgos.utilities.children.isMissingChildren(node, market, true) === true) {
let marketDataProducts = functionLibraryUiObjectsFromNodes.addUIObject(node, newNodeType)
marketDataProducts.payload.referenceParent = market
}
@@ -155,7 +190,7 @@ function newDataStorageFunctions() {
let cryptoExchanges = cryptoEcosystem.cryptoExchanges[j]
for (let k = 0; k < cryptoExchanges.exchanges.length; k++) {
let cryptoExchange = cryptoExchanges.exchanges[k]
if (isMissingChildren(node, cryptoExchange, true) === true) {
if (UI.projects.superalgos.utilities.children.isMissingChildren(node, cryptoExchange, true) === true) {
let exchange = functionLibraryUiObjectsFromNodes.addUIObject(node, newNodeType)
exchange.payload.referenceParent = cryptoExchange
}
@@ -0,0 +1,235 @@
function newLearningSessionFunctions() {
thisObject = {
syncronizeSessionWithBackEnd: syncronizeSessionWithBackEnd,
runSession: runSession,
stopSession: stopSession
}
return thisObject
function syncronizeSessionWithBackEnd(node) {
let networkNode = validations(node)
if (networkNode === undefined) {
/* Nodes that do not belong to a network can not get ready. */
return
}
let eventsServerClient = UI.projects.superalgos.spaces.designSpace.workspace.eventsServerClients.get(networkNode.id)
/* First we setup everything so as to listen to the response from the Task Server */
let eventSubscriptionIdOnStatus
let key = node.name + '-' + node.type + '-' + node.id
eventsServerClient.listenToEvent(key, 'Status Response', undefined, node.id, onResponse, onStatus)
function onResponse(message) {
eventSubscriptionIdOnStatus = message.eventSubscriptionId
}
function onStatus(message) {
eventsServerClient.stopListening(key, eventSubscriptionIdOnStatus, node.id)
if (message.event.status === 'Learning Session Runnning' ) {
node.payload.uiObject.menu.internalClick('Run Learning Session')
}
}
/* Second we ask the Task Server if this Session is Running. */
eventsServerClient.raiseEvent(key, 'Learning Session Status')
}
function runSession(node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, resume, callBackFunction) {
let networkNode = validations(node)
if (networkNode === undefined) {
/* This means that the validations failed. */
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
let eventsServerClient = UI.projects.superalgos.spaces.designSpace.workspace.eventsServerClients.get(networkNode.id)
node.payload.uiObject.run(eventsServerClient, callBackFunction)
let key = node.name + '-' + node.type + '-' + node.id
let lightingPath = '' +
'Trading System->' +
'Dynamic Indicators->Indicator Function->Formula->' +
'Trading Strategy->' +
'Trigger Stage->Trigger On Event->Trigger Off Event->Take Position Event->' +
'Announcement->Announcement Formula->' +
'Open Stage->' +
'Manage Stage->' +
'Managed Stop Loss->Managed Take Profit->' +
'Phase->Formula->Next Phase Event->Move To Phase Event->Phase->' +
'Situation->Condition->Javascript Code->' +
'Close Stage->' +
'Initial Targets->Target Size In Base Asset->Target Size In Quoted Asset->Target Rate->Formula->' +
'Announcement->Announcement Formula->' +
'Open Execution->Close Execution->' +
'Execution Algorithm->Market Buy Order->Market Sell Order->Limit Buy Order->Limit Sell Order->' +
'Order Rate->Formula->' +
'Create Order Event->Cancel Order Event->' +
'Size In Base Asset->Size In Quoted Asset->Position Rate->Formula->' +
'Situation->Condition->Javascript Code->' +
'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)
lightingPath = '' +
'Trading Engine->' +
'Dynamic Indicators->Indicator Function->' +
'Current->Last->Previous->' +
'Episode->' +
'Episode Base Asset->Episode Quoted Asset->Episode Counters->Episode Statistics->' +
'Strategies->Positions->Orders->Hits->Fails->' +
'Profit Loss->Hit Ratio->Hit Fail->Days->ROI->Annualized Rate Of Return->User Defined Statistic->' +
'Candle->Cycle->' +
'Begin->End->Last Begin->Last End->Open->Close->Min->Max->Index->' +
'Distance To Event->' +
'Head Of The Market->Process Date->' +
'Trigger On->Trigger Off->Take Position->Close Position->Next Phase->Move To Phase->Create Order->Cancel Order->Close Order->' +
'Strategy->' +
'Strategy Counters->' +
'Position->' +
'Entry Target Rate->Exit Target Rate->' +
'Stop Loss->Stop Loss Phase->Stop Loss Position->Begin->End->Initial Value->Final Value->' +
'Take Profit->Take Profit Phase->Take Profit Position->Begin->End->Initial Value->Final Value->' +
'Position Counters->' +
'Position Statistics->Days->User Defined Statistic->' +
'Position Base Asset->Position Quoted Asset->Entry Target Size->Exit Target Size->' +
'Profit Loss->ROI->Hit Fail->' +
'Exchange Orders->Market Buy Orders->Market Sell Orders->Limit Buy Orders->Limit Sell Orders->' +
'Market Order->Limit Order->' +
'Exchange Id->Rate->Order Name->Algorithm Name->Lock->' +
'Order Counters->' +
'Order Base Asset->Order Quoted Asset->' +
'Actual Size->Size->Size Filled->Amount Received->Fees Paid->Fees To Be Paid->' +
'Order Statistics->Percentage Filled->Actual Rate->Days->User Defined Statistic->' +
'Strategy Trigger Stage->Strategy Open Stage->Strategy Manage Stage->Strategy Close Stage->' +
'Begin->End->Exit Type->Status->Begin Rate->End Rate->Stage Base Asset->Stage Quoted Asset->Size Placed->Target Size->Size Filled->Fees Paid->Stage Defined In->' +
'Serial Number->Identifier->Begin->End->Begin Rate->End Rate->Strategy Name->Status->Exit Type->' +
'Balance->Begin Balance->End Balance->' +
'Index->Situation Name->Formula->Periods->'
let tradingEngine = functionLibraryProtocolNode.getProtocolNode(node.tradingEngineReference.payload.referenceParent, false, true, true, false, false, lightingPath)
lightingPath = '' +
'Learning Session->' +
'Learning Parameters->' +
'Session Base Asset->Session Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->Snapshots->Heartbeats->User Defined Parameters->' +
'Exchange Account Asset->Asset->' +
'Social Bots->Telegram Bot->'
let session = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath)
let dependencyFilter = functionLibraryDependenciesFilter.createFilter(node.tradingSystemReference.payload.referenceParent)
/* Raise event to run the session */
let event = {
session: JSON.stringify(session),
tradingSystem: JSON.stringify(tradingSystem),
tradingEngine: JSON.stringify(tradingEngine),
dependencyFilter: JSON.stringify(dependencyFilter),
resume: resume
}
if (resume !== true) {
eventsServerClient.raiseEvent(key, 'Run Learning Session', event)
} else {
eventsServerClient.raiseEvent(key, 'Resume Learning Session', event)
}
if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
}
function stopSession(node, functionLibraryProtocolNode, callBackFunction) {
let networkNode = validations(node)
if (networkNode === undefined) {
/* This means that the validations failed. */
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
let eventsServerClient = UI.projects.superalgos.spaces.designSpace.workspace.eventsServerClients.get(networkNode.id)
let key = node.name + '-' + node.type + '-' + node.id
eventsServerClient.raiseEvent(key, 'Stop Learning Session')
node.payload.uiObject.stop(callBackFunction, undefined, true)
}
function validations(node) {
if (node.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs a Process Instance parent to be able to run.')
return
}
if (node.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs to be inside a Process Instance node.')
return
}
if (node.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs to be inside a Task.')
return
}
if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs to be inside a Task Manager.')
return
}
let taskManager = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode
if (taskManager.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs to be inside Mine Tasks.')
return
}
if (taskManager.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs to be inside Market Tasks.')
return
}
if (taskManager.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs to be inside Exchange Tasks.')
return
}
if (taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs to be inside a Testing or Production Environment.')
return
}
if (taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs to be inside a Network Node.')
return
}
let networkNode = taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode
if (node.tradingSystemReference === undefined) {
node.payload.uiObject.setErrorMessage('Session needs a child Trading System Reference.')
return
}
if (node.tradingEngineReference === undefined) {
node.payload.uiObject.setErrorMessage('Session needs a child Trading Engine Reference.')
return
}
if (node.tradingSystemReference.payload.referenceParent === undefined) {
node.payload.uiObject.setErrorMessage('Trading System Reference needs to reference a Trading System.')
return
}
if (node.tradingEngineReference.payload.referenceParent === undefined) {
node.payload.uiObject.setErrorMessage('Trading Engine Reference needs to reference a Trading Engine.')
return
}
return networkNode
}
}
@@ -1,4 +1,4 @@
function newDataMineFunctions() {
function newMineFunctions() {
thisObject = {
addAllOutputDatasets: addAllOutputDatasets,
addAllDataDependencies: addAllDataDependencies,
@@ -31,7 +31,7 @@ function newDataMineFunctions() {
Output Dataset Folder, and for each Product Definition found we will create a Output Definition
for each Dataset defined inside the Product Definition.
*/
asymetricalFolderStructureCloning(
UI.projects.superalgos.utilities.folders.asymetricalFolderStructureCloning(
node.payload.parentNode.payload.parentNode,
node,
'products',
@@ -68,6 +68,7 @@ function newDataMineFunctions() {
scanBotArray(dataMine.sensorBots)
scanBotArray(dataMine.indicatorBots)
scanBotArray(dataMine.tradingBots)
scanBotArray(dataMine.learningBots)
function scanBotArray(botArray) {
for (let i = 0; i < botArray.length; i++) {
@@ -75,7 +76,7 @@ function newDataMineFunctions() {
let botProducts = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Bot Data Dependencies')
botProducts.name = bot.name
asymetricalFolderStructureCloning(
UI.projects.superalgos.utilities.folders.asymetricalFolderStructureCloning(
bot,
botProducts,
'products',
@@ -25,7 +25,8 @@ function newNodeCloning() {
type: node.type,
name: node.name,
code: node.code,
config: node.config
config: node.config,
project: node.project
}
/* Children Nodes */
@@ -78,7 +79,8 @@ function newNodeCloning() {
type: node.type,
name: node.name,
code: node.code,
config: node.config
config: node.config,
project: node.project
}
/* Children Nodes */
@@ -7,14 +7,15 @@ function newNodeDeleter() {
return thisObject
function destroyUiObject(node) {
canvas.floatingSpace.uiObjectConstructor.destroyUiObject(node.payload)
UI.projects.superalgos.spaces.floatingSpace.uiObjectConstructor.destroyUiObject(node.payload)
}
function deleteWorkspace(node, rootNodes) {
if (node.rootNodes !== undefined) {
while (node.rootNodes.length > 0) {
let rootNode = node.rootNodes[0]
deleteUIObject(rootNode, rootNodes)
let result = deleteUIObject(rootNode, rootNodes)
if (result === false) { return false}
}
}
@@ -24,6 +25,7 @@ function newNodeDeleter() {
}
function deleteUIObject(node, rootNodes) {
/* First we restore the reference parent to its default state */
if (node.payload !== undefined && node.payload.referenceParent !== undefined && node.payload.referenceParent.payload !== undefined && node.payload.referenceParent.payload.uiObject !== undefined) {
node.payload.referenceParent.payload.uiObject.isShowing = false
@@ -41,7 +43,8 @@ function newNodeDeleter() {
case 'node': {
if (property.name !== previousPropertyName) {
if (node[property.name] !== undefined) {
deleteUIObject(node[property.name], rootNodes)
let result = deleteUIObject(node[property.name], rootNodes)
if (result === false) { return false}
}
previousPropertyName = property.name
}
@@ -51,7 +54,8 @@ function newNodeDeleter() {
let nodePropertyArray = node[property.name]
if (nodePropertyArray !== undefined) {
while (nodePropertyArray.length > 0) {
deleteUIObject(nodePropertyArray[0], rootNodes)
let result = deleteUIObject(nodePropertyArray[0], rootNodes)
if (result === false) { return false}
}
}
}
@@ -61,6 +65,7 @@ function newNodeDeleter() {
}
/* Remove node from parent */
let removedFromParent = false
if (node.payload !== undefined) {
if (node.payload.parentNode !== undefined) {
let parentNodeDefinition = getNodeDefinition(node.payload.parentNode)
@@ -72,6 +77,7 @@ function newNodeDeleter() {
switch (property.type) {
case 'node': {
node.payload.parentNode[property.name] = undefined
removedFromParent = true
}
break
case 'array': {
@@ -89,6 +95,7 @@ function newNodeDeleter() {
}
nodePropertyArray.splice(j, 1)
removedFromParent = true
}
}
}
@@ -99,6 +106,10 @@ function newNodeDeleter() {
}
}
}
if (removedFromParent === false) {
console.log('[ERROR] Deleting Node: ' + node.type + ' ' + node.name + '. This node could not be deleted from its parent node (' + node.payload.parentNode.type + ') because its configured propertyNameAtParent (' + nodeDefinition.propertyNameAtParent + ') does not match any of the properties of its parent.')
return false
}
}
}
@@ -130,7 +141,7 @@ function newNodeDeleter() {
node.payload.node = undefined
node.payload.parentNode = undefined
node.payload.chainParent = undefined
node.payload.onMenuItemClick = undefined
node.payload.executeAction = undefined
node.handle = undefined
node.payload = undefined
node.cleaned = true
@@ -0,0 +1,135 @@
function newPluginsFunctions() {
thisObject = {
pluginMissingProjects: pluginMissingProjects,
pluginMissingDataMines: pluginMissingDataMines,
pluginMissingTradingMines: pluginMissingTradingMines,
pluginMissingTradingSystems: pluginMissingTradingSystems,
pluginMissingTradingEngines: pluginMissingTradingEngines,
pluginMissingSuperScripts: pluginMissingSuperScripts,
pluginMissingTutorials: pluginMissingTutorials
}
return thisObject
function getPluginFileNames(projectName, pluginType, callBack) {
callWebServer(undefined, 'PluginFileNames/' + projectName + '/' + pluginType, onResponse)
function onResponse(err, data) {
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
console.log('Failed to Fetch Plugin ' + pluginType + ' from the Backend')
return
}
let pluginFileNames = JSON.parse(data)
callBack(pluginFileNames)
}
}
function addPluginFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes) {
for (let i = 0; i < fileNames.length; i++) {
let fileName = fileNames[i]
fileName = fileName.replace('.json', '')
if (UI.projects.superalgos.utilities.children.isMissingChildrenByName(node, fileName) === true) {
let child = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Plugin File')
child.name = fileName
}
}
}
function pluginMissingProjects(node, rootNodes, functionLibraryUiObjectsFromNodes) {
let url = 'ProjectNames'
callWebServer(undefined, url, onResponse)
function onResponse(err, pProjects) {
let projects = JSON.parse(pProjects)
for (let i = 0; i < projects.length; i++) {
let project = projects[i]
if (UI.projects.superalgos.utilities.children.isMissingChildrenByName(node, project) === true) {
let child = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Plugin Project')
child.name = project
let config = JSON.parse(child.config)
config.codeName = project
child.config = JSON.stringify(config)
}
}
}
}
function getProjectName(node) {
/* Validations to see if we can do this or not. */
if (node.payload === undefined) { return }
if (node.payload.uiObject === undefined) { return }
if (node.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('You need to have a Plugin Project node as a parent to execute this action.')
return
}
if (node.payload.parentNode.payload === undefined) {
node.payload.uiObject.setErrorMessage('You need to have a Plugin Project node as a parent to execute this action.')
return
}
let pluginProject = node.payload.parentNode
let config = JSON.parse(pluginProject.config)
return config.codeName
}
function pluginMissingDataMines(node, rootNodes, functionLibraryUiObjectsFromNodes) {
let projectName = getProjectName(node)
getPluginFileNames(projectName, 'Data-Mines', onNamesArrived)
function onNamesArrived(fileNames) {
addPluginFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
}
}
function pluginMissingTradingMines(node, rootNodes, functionLibraryUiObjectsFromNodes) {
let projectName = getProjectName(node)
getPluginFileNames(projectName, 'Trading-Mines', onNamesArrived)
function onNamesArrived(fileNames) {
addPluginFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
}
}
function pluginMissingTradingSystems(node, rootNodes, functionLibraryUiObjectsFromNodes) {
let projectName = getProjectName(node)
getPluginFileNames(projectName, 'Trading-Systems', onNamesArrived)
function onNamesArrived(fileNames) {
addPluginFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
}
}
function pluginMissingTradingEngines(node, rootNodes, functionLibraryUiObjectsFromNodes) {
let projectName = getProjectName(node)
getPluginFileNames(projectName, 'Trading-Engines', onNamesArrived)
function onNamesArrived(fileNames) {
addPluginFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
}
}
function pluginMissingSuperScripts(node, rootNodes, functionLibraryUiObjectsFromNodes) {
let projectName = getProjectName(node)
getPluginFileNames(projectName, 'Super-Scripts', onNamesArrived)
function onNamesArrived(fileNames) {
addPluginFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
}
}
function pluginMissingTutorials(node, rootNodes, functionLibraryUiObjectsFromNodes) {
let projectName = getProjectName(node)
getPluginFileNames(projectName, 'Tutorials', onNamesArrived)
function onNamesArrived(fileNames) {
addPluginFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
}
}
}
@@ -20,7 +20,8 @@ function newProtocolNode() {
type: node.type,
name: node.name,
code: node.code,
config: node.config
config: node.config,
project: node.project
}
/* Children Nodes */
@@ -10,7 +10,7 @@ function newReferenceAttachDetach() {
completeDetachment(node)
}
function referenceAttachNode(node, attachToNode, rootNodes) {
function referenceAttachNode(node, attachToNode) {
completeAttachment(node, attachToNode)
}
@@ -13,16 +13,22 @@ function newTaskFunctions() {
stopAllExchangeDataTasks: stopAllExchangeDataTasks,
runAllExchangeTradingTasks: runAllExchangeTradingTasks,
stopAllExchangeTradingTasks: stopAllExchangeTradingTasks,
runAllExchangeLearningTasks: runAllExchangeLearningTasks,
stopAllExchangeLearningTasks: stopAllExchangeLearningTasks,
runAllMarketDataTasks: runAllMarketDataTasks,
stopAllMarketDataTasks: stopAllMarketDataTasks,
runAllMarketTradingTasks: runAllMarketTradingTasks,
stopAllMarketTradingTasks: stopAllMarketTradingTasks,
runAllMarketLearningTasks: runAllMarketLearningTasks,
stopAllMarketLearningTasks: stopAllMarketLearningTasks,
runAllDataMineTasks: runAllDataMineTasks,
stopAllDataMineTasks: stopAllDataMineTasks,
runAllTradingMineTasks: runAllTradingMineTasks,
stopAllTradingMineTasks: stopAllTradingMineTasks,
runAllLearningMineTasks: runAllLearningMineTasks,
stopAllLearningMineTasks: stopAllLearningMineTasks,
addMissingExchangeDataTasks: addMissingExchangeDataTasks,
addMissingMarketDataTasks: addMissingMarketDataTasks,
@@ -30,6 +36,10 @@ function newTaskFunctions() {
addMissingExchangeTradingTasks: addMissingExchangeTradingTasks,
addMissingMarketTradingTasks: addMissingMarketTradingTasks,
addMissingTradingMineTasks: addMissingTradingMineTasks,
addMissingExchangeLearningTasks: addMissingExchangeLearningTasks,
addMissingMarketLearningTasks: addMissingMarketLearningTasks,
addMissingLearningMineTasks: addMissingLearningMineTasks,
addAllTasks: addAllTasks
}
@@ -42,7 +52,7 @@ function newTaskFunctions() {
return
}
let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id)
let eventsServerClient = UI.projects.superalgos.spaces.designSpace.workspace.eventsServerClients.get(networkNode.id)
/* First we setup everything so as to listen to the response from the Task Manger */
let eventSubscriptionIdOnStatus
@@ -77,27 +87,32 @@ function newTaskFunctions() {
return
}
let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id)
let eventsServerClient = UI.projects.superalgos.spaces.designSpace.workspace.eventsServerClients.get(networkNode.id)
for (let i = 0; i < node.bot.processes.length; i++) {
let process = node.bot.processes[i]
process.payload.uiObject.run(eventsServerClient)
if (process.session !== undefined) {
process.session.payload.uiObject.reset()
}
}
let taskLightingPath = '->Task->' +
'Sensor Bot Instance->' +
'Indicator Bot Instance->Time Frames Filter->' +
'Trading Bot Instance->' +
'Sensor Process Instance->Indicator Process Instance->Trading Process Instance->' +
'Learning Bot Instance->' +
'Sensor Process Instance->Indicator Process Instance->Trading Process Instance->Learning Process Instance->' +
'Execution Started Event->' +
'Key Reference->Exchange Account Key->' +
'Task Manager->' +
'Data Mine Tasks->Trading Mine Tasks->' +
'Market Data Tasks->Market Trading Tasks->' +
'Exchange Data Tasks->Exchange Trading Tasks->' +
'Data Mine Tasks->Trading Mine Tasks->Learning Mine Tasks->' +
'Market Data Tasks->Market Trading Tasks->Market Learning Tasks->' +
'Exchange Data Tasks->Exchange Trading Tasks->Exchange Learning Tasks->' +
'Market->Exchange Markets->Crypto Exchange->' +
'Market Base Asset->Market Quoted Asset->Asset->' +
'Backtesting Session->Live Trading Session->Paper Trading Session->Forward Testing Session->' +
'Learning Session->' +
'Process Definition->' +
'Process Output->' +
'Output Dataset Folder->Output Dataset Folder->Output Dataset Folder->Output Dataset Folder->Output Dataset Folder->' +
@@ -121,7 +136,8 @@ function newTaskFunctions() {
'Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->' +
'Indicator Bot->' +
'Trading Bot->' +
'Data Mine->Trading Mine->'
'Learning Bot->' +
'Data Mine->Trading Mine->Learning Mine->'
let taskDefinition = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, taskLightingPath)
@@ -131,21 +147,21 @@ function newTaskFunctions() {
'Data Mine Products->Bot Products->' +
'Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->' +
'Data Product->Product Definition->' +
'Data Mining->Testing Environment->Production Environment->' +
'Exchange Data Tasks->Exchange Trading Tasks->Crypto Exchange->' +
'Market Data Tasks->Market Trading Tasks->Market->' +
'Data Mine Tasks->Trading Mine Tasks->' +
'Data Mining->Learning Mining->Testing Environment->Production Environment->' +
'Exchange Data Tasks->Exchange Trading Tasks->Exchange Learning Tasks->Crypto Exchange->' +
'Market Data Tasks->Market Trading Tasks->Market Learning Tasks->Market->' +
'Data Mine Tasks->Trading Mine Tasks->Learning Mine Tasks->' +
'Task Manager->Task->' +
'Indicator Bot Instance->Sensor Bot Instance->Trading Bot Instance->' +
'Indicator Process Instance->Sensor Process Instance->Trading Process Instance->' +
'Paper Trading Session->Forward Testing Session->Backtesting Session->Live Trading Session->' +
'Indicator Bot Instance->Sensor Bot Instance->Trading Bot Instance->Learning Bot Instance->' +
'Indicator Process Instance->Sensor Process Instance->Trading Process Instance->Learning Process Instance->' +
'Paper Trading Session->Forward Testing Session->Backtesting Session->Live Trading Session->Learning Session->' +
'Market->' +
'Process Definition->'
let networkDefinition = functionLibraryProtocolNode.getProtocolNode(networkNode.payload.parentNode, false, true, true, false, false, networkLightingPath)
let event = {
appSchema: JSON.stringify(APP_SCHEMA_ARRAY),
appSchema: JSON.stringify(SCHEMAS_BY_PROJECT.get('Superalgos').array.appSchema),
taskId: node.id,
taskName: node.name,
taskDefinition: JSON.stringify(taskDefinition),
@@ -169,14 +185,14 @@ function newTaskFunctions() {
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id)
let eventsServerClient = UI.projects.superalgos.spaces.designSpace.workspace.eventsServerClients.get(networkNode.id)
let event = {
taskId: node.id,
taskName: node.name
}
node.payload.uiObject.stop(callBackFunction)
node.payload.uiObject.stop(callBackFunction, undefined, true)
eventsServerClient.raiseEvent('Task Manager', 'Stop Task', event)
if (node.bot === undefined) { return }
@@ -184,7 +200,10 @@ function newTaskFunctions() {
for (let i = 0; i < node.bot.processes.length; i++) {
let process = node.bot.processes[i]
process.payload.uiObject.stop()
process.payload.uiObject.stop(undefined, undefined, true)
if (process.session !== undefined) {
process.session.payload.uiObject.reset()
}
}
}
@@ -221,7 +240,7 @@ function newTaskFunctions() {
}
if (taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Task needs to be inside a Data Mining, Testing or Production Environment.')
node.payload.uiObject.setErrorMessage('Task needs to be inside a Data Mining, Learning Mining, Testing or Production Environment node.')
return
}
@@ -231,17 +250,17 @@ function newTaskFunctions() {
}
let networkNode = taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode
if (loadPropertyFromNodeConfig(networkNode.payload, 'host') === undefined) {
if (UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(networkNode.payload, 'host') === undefined) {
node.payload.uiObject.setErrorMessage('Network Node needs to have a valid Host property at its config.')
return
}
if (loadPropertyFromNodeConfig(networkNode.payload, 'webPort') === undefined) {
if (UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(networkNode.payload, 'webPort') === undefined) {
node.payload.uiObject.setErrorMessage('Network Node needs to have a valid webPort property at its config.')
return
}
if (loadPropertyFromNodeConfig(networkNode.payload, 'webSocketsPort') === undefined) {
if (UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(networkNode.payload, 'webSocketsPort') === undefined) {
node.payload.uiObject.setErrorMessage('Network Node needs to have a valid webSocketsPort property at its config.')
return
}
@@ -327,6 +346,26 @@ function newTaskFunctions() {
}
}
function runAllExchangeLearningTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.exchangeLearningTasks.length; i++) {
let node = parent.exchangeLearningTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Run All Market Learning Tasks')
menu.internalClick('Run All Market Learning Tasks')
}
}
function stopAllExchangeLearningTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.exchangeLearningTasks.length; i++) {
let node = parent.exchangeLearningTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Stop All Market Learning Tasks')
menu.internalClick('Stop All Market Learning Tasks')
}
}
function runAllMarketDataTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.marketDataTasks.length; i++) {
let node = parent.marketDataTasks[i]
@@ -357,6 +396,16 @@ function newTaskFunctions() {
}
}
function runAllMarketLearningTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.marketLearningTasks.length; i++) {
let node = parent.marketLearningTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Run All Learning Mine Tasks')
menu.internalClick('Run All Learning Mine Tasks')
}
}
function stopAllMarketTradingTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.marketTradingTasks.length; i++) {
let node = parent.marketTradingTasks[i]
@@ -367,6 +416,16 @@ function newTaskFunctions() {
}
}
function stopAllMarketLearningTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.marketLearningTasks.length; i++) {
let node = parent.marketLearningTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Stop All Learning Mine Tasks')
menu.internalClick('Stop All Learning Mine Tasks')
}
}
function runAllDataMineTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.dataMineTasks.length; i++) {
let node = parent.dataMineTasks[i]
@@ -397,6 +456,16 @@ function newTaskFunctions() {
}
}
function runAllLearningMineTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.learningMineTasks.length; i++) {
let node = parent.learningMineTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Run All Task Managers')
menu.internalClick('Run All Task Managers')
}
}
function stopAllTradingMineTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.tradingMineTasks.length; i++) {
let node = parent.tradingMineTasks[i]
@@ -407,6 +476,16 @@ function newTaskFunctions() {
}
}
function stopAllLearningMineTasks(parent, functionLibraryProtocolNode) {
for (let i = 0; i < parent.learningMineTasks.length; i++) {
let node = parent.learningMineTasks[i]
let menu = node.payload.uiObject.menu
menu.internalClick('Stop All Task Managers')
menu.internalClick('Stop All Task Managers')
}
}
function addMissingExchangeDataTasks(node, rootNodes, functionLibraryUiObjectsFromNodes) {
addMissingExchangeTasks(node, rootNodes, 'Exchange Data Tasks', functionLibraryUiObjectsFromNodes)
}
@@ -415,6 +494,10 @@ function newTaskFunctions() {
addMissingExchangeTasks(node, rootNodes, 'Exchange Trading Tasks', functionLibraryUiObjectsFromNodes)
}
function addMissingExchangeLearningTasks(node, rootNodes, functionLibraryUiObjectsFromNodes) {
addMissingExchangeTasks(node, rootNodes, 'Exchange Learning Tasks', functionLibraryUiObjectsFromNodes)
}
function addMissingExchangeTasks(node, rootNodes, newNodeType, functionLibraryUiObjectsFromNodes) {
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
@@ -424,7 +507,7 @@ function newTaskFunctions() {
let cryptoExchanges = cryptoEcosystem.cryptoExchanges[j]
for (let k = 0; k < cryptoExchanges.exchanges.length; k++) {
let cryptoExchange = cryptoExchanges.exchanges[k]
if (isMissingChildren(node, cryptoExchange, true) === true) {
if (UI.projects.superalgos.utilities.children.isMissingChildren(node, cryptoExchange, true) === true) {
let exchangeTasks = functionLibraryUiObjectsFromNodes.addUIObject(node, newNodeType)
exchangeTasks.payload.referenceParent = cryptoExchange
}
@@ -442,6 +525,10 @@ function newTaskFunctions() {
addMissingMarketTasks(node, 'Market Trading Tasks', functionLibraryUiObjectsFromNodes)
}
function addMissingMarketLearningTasks(node, functionLibraryUiObjectsFromNodes) {
addMissingMarketTasks(node, 'Market Learning Tasks', functionLibraryUiObjectsFromNodes)
}
function addMissingMarketTasks(node, newNodeType, functionLibraryUiObjectsFromNodes) {
if (node.payload === undefined) { return }
if (node.payload.referenceParent === undefined) { return }
@@ -452,7 +539,7 @@ function newTaskFunctions() {
for (let i = 0; i < markets.length; i++) {
let market = markets[i]
if (isMissingChildren(node, market, true) === true) {
if (UI.projects.superalgos.utilities.children.isMissingChildren(node, market, true) === true) {
let marketDataTasks = functionLibraryUiObjectsFromNodes.addUIObject(node, newNodeType)
marketDataTasks.payload.referenceParent = market
}
@@ -467,15 +554,19 @@ function newTaskFunctions() {
addMissingMineTasks(node, rootNodes, 'Trading Mine', 'Trading Mine Tasks', functionLibraryUiObjectsFromNodes)
}
function addMissingLearningMineTasks(node, rootNodes, functionLibraryUiObjectsFromNodes) {
addMissingMineTasks(node, rootNodes, 'Learning Mine', 'Learning Mine Tasks', functionLibraryUiObjectsFromNodes)
}
function addMissingMineTasks(node, rootNodes, rootNodeType, newNodeType, functionLibraryUiObjectsFromNodes) {
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === rootNodeType) {
let dataMine = rootNode
let mine = rootNode
if (isMissingChildren(node, dataMine, true) === true) {
if (UI.projects.superalgos.utilities.children.isMissingChildren(node, mine, true) === true) {
let dataMineTasks = functionLibraryUiObjectsFromNodes.addUIObject(node, newNodeType)
dataMineTasks.payload.referenceParent = dataMine
dataMineTasks.payload.referenceParent = mine
}
}
}
@@ -494,6 +585,10 @@ function newTaskFunctions() {
addDataTasks()
break
}
case 'Learning Mine Tasks': {
addLearningTasks()
break
}
case 'Trading Mine Tasks': {
addTradingTasks()
break
@@ -504,6 +599,10 @@ function newTaskFunctions() {
addTaskForTradinSystem()
}
function addLearningTasks() {
addTaskForTradinSystem()
}
function addTradingTasks() {
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
@@ -519,6 +618,7 @@ function newTaskFunctions() {
addTasksForBotArray(mine.sensorBots)
addTasksForBotArray(mine.indicatorBots)
addTasksForBotArray(mine.tradingBots)
addTasksForBotArray(mine.learningBots)
function addTasksForBotArray(botsArray) {
if (botsArray === undefined) { return }
@@ -551,6 +651,11 @@ function newTaskFunctions() {
botInstance.name = bot.name
break
}
case 'Learning Bot': {
botInstance = functionLibraryUiObjectsFromNodes.addUIObject(task, 'Learning Bot Instance')
botInstance.name = bot.name
break
}
}
for (let j = 0; j < bot.processes.length; j++) {
@@ -592,6 +697,32 @@ function newTaskFunctions() {
}
break
function addSession(sessionType) {
session = functionLibraryUiObjectsFromNodes.addUIObject(processInstance, sessionType)
session.name = task.name
let config = JSON.parse(session.config)
config.folderName = session.name.split(" ").join("-")
session.config = JSON.stringify(config)
for (let m = 0; m < rootNodes.length; m++) {
let rootNode = rootNodes[m]
if (rootNode.type === 'Trading Engine' && rootNode.isPlugin === true) {
let tradingEngine = rootNode
session.tradingEngineReference.payload.referenceParent = tradingEngine
session.tradingSystemReference.payload.referenceParent = tradingSystem
}
}
}
}
case 'Learning Bot': {
processInstance = functionLibraryUiObjectsFromNodes.addUIObject(botInstance, 'Learning Process Instance')
processInstance.payload.referenceParent = process
let session
addSession('Learning Session')
break
function addSession(sessionType) {
session = functionLibraryUiObjectsFromNodes.addUIObject(processInstance, sessionType)
session.name = task.name
@@ -1,4 +1,4 @@
function newSessionFunctions() {
function newTradingSessionFunctions() {
thisObject = {
syncronizeSessionWithBackEnd: syncronizeSessionWithBackEnd,
runSession: runSession,
@@ -14,7 +14,7 @@ function newSessionFunctions() {
return
}
let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id)
let eventsServerClient = UI.projects.superalgos.spaces.designSpace.workspace.eventsServerClients.get(networkNode.id)
/* First we setup everything so as to listen to the response from the Task Server */
let eventSubscriptionIdOnStatus
@@ -27,13 +27,13 @@ function newSessionFunctions() {
function onStatus(message) {
eventsServerClient.stopListening(key, eventSubscriptionIdOnStatus, node.id)
if (message.event.status === 'Session Runnning' ) {
node.payload.uiObject.menu.internalClick('Run Session')
if (message.event.status === 'Trading Session Runnning' ) {
node.payload.uiObject.menu.internalClick('Run Trading Session')
}
}
/* Second we ask the Task Server if this Session is Running. */
eventsServerClient.raiseEvent(key, 'Session Status')
eventsServerClient.raiseEvent(key, 'Trading Session Status')
}
function runSession(node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, resume, callBackFunction) {
@@ -44,7 +44,7 @@ function newSessionFunctions() {
return
}
let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id)
let eventsServerClient = UI.projects.superalgos.spaces.designSpace.workspace.eventsServerClients.get(networkNode.id)
node.payload.uiObject.run(eventsServerClient, callBackFunction)
@@ -84,7 +84,7 @@ function newSessionFunctions() {
'Strategies->Positions->Orders->Hits->Fails->' +
'Profit Loss->Hit Ratio->Hit Fail->Days->ROI->Annualized Rate Of Return->User Defined Statistic->' +
'Candle->Cycle->' +
'Begin->End->Open->Close->Min->Max->Index->' +
'Begin->End->Last Begin->Last End->Open->Close->Min->Max->Index->' +
'Distance To Event->' +
'Head Of The Market->Process Date->' +
'Trigger On->Trigger Off->Take Position->Close Position->Next Phase->Move To Phase->Create Order->Cancel Order->Close Order->' +
@@ -92,8 +92,8 @@ function newSessionFunctions() {
'Strategy Counters->' +
'Position->' +
'Entry Target Rate->Exit Target Rate->' +
'Stop Loss->Stop Loss Phase->Stop Loss Position->' +
'Take Profit->Take Profit Phase->Take Profit Position->' +
'Stop Loss->Stop Loss Phase->Stop Loss Position->Begin->End->Initial Value->Final Value->' +
'Take Profit->Take Profit Phase->Take Profit Position->Begin->End->Initial Value->Final Value->' +
'Position Counters->' +
'Position Statistics->Days->User Defined Statistic->' +
'Position Base Asset->Position Quoted Asset->Entry Target Size->Exit Target Size->' +
@@ -103,7 +103,7 @@ function newSessionFunctions() {
'Exchange Id->Rate->Order Name->Algorithm Name->Lock->' +
'Order Counters->' +
'Order Base Asset->Order Quoted Asset->' +
'Size->Size Filled->Fees Paid->' +
'Actual Size->Size->Size Filled->Amount Received->Fees Paid->Fees To Be Paid->' +
'Order Statistics->Percentage Filled->Actual Rate->Days->User Defined Statistic->' +
'Strategy Trigger Stage->Strategy Open Stage->Strategy Manage Stage->Strategy Close Stage->' +
'Begin->End->Exit Type->Status->Begin Rate->End Rate->Stage Base Asset->Stage Quoted Asset->Size Placed->Target Size->Size Filled->Fees Paid->Stage Defined In->' +
@@ -115,7 +115,7 @@ function newSessionFunctions() {
lightingPath = '' +
'Backtesting Session->Paper Trading Session->Forward Testing Session->Live Trading Session->' +
'Parameters->' +
'Trading Parameters->' +
'Session Base Asset->Session Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->Snapshots->Heartbeats->User Defined Parameters->' +
'Exchange Account Asset->Asset->' +
'Social Bots->Telegram Bot->'
@@ -134,9 +134,9 @@ function newSessionFunctions() {
}
if (resume !== true) {
eventsServerClient.raiseEvent(key, 'Run Session', event)
eventsServerClient.raiseEvent(key, 'Run Trading Session', event)
} else {
eventsServerClient.raiseEvent(key, 'Resume Session', event)
eventsServerClient.raiseEvent(key, 'Resume Trading Session', event)
}
if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
@@ -153,12 +153,12 @@ function newSessionFunctions() {
return
}
let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id)
let eventsServerClient = UI.projects.superalgos.spaces.designSpace.workspace.eventsServerClients.get(networkNode.id)
let key = node.name + '-' + node.type + '-' + node.id
eventsServerClient.raiseEvent(key, 'Stop Session')
eventsServerClient.raiseEvent(key, 'Stop Trading Session')
node.payload.uiObject.stop(callBackFunction)
node.payload.uiObject.stop(callBackFunction, undefined, true)
}
function validations(node) {
@@ -168,7 +168,7 @@ function newSessionFunctions() {
}
if (node.payload.parentNode.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Session needs to be inside a Trading Process Instance.')
node.payload.uiObject.setErrorMessage('Session needs to be inside a Process Instance node.')
return
}
@@ -1,7 +1,8 @@
function newUiObjectsFromNodes() {
thisObject = {
syncronizeTasksFoundAtWorkspaceWithBackEnd: syncronizeTasksFoundAtWorkspaceWithBackEnd,
syncronizeSessionsFoundAtWorkspaceWithBackEnd: syncronizeSessionsFoundAtWorkspaceWithBackEnd,
syncronizeTradingSessionsFoundAtWorkspaceWithBackEnd: syncronizeTradingSessionsFoundAtWorkspaceWithBackEnd,
syncronizeLearningSessionsFoundAtWorkspaceWithBackEnd: syncronizeLearningSessionsFoundAtWorkspaceWithBackEnd,
playTutorials: playTutorials,
recreateWorkspace: recreateWorkspace,
getNodeById: getNodeById,
@@ -14,7 +15,8 @@ function newUiObjectsFromNodes() {
let mapOfReferenceChildren = new Map()
let mapOfNodes
let tasksFoundAtWorkspace
let sessionsFoundAtWorkspace
let tradingSessionsFoundAtWorkspace
let learningSessionsFoundAtWorkspace
let tutorialsToPlay
return thisObject
@@ -26,7 +28,8 @@ function newUiObjectsFromNodes() {
function recreateWorkspace(node, callBackFunction) {
mapOfNodes = new Map()
tasksFoundAtWorkspace = []
sessionsFoundAtWorkspace = []
tradingSessionsFoundAtWorkspace = []
learningSessionsFoundAtWorkspace = []
tutorialsToPlay = []
removeNullRootNodes()
@@ -53,29 +56,34 @@ function newUiObjectsFromNodes() {
let rootNode = node.rootNodes[i]
if (rootNode.type === 'Plugins') {
let plugins = rootNode
if (plugins.pluginDataMines !== undefined) {
totalPlugin = totalPlugin + plugins.pluginDataMines.pluginFiles.length
pluginAllTheseFiles(plugins.pluginDataMines.pluginFiles, 'Data-Mines')
}
if (plugins.pluginTradingMines !== undefined) {
totalPlugin = totalPlugin + plugins.pluginTradingMines.pluginFiles.length
pluginAllTheseFiles(plugins.pluginTradingMines.pluginFiles, 'Trading-Mines')
}
if (plugins.pluginTradingSystems !== undefined) {
totalPlugin = totalPlugin + plugins.pluginTradingSystems.pluginFiles.length
pluginAllTheseFiles(plugins.pluginTradingSystems.pluginFiles, 'Trading-Systems')
}
if (plugins.pluginTradingEngines !== undefined) {
totalPlugin = totalPlugin + plugins.pluginTradingEngines.pluginFiles.length
pluginAllTheseFiles(plugins.pluginTradingEngines.pluginFiles, 'Trading-Engines')
}
if (plugins.pluginSuperScripts !== undefined) {
totalPlugin = totalPlugin + plugins.pluginSuperScripts.pluginFiles.length
pluginAllTheseFiles(plugins.pluginSuperScripts.pluginFiles, 'Super-Scripts')
}
if (plugins.pluginTutorials !== undefined) {
totalPlugin = totalPlugin + plugins.pluginTutorials.pluginFiles.length
pluginAllTheseFiles(plugins.pluginTutorials.pluginFiles, 'Tutorials')
if (plugins.pluginProjects === undefined) { continue }
for (let j = 0; j < plugins.pluginProjects.length; j++) {
let project = plugins.pluginProjects[j]
if (project.pluginDataMines !== undefined) {
totalPlugin = totalPlugin + project.pluginDataMines.pluginFiles.length
pluginAllTheseFiles(project.pluginDataMines.pluginFiles, 'Data-Mines')
}
if (project.pluginTradingMines !== undefined) {
totalPlugin = totalPlugin + project.pluginTradingMines.pluginFiles.length
pluginAllTheseFiles(project.pluginTradingMines.pluginFiles, 'Trading-Mines')
}
if (project.pluginTradingSystems !== undefined) {
totalPlugin = totalPlugin + project.pluginTradingSystems.pluginFiles.length
pluginAllTheseFiles(project.pluginTradingSystems.pluginFiles, 'Trading-Systems')
}
if (project.pluginTradingEngines !== undefined) {
totalPlugin = totalPlugin + project.pluginTradingEngines.pluginFiles.length
pluginAllTheseFiles(project.pluginTradingEngines.pluginFiles, 'Trading-Engines')
}
if (project.pluginSuperScripts !== undefined) {
totalPlugin = totalPlugin + project.pluginSuperScripts.pluginFiles.length
pluginAllTheseFiles(project.pluginSuperScripts.pluginFiles, 'Super-Scripts')
}
if (project.pluginTutorials !== undefined) {
totalPlugin = totalPlugin + project.pluginTutorials.pluginFiles.length
pluginAllTheseFiles(project.pluginTutorials.pluginFiles, 'Tutorials')
}
}
}
}
@@ -91,12 +99,12 @@ function newUiObjectsFromNodes() {
for (let i = 0; i < pluginFiles.length; i++) {
let pluginFile = pluginFiles[i]
let name = pluginFile.name
blobService.getFileFromHost(pluginType + '/' + name + '.json', onFileReceived, true)
callWebServer(undefined, 'LoadPlugin' + '/' + 'Superalgos' + '/' + pluginType + '/' + name + '.json', onFileReceived)
function onFileReceived(err, text, response) {
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
console.log('[WARN] Cannot load plugin ' + pluginType + ' ' + name + '. The workspace will be loaded with this plugin file missing.')
console.log('[WARN] Cannot load plugin ' + pluginType + ' ' + name + '. The Workspace will be loaded with this plugin file missing.')
} else {
let receivedNode = JSON.parse(text)
/*
@@ -158,12 +166,20 @@ function newUiObjectsFromNodes() {
tasksFoundAtWorkspace = undefined
}
function syncronizeSessionsFoundAtWorkspaceWithBackEnd(functionLibrarySessionFunctions) {
for (let i = 0; i < sessionsFoundAtWorkspace.length; i++) {
let node = sessionsFoundAtWorkspace[i]
function syncronizeTradingSessionsFoundAtWorkspaceWithBackEnd(functionLibrarySessionFunctions) {
for (let i = 0; i < tradingSessionsFoundAtWorkspace.length; i++) {
let node = tradingSessionsFoundAtWorkspace[i]
functionLibrarySessionFunctions.syncronizeSessionWithBackEnd(node)
}
sessionsFoundAtWorkspace = undefined
tradingSessionsFoundAtWorkspace = undefined
}
function syncronizeLearningSessionsFoundAtWorkspaceWithBackEnd(functionLibrarySessionFunctions) {
for (let i = 0; i < learningSessionsFoundAtWorkspace.length; i++) {
let node = learningSessionsFoundAtWorkspace[i]
functionLibrarySessionFunctions.syncronizeSessionWithBackEnd(node)
}
learningSessionsFoundAtWorkspace = undefined
}
function playTutorials() {
@@ -216,14 +232,10 @@ function newUiObjectsFromNodes() {
}
function createUiObjectFromNode(node, parentNode, chainParent, positionOffset) {
/* Code needed to Migrante from Beta 5 to Beta 6 a Trading System
if (node.type === 'Take Profit') {
node.type = 'Managed Take Profit'
/* Migration code from beta 6 to beta 7 */
if (node.project === undefined) {
node.project = 'Superalgos'
}
if (node.type === 'Stop') {
node.type = 'Managed Stop Loss'
}
*/
/*
This function can be called with a positionOffset to change the node
@@ -320,18 +332,21 @@ function newUiObjectsFromNodes() {
}
}
function addUIObject(parentNode, type) {
function addUIObject(parentNode, type, rootNodes, project) {
if (project === undefined) { project = parentNode.project }
let object = {
name: 'New ' + type,
type: type
type: type,
project: project
}
let parentNodeDefinition = getNodeDefinition(parentNode)
let parentNodeDefinition = getNodeDefinition(parentNode, project)
if (parentNodeDefinition === undefined) {
console.log('Cannot addUIOBject from parent of ' + type + ' because that type it is not defined at the APP_SCHEMA.')
}
/* Resolve Initial Values */
let nodeDefinition = getNodeDefinition(object)
let nodeDefinition = getNodeDefinition(object, project)
if (nodeDefinition === undefined) {
console.log('Cannot addUIOBject of ' + type + ' because that type it is not defined at the APP_SCHEMA.')
@@ -349,8 +364,8 @@ function newUiObjectsFromNodes() {
}
}
if (nodeDefinition.isHierarchyHead === true) {
parentNode.rootNodes.push(object)
if (nodeDefinition.isHierarchyHead === true || nodeDefinition.isProjectHead) {
rootNodes.push(object)
createUiObject(true, object.type, object.name, object, parentNode, undefined)
return object
}
@@ -462,7 +477,7 @@ function newUiObjectsFromNodes() {
return object
}
function addMissingChildren(node) {
function addMissingChildren(node, rootNodes) {
let nodeDefinition = getNodeDefinition(node)
/* Connect to Parent */
@@ -473,7 +488,7 @@ function newUiObjectsFromNodes() {
if (property.type === 'node') {
if (property.name !== previousPropertyName) {
if (node[property.name] === undefined) {
addUIObject(node, property.childType)
addUIObject(node, property.childType, rootNodes)
previousPropertyName = property.name
}
}
@@ -495,8 +510,8 @@ function newUiObjectsFromNodes() {
*/
let testNode = mapOfNodes.get(node.id)
if (testNode !== undefined && testNode.cleaned !== true) {
console.log(testNode.name + ' already have the id of the node ' + node.name + ' being added.')
node.id = newUniqueId()
console.log(testNode.name + ' already have the id of the node ' + node.name + ' being added. Creating a new id for it: ' + node.id)
}
}
@@ -562,9 +577,16 @@ function newUiObjectsFromNodes() {
/* Chain parent pointing to the position of the chain parent if defined. */
if (chainParent === undefined) {
payload.targetPosition = {
x: spawnPosition.x,
y: spawnPosition.y
if (parentNode !== undefined) {
payload.targetPosition = {
x: parentNode.payload.position.x,
y: parentNode.payload.position.y
}
} else {
payload.targetPosition = {
x: spawnPosition.x,
y: spawnPosition.y
}
}
} else {
payload.targetPosition = {
@@ -586,7 +608,7 @@ function newUiObjectsFromNodes() {
payload.node = node
payload.parentNode = parentNode
payload.chainParent = chainParent
payload.onMenuItemClick = canvas.designSpace.workspace.onMenuItemClick
payload.executeAction = UI.projects.superalgos.spaces.designSpace.workspace.executeAction
node.payload = payload
node.type = uiObjectType
@@ -608,18 +630,18 @@ function newUiObjectsFromNodes() {
frame.width = node.savedPayload.frame.width
frame.height = node.savedPayload.frame.height
frame.radius = node.savedPayload.frame.radius
saveFrame(payload, frame)
UI.projects.superalgos.utilities.loadSaveFrame.saveFrame(payload, frame)
}
if (node.savedPayload.tutorial !== undefined) {
let tutorial = {
status: node.savedPayload.tutorial.status
}
saveTutorial(payload, tutorial)
UI.projects.superalgos.utilities.tutorial.saveTutorial(payload, tutorial)
}
}
/* Now we mount the floating object where the UIOBject will be laying on top of */
canvas.floatingSpace.uiObjectConstructor.createUiObject(userAddingNew, payload)
UI.projects.superalgos.spaces.floatingSpace.uiObjectConstructor.createUiObject(userAddingNew, payload)
/* This is the point where we build a map with all nodes present at the workspace */
mapOfNodes.set(node.id, node)
@@ -634,8 +656,13 @@ function newUiObjectsFromNodes() {
/* Check if there are sessions to run */
if (userAddingNew === false && node.savedPayload !== undefined) {
if (uiObjectType === 'Live Trading Session' || uiObjectType === 'Forward Testing Session' || uiObjectType === 'Backtesting Session' || uiObjectType === 'Paper Trading Session') {
if (sessionsFoundAtWorkspace !== undefined) { // it might be undefined when you are spawning a session that was running while backed up
sessionsFoundAtWorkspace.push(node)
if (tradingSessionsFoundAtWorkspace !== undefined) { // it might be undefined when you are spawning a session that was running while backed up
tradingSessionsFoundAtWorkspace.push(node)
}
}
if (uiObjectType === 'Learning Session') {
if (learningSessionsFoundAtWorkspace !== undefined) { // it might be undefined when you are spawning a session that was running while backed up
learningSessionsFoundAtWorkspace.push(node)
}
}
}
@@ -6,10 +6,10 @@ function newWebhookFunctions() {
return thisObject
function sendTestMessage(node, callBackFunction) {
let testMessage = loadPropertyFromNodeConfig(node.payload, 'testMessage')
let letURL = loadPropertyFromNodeConfig(node.payload, 'webhookURL')
let testMessage = UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(node.payload, 'testMessage')
let letURL = UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(node.payload, 'webhookURL')
callServer(testMessage, letURL, onResponse)
callWebServer(testMessage, letURL, onResponse)
function onResponse(err) {
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
@@ -0,0 +1,32 @@
function newWorkspaceFunctions() {
thisObject = {
addMissingWorkspaceProjects: addMissingWorkspaceProjects
}
return thisObject
function addMissingWorkspaceProjects(node, rootNodes, functionLibraryUiObjectsFromNodes) {
let url = 'ProjectNames'
callWebServer(undefined, url, onResponse)
function onResponse(err, pProjects) {
let projects = JSON.parse(pProjects)
for (let i = 0; i < projects.length; i++) {
let project = projects[i]
let alreadyExist = false
for (let j = 0; j < rootNodes.length; j++) {
let rootNode = rootNodes[j]
if (rootNode.type === project + ' Project') {
alreadyExist = true
}
}
if (alreadyExist === false) {
let child = functionLibraryUiObjectsFromNodes.addUIObject(node, project + ' Project', rootNodes, project)
child.project = project
}
}
}
}
}
@@ -0,0 +1,7 @@
function newSuperalgosGlobalsDocs() {
thisObject = {
DOCUMENTATION_URL_PREFIX: 'https://docs.superalgos.org/',
DOCUMENTATION_URL_DEFAULT: 'https://docs.superalgos.org/suite-about-this-documentation.html'
}
return thisObject
}
@@ -0,0 +1,15 @@
function newSuperalgosGlobalsZoom() {
thisObject = {
DOUBLE_CLICK_ZOOM_OUT_LEVEL: 0,
DOUBLE_CLICK_ZOOM_IN_LEVEL: 6,
DOUBLE_CLICK_ZOOM_IN_IN_LEVEL: 7,
ZOOM_OUT_THRESHOLD_FOR_NOT_HIDDING_PANELS: 12,
ZOOM_OUT_THRESHOLD_FOR_HIDDING_PANELS: 7,
ZOOM_OUT_THRESHOLD_FOR_CHANGING_TIME_FRAME: 3,
ZOOM_OUT_THRESHOLD_FOR_PACKING_OBJECTS_AT_THE_BOTTOM_OR_TOP_OF_VIEWPORT: 2,
ZOOM_OUT_THRESHOLD_FOR_PLOTTING_IN_LOW_RESOLUTION: 3,
ZOOM_OUT_THRESHOLD_FOR_DISPLAYING_TIME_MACHINES_ICONIZED: 5,
ZOOM_OUT_THRESHOLD_FOR_DISPLAYING_SCALES: 3
}
return thisObject
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Loaded 100 of 700 files, more files were not shown because too many files have changed in this diff. Show more