Compare commits
No files matched your search
@@ -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
|
||||
@@ -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",
|
||||
|
||||
@@ -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'
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 926 KiB After Width: | Height: | Size: 1.1 MiB |
@@ -8,7 +8,7 @@
|
||||
<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>
|
||||
|
||||
<!-- Documentation Style Sheets -->
|
||||
@@ -49,12 +49,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 +74,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=""> Stop </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=""> Skip </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=""> Next </label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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('-');
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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. ') }
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 @@
|
||||
{"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,725 @@
|
||||
[
|
||||
{
|
||||
"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 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": "walletKeys",
|
||||
"type": "node",
|
||||
"childType": "Wallet Keys",
|
||||
"autoAdd": true
|
||||
},
|
||||
{
|
||||
"name": "walletAccount",
|
||||
"type": "array",
|
||||
"childType": "Wallet Account"
|
||||
}
|
||||
],
|
||||
"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\"webSocketsPort\": \"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,224 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
"spaces": []
|
||||
}
|
||||
]
|
||||
@@ -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
|
||||
}
|
||||
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 16 KiB |