From 62529a5714e12c4ba26c28e16c667c45937ccaf4 Mon Sep 17 00:00:00 2001 From: Matias Date: Sat, 27 Jul 2019 07:27:38 -0300 Subject: [PATCH] Option to obtain ecosystem from file --- Ecosystem.js | 3 + Scripts/AppLoader.js | 84 ++-- Scripts/AppPreLoader.js | 9 +- ecosystem.json | 891 ++++++++++++++++++++++++++++++++++++++++ server.js | 87 ++-- 5 files changed, 1006 insertions(+), 68 deletions(-) create mode 100644 ecosystem.json diff --git a/Ecosystem.js b/Ecosystem.js index 961085e1f..5a06cdc8c 100644 --- a/Ecosystem.js +++ b/Ecosystem.js @@ -18,6 +18,9 @@ function newEcosystem() { } let ECOSYSTEM = JSON.parse(window.localStorage.getItem('ecosystem')); + if (ECOSYSTEM === null || ECOSYSTEM === undefined) { + ECOSYSTEM = getUserEcosystem() + } return thisObject; diff --git a/Scripts/AppLoader.js b/Scripts/AppLoader.js index 4a6a2f49e..4685baf22 100644 --- a/Scripts/AppLoader.js +++ b/Scripts/AppLoader.js @@ -17,11 +17,19 @@ function newAppLoader() { try { if (INFO_LOG === true) { logger.write('[INFO] loadModules -> Entering function.') } - let ecosystem = await loadEcosystem() - window.localStorage.setItem('ecosystem', JSON.stringify(ecosystem)) - let plotters = getPlotters(ecosystem) + window.localStorage.removeItem('ecosystem') - let modulesArray = [ + let plotters, modulesArray + let ecosystem = await loadEcosystem() + if (ecosystem) { + window.localStorage.setItem('ecosystem', JSON.stringify(ecosystem)) + plotters = getPlotters(ecosystem) + } else { + plotters = defaultPlotters() + modulesArray = ['UserEcosystem.js'] + } + + modulesArray = modulesArray.concat([ 'Globals.js', 'Ecosystem.js', @@ -114,7 +122,7 @@ function newAppLoader() { 'Utilities.js', 'Dashboard.js' - ] + ]) modulesArray = modulesArray.concat(plotters) @@ -147,8 +155,8 @@ function newAppLoader() { if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> Starting Advanced Algos Platform.') } dashboard = newDashboard() - dashboard.start() + } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] loadModules -> onRequired -> err = ' + err.stack) } @@ -163,19 +171,13 @@ function newAppLoader() { async function loadEcosystem() { if (INFO_LOG === true) { logger.write('[INFO] loadEcosystem -> Entering function.') } - let headers let accessToken = window.localStorage.getItem('access_token') if (accessToken !== null) { - headers = { - authorization: 'Bearer ' + accessToken - } - } - - let response = await axios({ - url: window.canvasApp.graphQL.masterAppApiUrl, - method: 'post', - data: { - query: ` + let response = await axios({ + url: window.canvasApp.graphQL.masterAppApiUrl, + method: 'post', + data: { + query: ` query { web_GetEcosystem { id @@ -295,22 +297,54 @@ function newAppLoader() { } } ` - }, - headers: headers - }) + }, + headers: { + authorization: 'Bearer ' + accessToken + } + }) - if (response.data.errors) { - if (ERROR_LOG === true) { console.log(spacePad(MODULE_NAME, 50) + ' : ' + '[ERROR] AppPreLoader -> loadEcosystem -> response.text = ' + JSON.stringify(response.data.errors)) } - throw error + if (response.data.errors) { + if (ERROR_LOG === true) { console.log(spacePad(MODULE_NAME, 50) + ' : ' + '[ERROR] AppPreLoader -> loadEcosystem -> response.text = ' + JSON.stringify(response.data.errors)) } + throw error + } + + return response.data.data.web_GetEcosystem } + } - return response.data.data.web_GetEcosystem + function defaultPlotters() { + return [ + 'Plotters/AAMasters/Plotters-Candles-Volumes/Candles.js', + 'PlotterPanels/AAMasters/Plotters-Candles-Volumes/CandlePanel.js', + 'Plotters/AAMasters/Plotters-Candles-Volumes/Volumes.js', + 'PlotterPanels/AAMasters/Plotters-Candles-Volumes/VolumePanel.js', + 'Plotters/AAMasters/Plotters-Stairs-Patterns/CandleStairs.js', + 'Plotters/AAMasters/Plotters-Stairs-Patterns/VolumeStairs.js', + 'Plotters/AAMasters/Plotters-Trading/Details.js', + 'Plotters/AAMasters/Plotters-Trading/History.js', + 'Plotters/AAMasters/Plotters-Bollinger-Bands/BollingerBands.js', + 'PlotterPanels/AAMasters/Plotters-Bollinger-Bands/BollingerBandsPanel.js', + 'Plotters/AAMasters/Plotters-Bollinger-Bands/PercentageBandwidth.js', + 'Plotters/AAMasters/Plotters-Trading-Simulation/TradingSimulation.js', + 'PlotterPanels/AAMasters/Plotters-Trading-Simulation/TradingSimulationPanel.js', + 'Plotters/AAMasters/Plotters-Trading-Simulation/Conditions.js', + 'Plotters/AAMasters/Plotters-Trading-Simulation/Strategies.js', + 'Plotters/AAMasters/Plotters-Trading-Simulation/Trades.js', + 'Plotters/AAMasters/Plotters-Trading-Simulation/SimulationExecution.js', + 'PlotterPanels/AAMasters/Plotters-Trading-Simulation/SimulationExecutionPanel.js', + 'Plotters/AAMasters/Plotters-Bollinger-Channels/BollingerChannels.js', + 'PlotterPanels/AAMasters/Plotters-Bollinger-Channels/ChannelPanel.js', + 'Plotters/AAMasters/Plotters-Bollinger-Channels/BollingerSubChannels.js', + 'PlotterPanels/AAMasters/Plotters-Bollinger-Channels/SubChannelPanel.js', + 'Plotters/AAVikings/Plotters-Linear-Regression-Curve/LRC.js', + 'PlotterPanels/AAVikings/Plotters-Linear-Regression-Curve/ChannelPanel.js', + 'Plotters/AAMasters/Plotters-ROI/CombinedProfits.js' + ] } function getPlotters(ecosystem) { if (INFO_LOG === true) { console.log('[INFO] server -> onBrowserRequest -> onFileRead -> addPlotters -> Entering function.') } - let plotters = [] let devTeams = ecosystem.devTeams let hosts = ecosystem.hosts diff --git a/Scripts/AppPreLoader.js b/Scripts/AppPreLoader.js index 16f924c16..63e9368e8 100644 --- a/Scripts/AppPreLoader.js +++ b/Scripts/AppPreLoader.js @@ -26,9 +26,9 @@ GLOBAL.CUSTOM_OK_RESPONSE = { GLOBAL.CUSTOM_FAIL_RESPONSE = { result: "Fail Because", message: "Custom Message" -}; +}; -let browserCanvas; // This is the canvas object of the browser. +let browserCanvas; // This is the canvas object of the browser. function spacePad(str, max) { str = str.toString(); @@ -167,8 +167,3 @@ function callServer(pContentToSend, pPath, callBackFunction) { } } } - - - - - diff --git a/ecosystem.json b/ecosystem.json new file mode 100644 index 000000000..c8011458c --- /dev/null +++ b/ecosystem.json @@ -0,0 +1,891 @@ +{ + "devTeams": [ + { + "codeName": "AAMasters", + "displayName": "Masters", + "host": { + "url": "https://demo-api-dev.superalgos.org/", + "storage": "localStorage", + "container": "aamasters", + "accessKey": "09e890b76767ede3e10f0526b5036600a6b8d3faac540336e12b493fdb2aa9ed46f86094c34652f99fb6322e5f09806412f17725807f85e4dc4169bd22dd59f0b23aba5251f5544478a1aabf5a2dea5260e6eb0c29af3a788208af85025a02f94950437d501b91fd55b9d97b3d6ac3af4e1161321f78b73ca0fda524dc3a5d03" + }, + "bots": [ + { + "codeName": "AAOlivia", + "displayName": "Olivia", + "type": "Indicator", + "profilePicture": "Olivia.png", + "repo": "AAOlivia-Indicator-Bot", + "configFile": "this.bot.config.json", + "products": [ + { + "codeName": "Candles", + "displayName": "Candles", + "description": "Two sets of files per period that contains candles.", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AAOlivia.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Candles/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AAOlivia.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Candles/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAOlivia.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Candles/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersCandlesVolumes", + "moduleName": "Candles" + } + }, + { + "codeName": "Volumes", + "displayName": "Buy and Sell Volumes", + "description": "Two sets of files per period that contains buy and sell volumes.", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AAOlivia.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Volumes/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AAOlivia.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Volumes/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAOlivia.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Volumes/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersCandlesVolumes", + "moduleName": "Volumes" + } + } + ] + }, + { + "codeName": "AATom", + "displayName": "Tom", + "type": "Indicator", + "profilePicture": "Tom.png", + "repo": "AATom-Indicator-Bot", + "configFile": "this.bot.config.json", + "products": [ + { + "codeName": "Candle-Stairs", + "displayName": "Candle-Stairs Patters", + "description": "Two sets of files per period that contains candle-stairs patterns.", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AATom.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Candle-Stairs/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AATom.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Candle-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AATom.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Candle-Stairs/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersStairsPatterns", + "moduleName": "CandleStairs" + } + }, + { + "codeName": "Volume-Stairs", + "displayName": "Volume-Stairs Patters", + "description": "Two sets of files per period that contains volume-stairs patterns.", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AATom.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Volume-Stairs/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AATom.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Volume-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AATom.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Volume-Stairs/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersStairsPatterns", + "moduleName": "VolumeStairs" + } + } + ] + }, + { + "codeName": "AAChris", + "displayName": "Chris", + "type": "Indicator", + "profilePicture": "Chris.png", + "repo": "AAChris-Indicator-Bot", + "configFile": "this.bot.config.json", + "products": [ + { + "codeName": "Bollinger-Bands", + "displayName": "Bollinger Bands", + "description": "Bollinger Bands", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AAChris.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Bands/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AAChris.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Bands/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAChris.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Bands/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersBollingerBands", + "moduleName": "BollingerBands" + } + }, + { + "codeName": "Percentage-Bandwidth", + "displayName": "Percentage Bandwidth", + "description": "Percentage Bandwidth", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AAChris.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Percentage-Bandwidth/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AAChris.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Percentage-Bandwidth/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAChris.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Percentage-Bandwidth/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersBollingerBands", + "moduleName": "PercentageBandwidth" + } + } + ] + }, + { + "codeName": "AAPaula", + "displayName": "Paula", + "type": "Indicator", + "profilePicture": "Paula.png", + "repo": "AAPaula-Indicator-Bot", + "configFile": "this.bot.config.json", + "products": [ + { + "codeName": "Bollinger-Channels", + "displayName": "Bollinger-Channels", + "description": "Two sets of files per period that contains band-channel patterns.", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AAPaula.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Channels/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AAPaula.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Channels/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAPaula.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Channels/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersBollingerChannels", + "moduleName": "BollingerChannels" + } + }, + { + "codeName": "Bollinger-Sub-Channels", + "displayName": "Bollinger-Sub-Channels", + "description": "Bollinger Sub Channels with slope.", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AAPaula.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Sub-Channels/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AAPaula.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Sub-Channels/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAPaula.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Sub-Channels/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersBollingerChannels", + "moduleName": "BollingerSubChannels" + } + } + ] + } + ], + "plotters": [ + { + "displayName": "Plotters Candles & Volumes", + "codeName": "PlottersCandlesVolumes", + "devTeam": "AAMasters", + "modules": [ + { + "codeName": "Candles", + "moduleName": "Candles", + "description": "Plots traditional red and green candles.", + "profilePicture": "Candles.png", + "panels": [ + { + "codeName": "CandlePanel", + "moduleName": "CandlePanel", + "event": "Current Candle Changed" + } + ] + }, + { + "codeName": "Volumes", + "description": "Plots volumes separated in buy and sell.", + "moduleName": "Volumes", + "profilePicture": "Volumes.png", + "panels": [ + { + "codeName": "VolumePanel", + "moduleName": "VolumePanel", + "event": "Current Volume Changed" + } + ] + } + ], + "repo": "Plotters-Candles-Volumes", + "configFile": "this.plotter.config.json" + }, + { + "displayName": "Plotters Stairs Patterns", + "codeName": "PlottersStairsPatterns", + "devTeam": "AAMasters", + "modules": [ + { + "codeName": "CandleStairs", + "moduleName": "CandleStairs", + "description": "Plots Candle Stairs patterns.", + "profilePicture": "CandleStairs.png", + "panels": [] + }, + { + "codeName": "VolumeStairs", + "description": "Plots Volume Stairs patterns.", + "moduleName": "VolumeStairs", + "profilePicture": "VolumeStairs.png", + "panels": [] + } + ], + "repo": "Plotters-Stairs-Patterns", + "configFile": "this.plotter.config.json" + }, + { + "displayName": "Plotters Trading", + "codeName": "PlottersTrading", + "devTeam": "AAMasters", + "modules": [ + { + "codeName": "Details", + "moduleName": "Details", + "description": "Plots trading decitions in an easy to understand way.", + "panels": [] + }, + { + "codeName": "History", + "moduleName": "History", + "description": "Plots trading history.", + "profilePicture": "History.png", + "panels": [] + } + ], + "repo": "Plotters-Trading", + "configFile": "this.plotter.config.json" + }, + { + "displayName": "Plotters Bollinger Bands", + "codeName": "PlottersBollingerBands", + "devTeam": "AAMasters", + "modules": [ + { + "codeName": "BollingerBands", + "moduleName": "BollingerBands", + "description": "Plots Bollinger Bands.", + "profilePicture": "BollingerBands.png", + "panels": [ + { + "codeName": "BollingerBandsPanel", + "moduleName": "BollingerBandsPanel", + "event": "Current Band Changed" + } + ] + }, + { + "codeName": "PercentageBandwidth", + "moduleName": "PercentageBandwidth", + "description": "Plots Bollinger Bands.", + "profilePicture": "PercentageBandwidth.png", + "panels": [] + } + ], + "repo": "Plotters-Bollinger-Bands", + "configFile": "this.plotter.config.json" + }, + { + "displayName": "Plotters Trading Simulation", + "codeName": "PlottersTradingSimulation", + "devTeam": "AAMasters", + "modules": [ + { + "codeName": "TradingSimulation", + "moduleName": "TradingSimulation", + "description": "Plots Bollinger Records.", + "profilePicture": "TradingSimulation.png", + "panels": [ + { + "codeName": "TradingSimulationPanel", + "moduleName": "TradingSimulationPanel", + "event": "Current Record Changed" + } + ] + }, + { + "codeName": "Conditions", + "moduleName": "Conditions", + "description": "Plots Simulation Conditions.", + "profilePicture": "Conditions.png", + "panels": [] + }, + { + "codeName": "Strategies", + "moduleName": "Strategies", + "description": "Plots Strategies.", + "profilePicture": "Strategies.png", + "panels": [] + }, + { + "codeName": "Trades", + "moduleName": "Trades", + "description": "Plots Trades.", + "profilePicture": "Trades.png", + "panels": [] + }, + { + "codeName": "SimulationExecution", + "moduleName": "SimulationExecution", + "description": "Plots Simulation Execution.", + "profilePicture": "SimulationExecution.png", + "panels": [ + { + "codeName": "SimulationExecutionPanel", + "moduleName": "SimulationExecutionPanel", + "event": "Current Record Changed" + } + ] + } + ], + "repo": "Plotters-Trading-Simulation", + "configFile": "this.plotter.config.json" + }, + { + "displayName": "Plotters Bollinger Channels", + "codeName": "PlottersBollingerChannels", + "devTeam": "AAMasters", + "modules": [ + { + "codeName": "BollingerChannels", + "moduleName": "BollingerChannels", + "description": "Plots Bollinger Channels.", + "profilePicture": "BollingerChannels.png", + "panels": [ + { + "codeName": "ChannelPanel", + "moduleName": "ChannelPanel", + "event": "Current Channel Changed" + } + ] + }, + { + "codeName": "BollingerSubChannels", + "moduleName": "BollingerSubChannels", + "description": "Plots Bollinger Sub-Channels.", + "profilePicture": "BollingerSubChannels.png", + "panels": [ + { + "codeName": "SubChannelPanel", + "moduleName": "SubChannelPanel", + "event": "Current Sub-Channel Changed" + } + ] + } + ], + "repo": "Plotters-Bollinger-Channels", + "configFile": "this.plotter.config.json" + } + ] + }, + { + "codeName": "AAVikings", + "displayName": "Vikings", + "host": { + "url": "https://demo-api-dev.superalgos.org/", + "container": "aavikings", + "storage": "localStorage", + "accessKey": "0f38fea438be5adfc5873228f503c55353fb334406128b16a958851b8e47c118a08f0105dd8985d5479758fc4cc3f56c2e2364c2d7c3d0fdffba8d7e9356056a34629e3b926b1ebb940122d973db30b04fc18fab542cbc1afdc032dccf64b0fe308ee6bbc74f82bd350aaebf723428a50d8a699fa2b4b96d58716986ed24069f" + }, + "bots": [ + { + "codeName": "AAGauss", + "displayName": "Gauss", + "type": "Indicator", + "profilePicture": "Gauss.png", + "repo": "AAGauss-Indicator-Bot", + "configFile": "this.bot.config.json", + "products": [ + { + "codeName": "LRCPoints", + "displayName": "LRCPoints", + "description": "Two sets of files per period that contains LRC points.", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAVikings/AAGauss.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/LRC-Points/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAVikings/AAGauss.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/LRC-Points/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAVikings/AAGauss.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/LRC-Points/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAVikings", + "codeName": "PlotterLinearRegressionCurve", + "moduleName": "LRC" + } + } + ] + } + ], + "plotters": [ + { + "displayName": "Plotter LRC", + "codeName": "PlotterLinearRegressionCurve", + "devTeam": "AAVikings", + "modules": [ + { + "codeName": "LRC", + "moduleName": "LRC", + "description": "Plots the linear regression curve.", + "profilePicture": "LRC.png", + "panels": [ + { + "codeName": "ChannelPanel", + "moduleName": "ChannelPanel", + "event": "Current LRC Changed" + } + ] + } + ], + "repo": "Plotters-Linear-Regression-Curve", + "configFile": "this.plotter.config.json" + } + ] + } + ], + "hosts": [ + { + "codeName": "AAMasters", + "displayName": "AA Arena", + "host": { + "url": "https://demo-api-dev.superalgos.org/", + "storage": "localStorage", + "container": "aamasters", + "accessKey": "09e890b76767ede3e10f0526b5036600a6b8d3faac540336e12b493fdb2aa9ed46f86094c34652f99fb6322e5f09806412f17725807f85e4dc4169bd22dd59f0b23aba5251f5544478a1aabf5a2dea5260e6eb0c29af3a788208af85025a02f94950437d501b91fd55b9d97b3d6ac3af4e1161321f78b73ca0fda524dc3a5d03" + }, + "competitions": [ + { + "codeName": "Weekend-Deathmatch", + "description": "First AA Internal Competition. Bots will be trading during 3 days at the USDT/BTC market of Poloniex to see who can make the gratest return over investment (ROI).", + "displayName": "AA Internal Challenge", + "startDatetime": "2018-01-01T16:00:00.000Z", + "finishDatetime": "2018-01-02T16:00:00.000Z", + "formula": "ROI", + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersROI", + "host": { + "url": "https://demo-api-dev.superalgos.org/", + "storage": "localStorage", + "container": "aamasters", + "accessKey": "" + }, + "moduleName": "CombinedProfits", + "repo": "Plotters-ROI" + }, + "rules": [], + "prizes": [], + "participants": [], + "repo": "Weekend-Deathmatch", + "configFile": "this.competition.config.json" + } + ], + "plotters": [ + { + "displayName": "Plotters ROI", + "codeName": "PlottersROI", + "devTeam": "AAMasters", + "modules": [ + { + "codeName": "CombinedProfits", + "moduleName": "CombinedProfits", + "description": "Plots participants of a competition by the ROI each one had over time.", + "panels": [] + } + ], + "repo": "Plotters-ROI", + "configFile": "this.plotter.config.json" + } + ] + } + ] +} diff --git a/server.js b/server.js index bf9b8bd69..cbf374b02 100644 --- a/server.js +++ b/server.js @@ -34,12 +34,9 @@ let http = require('http') let port = process.env.PORT || 1337 let isHttpServerStarted = false -const FILE_CLOUD = require('./Server/FileCloud') -let fileCloud = FILE_CLOUD.newFileCloud() - startHtttpServer() -function startHtttpServer () { +function startHtttpServer() { if (CONSOLE_LOG === true) { console.log('[INFO] server -> startHtttpServer -> Entering function.') } try { @@ -52,7 +49,7 @@ function startHtttpServer () { } } -function onBrowserRequest (request, response) { +function onBrowserRequest(request, response) { if (CONSOLE_LOG === true && request.url.indexOf('NO-LOG') === -1) { console.log('[INFO] server -> onBrowserRequest -> request.url = ' + request.url) } let requestParameters = request.url.split('/') @@ -148,15 +145,15 @@ function onBrowserRequest (request, response) { { if (requestParameters[3] === undefined) { - respondWithFile(process.env.PATH_TO_CANVAS_APP + '/StrategySpace/' + requestParameters[2], response) + respondWithFile(process.env.PATH_TO_CANVAS_APP + '/StrategySpace/' + requestParameters[2], response) return } if (requestParameters[4] === undefined) { - respondWithFile(process.env.PATH_TO_CANVAS_APP + '/StrategySpace/' + requestParameters[2] + '/' + requestParameters[3], response) + respondWithFile(process.env.PATH_TO_CANVAS_APP + '/StrategySpace/' + requestParameters[2] + '/' + requestParameters[3], response) return } if (requestParameters[5] === undefined) { - respondWithFile(process.env.PATH_TO_CANVAS_APP + '/StrategySpace/' + requestParameters[2] + '/' + requestParameters[3] + '/' + requestParameters[4], response) + respondWithFile(process.env.PATH_TO_CANVAS_APP + '/StrategySpace/' + requestParameters[2] + '/' + requestParameters[3] + '/' + requestParameters[4], response) return } } @@ -182,13 +179,21 @@ function onBrowserRequest (request, response) { case 'Plotters': // This means the plotter folder, not to be confused with the Plotters script! { - respondWithSourceCode(requestParameters, response) + let devTeam = requestParameters[2] + let codeName = requestParameters[3] + let moduleName = requestParameters[4] + let filePath = './Plotters/' + devTeam + '/plotters/' + codeName + '/' + moduleName + respondWithFile(filePath, response) } break case 'PlotterPanels': // This means the PlotterPanels folder, not to be confused with the Plotter Panels scripts! { - respondWithSourceCode(requestParameters, response) + let devTeam = requestParameters[2] + let codeName = requestParameters[3] + let moduleName = requestParameters[4] + let filePath = './Plotters/' + devTeam + '/plotters/' + codeName + '/' + moduleName + respondWithFile(filePath, response) } break case 'Panels': @@ -233,20 +238,48 @@ function onBrowserRequest (request, response) { } break + case 'UserEcosystem.js': + { + let fs = require('fs') + try { + let filePath = process.env.ECOSYSTEM_PATH + 'ecosystem.json' + fs.readFile(filePath, onFileRead) + + function onFileRead(err, userEcosystem) { + 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. + + if (err) { + response.writeHead(404, { 'Content-Type': 'text/html' }) + } else { + let responseContent = 'function getUserEcosystem(){ return ' + userEcosystem + '}' + response.writeHead(200, { 'Content-Type': 'text/html' }) + response.write(responseContent) + } + + response.end('\n') + } + } catch (e) { + console.log('[ERROR] Error reading the user ecosystem') + } + } + break + default: { homePage() } } - function homePage () { + function homePage() { if (requestParameters[1] === '') { let fs = require('fs') try { let fileName = 'index.html' fs.readFile(fileName, onFileRead) - function onFileRead (err, file) { + function onFileRead(err, file) { if (CONSOLE_LOG === true) { console.log('[INFO] server -> onBrowserRequest -> onFileRead -> Entering function.') } try { @@ -272,7 +305,7 @@ function onBrowserRequest (request, response) { } } -function respondWithContent (content, response) { +function respondWithContent(content, response) { if (CONSOLE_LOG === true) { console.log('[INFO] server -> respondWithContent -> Entering function.') } try { @@ -290,7 +323,7 @@ function respondWithContent (content, response) { } } -function respondWithFile (fileName, response) { +function respondWithFile(fileName, response) { if (CONSOLE_LOG === true) { console.log('[INFO] server -> respondWithFile -> Entering function.') } let fs = require('fs') @@ -302,7 +335,7 @@ function respondWithFile (fileName, response) { fs.readFile(fileName, onFileRead) - function onFileRead (err, file) { + function onFileRead(err, file) { if (CONSOLE_LOG === true) { console.log('[INFO] server -> respondWithFile -> onFileRead -> Entering function.') } try { @@ -328,14 +361,14 @@ function respondWithFile (fileName, response) { } } -function respondWithImage (fileName, response) { +function respondWithImage(fileName, response) { if (CONSOLE_LOG === true) { console.log('[INFO] server -> respondWithImage -> Entering function.') } let fs = require('fs') try { fs.readFile(fileName, onFileRead) - function onFileRead (err, file) { + function onFileRead(err, file) { if (CONSOLE_LOG === true) { console.log('[INFO] server -> respondWithImage -> onFileRead -> Entering function.') } try { @@ -355,7 +388,7 @@ function respondWithImage (fileName, response) { } } -function returnEmptyArray (response) { +function returnEmptyArray(response) { try { if (CONSOLE_LOG === true) { console.log('[INFO] server -> respondWithFile -> returnEmptyArray -> Entering function.') } @@ -370,21 +403,3 @@ function returnEmptyArray (response) { console.log('[ERROR] server -> returnEmptyArray -> err.message ' + err.message) } } - -function respondWithSourceCode (requestParameters, response) { - let devTeam = requestParameters[2] - let codeName = requestParameters[3] - let moduleName = requestParameters[4] - - let filePath = devTeam + '/plotters/' + codeName + '/' + moduleName - - fileCloud.getBlobToText(devTeam.toLowerCase(), filePath, null, onDataArrived) - - function onDataArrived (err, pData) { - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { - console.log('[ERROR] server -> onBrowserRequest -> respondWithSourceCode -> Could not read a file -> err.message = ' + err.message, err.stack) - pData = '' - } - respondWithContent(pData, response) - } -}