diff --git a/Environment.js b/Environment.js index efd66849b..47627f378 100644 --- a/Environment.js +++ b/Environment.js @@ -8,6 +8,7 @@ if (process.env.PACKAGED_PATH) { exports.newEnvironment = function () { let thisObject = { + DEMO_MODE: false, BASE_PATH: basePath, WEB_SERVER_URL: 'localhost', PLATFORM_WEB_SOCKETS_INTERFACE_PORT: 18041, diff --git a/Platform/Client/eventServer.js b/Platform/Client/eventServer.js index 7b3067777..dd34a53e7 100644 --- a/Platform/Client/eventServer.js +++ b/Platform/Client/eventServer.js @@ -1,8 +1,5 @@ exports.newEventServer = function newEventServer() { - const MODULE = "Events Server" - const LOG_INFO = false - let thisObject = { initialize: initialize, finalize: finalize, diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index 08e617350..0d2f8a2a3 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -44,7 +44,11 @@ exports.newHttpInterface = function newHttpInterface() { let endpointOrFile = requestPath[1] switch (endpointOrFile) { - + case 'Environment': + { + SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(global.env), httpResponse) + } + break case 'WEB3': { SA.projects.foundations.utilities.httpRequests.getRequestBody(httpRequest, httpResponse, processRequest) diff --git a/Platform/Client/webSocketsInterface.js b/Platform/Client/webSocketsInterface.js index 5797173da..6159d840b 100644 --- a/Platform/Client/webSocketsInterface.js +++ b/Platform/Client/webSocketsInterface.js @@ -9,7 +9,7 @@ const WEB_SOCKET = SA.nodeModules.ws let socketServer - let port = global.env.PLATFORM_WEB_SOCKETS_INTERFACE_PORT + let port = global.env.PLATFORM_WEB_SOCKETS_INTERFACE_PORT return thisObject @@ -36,13 +36,42 @@ socket.on('message', onMenssage) - function onMenssage(message){ + function onMenssage(message) { try { - if (LOG_INFO === true) { - console.log('Message Received: ' + message.substring(0, 1000)) + if (global.env.DEMO_MODE === true) { + /* + In DEMO MODE we will accept Task / Sessioins Running or Stopping if you are requesting this from localhost only. + */ + if (socket._socket.remoteAddress !== "::1") { + if ( + message.toString().indexOf('"eventType":"Run Task"') >= 0 + || + message.toString().indexOf('"eventType":"Stop Task"') >= 0 + || + message.toString().indexOf('"eventType":"Run Trading Session"') >= 0 + || + message.toString().indexOf('"eventType":"Stop Trading Session"') >= 0 + || + message.toString().indexOf('"eventType":"Resume Trading Session"') >= 0 + || + message.toString().indexOf('"eventType":"Run Learning Session"') >= 0 + || + message.toString().indexOf('"eventType":"Stop Learning Session"') >= 0 + || + message.toString().indexOf('"eventType":"Resume Learning Session"') >= 0 + ) { + console.log('Trying to execute a Task while in DEMO MODE. Some hacking has taken place!') + console.log('Hacker IP Address is: ' + socket._socket.remoteAddress) + return + } + } } - + + if (LOG_INFO === true) { + console.log('Message Received: ' + message.toString().substring(0, 10000)) + } + let messageArray = message.toString().split('|*|') let origin = messageArray[0] diff --git a/Platform/UI/AppPostLoader.js b/Platform/UI/AppPostLoader.js index b73803e3c..9d5cccd81 100644 --- a/Platform/UI/AppPostLoader.js +++ b/Platform/UI/AppPostLoader.js @@ -4,7 +4,7 @@ function newAppPostLoader() { const MODULE_NAME = 'Post Loader' const ERROR_LOG = true const logger = newWebDebugLog() - + let thisObject = { start: start @@ -14,9 +14,18 @@ function newAppPostLoader() { function start() { try { - + // autoSaveWhenClosingTheBrowser() - setupProjectsSchema() + setupEnvironment() + + function setupEnvironment() { + httpRequest(undefined, 'Environment', onResponse) + + function onResponse(err, file) { + UI.environment = JSON.parse(file) + setupProjectsSchema() + } + } function setupProjectsSchema() { httpRequest(undefined, 'ProjectsSchema', onResponse) diff --git a/Platform/UI/Globals.js b/Platform/UI/Globals.js index b3588616d..83bf7c5de 100644 --- a/Platform/UI/Globals.js +++ b/Platform/UI/Globals.js @@ -5,7 +5,8 @@ let PROJECTS_SCHEMA let SCHEMAS_BY_PROJECT = new Map() /* New Root object*/ let UI = { - projects: {} + projects: {}, + environment: {} } /* User Interface Colors */ diff --git a/Projects/Algorithmic-Trading/UI/Function-Libraries/TradingSessionFunctions.js b/Projects/Algorithmic-Trading/UI/Function-Libraries/TradingSessionFunctions.js index 66fc16d5e..1a3d66ec7 100644 --- a/Projects/Algorithmic-Trading/UI/Function-Libraries/TradingSessionFunctions.js +++ b/Projects/Algorithmic-Trading/UI/Function-Libraries/TradingSessionFunctions.js @@ -42,6 +42,15 @@ function newAlgorithmicTradingFunctionLibraryTradingSessionFunctions() { } function runSession(node, resume, callBackFunction) { + + if (UI.environment.DEMO_MODE === true) { + if (window.location.hostname !== 'localhost') { + node.payload.uiObject.setWarningMessage('Superalgos is running is DEMO MODE. This means that you can not RUN Sessions.', 5) + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + return + } + } + let validationsResult = validations(node) if (validationsResult === undefined) { /* If something fails at validations we just quit. */ @@ -164,7 +173,7 @@ function newAlgorithmicTradingFunctionLibraryTradingSessionFunctions() { let defaultExchange = UI.projects.visualScripting.utilities.nodeConfig.loadConfigProperty(validationsResult.exchange.payload, 'codeName') let defaultMarket = UI.projects.visualScripting.utilities.nodeConfig.loadConfigProperty(validationsResult.market.baseAsset.payload.referenceParent.payload, 'codeName') - + '-' + + + '-' + UI.projects.visualScripting.utilities.nodeConfig.loadConfigProperty(validationsResult.market.quotedAsset.payload.referenceParent.payload, 'codeName') let dependencyFilter = UI.projects.foundations.functionLibraries.dependenciesFilter.createDependencyFilter( @@ -195,6 +204,15 @@ function newAlgorithmicTradingFunctionLibraryTradingSessionFunctions() { } function stopSession(node, callBackFunction) { + + if (UI.environment.DEMO_MODE === true) { + if (window.location.hostname !== 'localhost') { + node.payload.uiObject.setWarningMessage('Superalgos is running is DEMO MODE. This means that you can not STOP Sessions.', 5) + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + return + } + } + let validationsResult = validations(node) if (validationsResult === undefined) { /* If something fails at validations we just quit. */ diff --git a/Projects/Foundations/UI/Function-Libraries/TaskFunctions.js b/Projects/Foundations/UI/Function-Libraries/TaskFunctions.js index 2f66119c7..4e1884a41 100644 --- a/Projects/Foundations/UI/Function-Libraries/TaskFunctions.js +++ b/Projects/Foundations/UI/Function-Libraries/TaskFunctions.js @@ -90,6 +90,14 @@ function newFoundationsFunctionLibraryTaskFunctions() { function runTask(node, isDebugging, callBackFunction) { + if (UI.environment.DEMO_MODE === true) { + if (window.location.hostname !== 'localhost') { + node.payload.uiObject.setWarningMessage('Superalgos is running is DEMO MODE. This means that you can not RUN Tasks.', 5) + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + return + } + } + let lanNetworkNode = validations(node) if (lanNetworkNode === undefined) { /* This means that the validations failed. */ @@ -218,6 +226,15 @@ function newFoundationsFunctionLibraryTaskFunctions() { } function stopTask(node, callBackFunction) { + + if (UI.environment.DEMO_MODE === true) { + if (window.location.hostname !== 'localhost') { + node.payload.uiObject.setWarningMessage('Superalgos is running is DEMO MODE. This means that you can not STOP Tasks.', 5) + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + return + } + } + let lanNetworkNode = validations(node) if (lanNetworkNode === undefined) { /* This means that the validations failed. */ diff --git a/Projects/Governance/Plugins/Pools/Superalgos.json b/Projects/Governance/Plugins/Pools/Superalgos.json index 89861b27c..30ed151de 100644 --- a/Projects/Governance/Plugins/Pools/Superalgos.json +++ b/Projects/Governance/Plugins/Pools/Superalgos.json @@ -1064,7 +1064,7 @@ "floatingObject": { "isPinned": false, "isFrozen": false, - "isCollapsed": true, + "isCollapsed": false, "angleToParent": 1, "distanceToParent": 3, "arrangementStyle": 0 diff --git a/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json b/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json index 9a85a4ee1..e67809472 100644 --- a/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json +++ b/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json @@ -11847,7 +11847,7 @@ "type": "Tokens Awarded", "name": "New Tokens Awarded", "project": "Governance", - "id": "b66c668c-8411-4401-8aa7-10d8b2c4c233", + "id": "90876ef0-3d01-4a3f-afc8-52914972a040", "savedPayload": { "position": { "x": 33628.04190627182, diff --git a/Projects/Machine-Learning/UI/Function-Libraries/LearningSessionFunctions.js b/Projects/Machine-Learning/UI/Function-Libraries/LearningSessionFunctions.js index c4323334b..bfd25b838 100644 --- a/Projects/Machine-Learning/UI/Function-Libraries/LearningSessionFunctions.js +++ b/Projects/Machine-Learning/UI/Function-Libraries/LearningSessionFunctions.js @@ -42,6 +42,15 @@ function newMachineLearningFunctionLibraryLearningSessionFunctions() { } function runSession(node, resume, callBackFunction) { + + if (UI.environment.DEMO_MODE === true) { + if (window.location.hostname !== 'localhost') { + node.payload.uiObject.setWarningMessage('Superalgos is running is DEMO MODE. This means that you can not execute Sessions.', 5) + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + return + } + } + let validationsResult = validations(node) if (validationsResult === undefined) { /* If something fails at validations we just quit. */ @@ -74,13 +83,13 @@ function newMachineLearningFunctionLibraryLearningSessionFunctions() { 'Layers API->Core API->' + 'Sequential Model->Functional Model->' + 'Data Reporting->' + - 'Input Layer->Sequential layer->Output Layer->'+ + 'Input Layer->Sequential layer->Output Layer->' + 'Input Features->Data Feature->Feature Formula->Input Shape->Batch Input Shape->Feature Preprocessing->MinMax Scaler->Standard Scaler->Collection Condition->' + 'Output Labels->Data Label->Label Formula->' + 'Advanced Activation Layers->Basic Layers->Convolutional Layers->' + 'Conv 1D Layer->Conv 2D Layer->Conv 2D Transpose Layer->Conv 3D Layer->Cropping 2D Layer->Depthwise Convo 2D Layer->Separable Convo 2D Layer->Up Sampling 2D Layer->' + 'Activation Layer->Dense Layer->Dropout Layer->Embedding Layer->Flatten Layer->Permutable Layer->Rrepeat Vector Layer->Reshape Layer->Spatial Dropout 1D Layer->' + - 'Elu Layer->Leaky Relu Layer->Prelu Layer->Relu Layer->Softmax Layer->Thresholded Relu Layer->'+ + 'Elu Layer->Leaky Relu Layer->Prelu Layer->Relu Layer->Softmax Layer->Thresholded Relu Layer->' + 'Dimensionality Units->Activation Function->Dtype->Trainable->Weights->Tensor->Kernel->Bias->' + 'Kernel Initializer->Kernel Constraint->Kernel Regularizer->' + 'Bias Initializer->Bias Constraint->Bias Regularizer->' @@ -121,8 +130,8 @@ function newMachineLearningFunctionLibraryLearningSessionFunctions() { 'Serial Number->Identifier->Begin->End->Begin Rate->End Rate->Strategy Name->Status->Exit Type->' + 'Balance->Begin Balance->End Balance->' + 'Index->Situation Name->Formula->Periods->' + - 'Features->Feature->Begin->End->Feature Value->'+ - 'Labels->Label->Begin->End->Label Value->'+ + 'Features->Feature->Begin->End->Feature Value->' + + 'Labels->Label->Begin->End->Label Value->' + 'Predictions->Prediction->Begin->End->Prediction Value->' let learningEngine = UI.projects.visualScripting.functionLibraries.protocolNode.getProtocolNode(node.learningEngineReference.payload.referenceParent, false, true, true, false, false, lightingPath) @@ -169,6 +178,15 @@ function newMachineLearningFunctionLibraryLearningSessionFunctions() { } function stopSession(node, callBackFunction) { + + if (UI.environment.DEMO_MODE === true) { + if (window.location.hostname !== 'localhost') { + node.payload.uiObject.setWarningMessage('Superalgos is running is DEMO MODE. This means that you can not STOP Sessions.', 5) + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + return + } + } + let validationsResult = validations(node) if (validationsResult === undefined) { /* If something fails at validations we just quit. */ diff --git a/platform.js b/platform.js index 5058dba87..28b0de345 100644 --- a/platform.js +++ b/platform.js @@ -26,13 +26,14 @@ if ( console.log('') console.log('TELEGRAM COMMUNITY: https://t.me/superalgoscommunity') console.log('') - console.log('USAGE: node platform [help] [noBrowser] [minMemo]') + console.log('USAGE: node platform [help] [noBrowser] [minMemo] [demoMode]') console.log('') console.log('OPTIONS:') console.log('') console.log(' help: Optional. Use it to see this helping information.') console.log(' noBrowser: Optional. Use it to launch Superalgos Platform Client only. The Superalgos Platform UI will not be loaded.') console.log(' minMemo: Optional. Use it when your hardware has less than 8 Gb or memory.') + console.log(' demoMode: Optional. Use it to launch Superalgos in Demo Mode. Users will be able to use the UI but not run Tasks.') console.log('') console.log('If you are having an error while trying to run the Superalgos Platform Client, consider this:') @@ -68,7 +69,6 @@ console.log('OPTIONS ACCEPTED:') console.log('') let optionsAccepted = 0 - if (process.argv.includes("minMemo")) { optionsAccepted++ console.log('minMemo ..................................................... Running with Minimun Required Memory.') @@ -79,9 +79,15 @@ if (process.argv.includes("noBrowser")) { console.log('noBrowser ................................................... Running without User Interface.') } +if (process.argv.includes("demoMode")) { + optionsAccepted++ + console.log('demoMode .................................................... Running without User Interface.') +} + if (optionsAccepted === 0) { console.log('none ........................................................ Running without any command line options.') } + console.log('') console.log('')