From 57d988fc253eed87d581bfb3ae04d7dbc5b022c6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 4 Mar 2018 15:11:02 +0100 Subject: [PATCH] Some comments and config moved to AAPlatform --- .vs/AAWebPlatform/v15/.suo | Bin 80384 -> 71168 bytes AAWebPlatform.njsproj | 3 - ecosystem.json | 255 ------------------------------------- server.js | 38 ++++-- 4 files changed, 30 insertions(+), 266 deletions(-) delete mode 100644 ecosystem.json diff --git a/.vs/AAWebPlatform/v15/.suo b/.vs/AAWebPlatform/v15/.suo index a4cbb8bd03d74e0bed8a7832e7137c16aa6a2146..22e83fd572d882c41ba72035e8d8850e1fdd71b6 100644 GIT binary patch delta 3203 zcmcJR4^Wf$8OQUyc|#BgLVkbsm$OdV8;w9|@$iii>rsSdRw>cm!r8J&WYU^{QK zb~O39#=E-f`qHv>=WUwT4bI&;gr0TPS+6=>*Y(DFwj17dw_4hX>tx^O%^NQ3cGq>i z{_Z|`{{8;F&+mDEZ+v62@3{QT+*FIfU@(Ha6B82<1_Jhzwf`Vd9pg+K$^GefhSV#x zj6;>8L+YSx@uBnt#frVgW#SccVOI+x_1PRZ7);=wm?+YC(pdP|&Val}*Ha-Yb^R-l zNgxxXfON11B!e6f4|seWB+qSztN>pISq4LwVG|VYz-2m)wtAQ`Wf?TcZZ0AE?A7xMY*O~K5qZ}KdH-njAGuQ%nQE_aFed-PvJWCs7JJ{>5 z&9;A2cXEK+e%L-BJ|+*viySFC(c@XLhs$6g-2YJqRbn`?sH+u`NEw9ZnV6UY-zUo< z5=%pj%U}U`07U#OBW2JCe{>nlhRtOV-M0j`Rt8^#@*r@7NEvX)|D_DL_9A7#W4H`> z<4(u~FdxhVTq1M9IuHXQr=86`=D@*a@DSihIO~gao$bZYmqyuD(5rQOrN1^)RGS?4 z@cFIYa9&lzb_a>y%WdyO%7)1Gs!5 z17n|t(F4TU(iAmm-}|KGNut}8B2wBM)p2L)r>u|E~9lBQJS05JW$1B#(|a~!FbXT(p29_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!Dd&GHuz9^8-&CtKq689y;F+ zn6k0y`nO(n_zbz&2Ul8RC+AsPt;Up-31uJnK)~%FIC;5HS(=%-rm8%zUT-}}6WMyS z|2wWp4_ArqMO(Ze)S{ex75@ZMS(NYpaXP?%4gJS-FijfwaJa`Fz%iD>z8#~VUJ6w0U8%YW_$^my{ zF0{Yu0>-b5{9Vp8*yk6ixX{`;FgxqLTQ3!lXv5mX3~FhK8_($9_tuPrj^>2vCL(8Z aU7;8n@hc_6)K>_@x0JAPaP|K<+P?vj*jgn3 diff --git a/AAWebPlatform.njsproj b/AAWebPlatform.njsproj index e082539ca..53dafe941 100644 --- a/AAWebPlatform.njsproj +++ b/AAWebPlatform.njsproj @@ -113,9 +113,6 @@ - - Code - diff --git a/ecosystem.json b/ecosystem.json deleted file mode 100644 index 850ecb930..000000000 --- a/ecosystem.json +++ /dev/null @@ -1,255 +0,0 @@ -{ - "devTeams": [ - { - "codeName": "AAMasters", - "displayName": "AA Masters", - "organization": { - "name": "AAMasters", - "type": "Open Source Community", - "displayName": "AA Masters", - "location": "Global", - "leader": "Luis Molina", - "logo": "AAMasters.jpg" - }, - "teamMembers": [ - { - "member": { - "displayName": "Luis Molina", - "githubUsername": "Luis-Fernando-Molina", - "profilePicture": "Luis.jpg" - } - } - ], - "bots": [ - { - "codeName": "AAOlivia", - "displayName": "Olivia", - "type": "Indicator", - "version": { - "number": "1.0.0", - "status": "Mantained" - }, - "products": [ - { - "codeName": "Candles", - "displayName": "Market Candles per Period", - "description": "Two sets of files per period that contains candles.", - "storageAccount": "aaolivia", - "sets": [ - { - "type": "Market Files", - "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ], - "filePath": "@Exchange/Output/Candles/Multi-Period-Market/@Period", - "fileName": "@AssetA_@AssetB.json" - }, - { - "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": "@Exchange/Output/Candles/Multi-Period-Daily/@Period/@Year/@Month/@Day", - "fileName": "@AssetA_@AssetB.json" - } - ], - "exchangeList": [ - { - "name": "Poloniex" - } - ] - , - "plotter": { - "devTeam": "AAMasters", - "repo": "Plotters-Candles-Volumes", - "moduleName": "Candles" - } - }, - { - "codeName": "Volumes", - "displayName": "Buy and Sell Volumes", - "description": "Two sets of files per period that contains buy and sell volumes.", - "storageAccount": "aaolivia", - "sets": [ - { - "type": "Market Files", - "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ], - "filePath": "@Exchange/Output/Volumes/Multi-Period-Market/@Period", - "fileName": "@AssetA_@AssetB.json" - }, - { - "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": "@Exchange/Output/Volumes/Multi-Period-Daily/@Period/@Year/@Month/@Day", - "fileName": "@AssetA_@AssetB.json" - } - ], - "exchangeList": [ - { - "name": "Poloniex" - } - ], - "plotter": { - "devTeam": "AAMasters", - "repo": "Plotters-Candles-Volumes", - "moduleName": "Volumes" - } - } - ], - "storage": { - "sas": "?sv=2017-04-17&ss=f&srt=sco&sp=rl&se=2018-12-31T02:34:32Z&st=2018-02-01T18:34:32Z&spr=https,http&sig=24UJjGDVpPrHjhBoZtt3iKj4sxgenfSV4VTJD2v0q1U%3D", - "fileUri": "https://aaolivia.file.core.windows.net" - } - }, - { - "codeName": "AATom", - "displayName": "Tom", - "type": "Indicator", - "version": { - "number": "1.0.0", - "status": "Mantained" - }, - "products": [ - { - "codeName": "Candle-Stairs", - "displayName": "Candle-Stairs Patters", - "description": "Two sets of files per period that contains candle-stairs patterns.", - "storageAccount": "aatom", - "sets": [ - { - "type": "Market Files", - "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ], - "filePath": "@Exchange/Tom/dataSet.V1/Output/Candle-Stairs/Multi-Period-Market/@Period", - "fileName": "@AssetA_@AssetB.json" - }, - { - "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": "@Exchange/Tom/dataSet.V1/Output/Candle-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day", - "fileName": "@AssetA_@AssetB.json" - } - ], - "exchangeList": [ - { - "name": "Poloniex" - } - ], - "plotter": { - "devTeam": "AAMasters", - "repo": "Plotters-Stairs-Patterns", - "moduleName": "CandleStairs" - } - }, - { - "codeName": "Volume-Stairs", - "displayName": "Volume-Stairs Patters", - "description": "Two sets of files per period that contains volume-stairs patterns.", - "storageAccount": "aatom", - "sets": [ - { - "type": "Market Files", - "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ], - "filePath": "@Exchange/Tom/dataSet.V1/Output/Volume-Stairs/Multi-Period-Market/@Period", - "fileName": "@AssetA_@AssetB.json" - }, - { - "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": "@Exchange/Tom/dataSet.V1/Output/Volume-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day", - "fileName": "@AssetA_@AssetB.json" - } - ], - "exchangeList": [ - { - "name": "Poloniex" - } - ], - "plotter": { - "devTeam": "AAMasters", - "repo": "Plotters-Stairs-Patterns", - "moduleName": "VolumeStairs" - } - } - ], - "storage": { - "sas": "?sv=2017-04-17&ss=f&srt=sco&sp=r&se=2018-12-31T19:28:33Z&st=2018-02-22T11:28:33Z&spr=https&sig=YaprSp9zO%2Fsz0nPPWwPMqPACxZTnYhSWKApfun%2Bfez4%3D", - "fileUri": "https://aatom.file.core.windows.net" - } - }, - { - "codeName": "AAMariam", - "displayName": "Mariam", - "type": "Trading", - "version": { - "number": "1.0.0", - "status": "Mantained" - }, - "products": [ - { - "codeName": "Trading History", - "displayName": "Mariam Trading History", - "description": "General information about Mariam trading history.", - "storageAccount": "aamariam", - "sets": [ - { - "type": "Single File", - "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs", "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ], - "filePath": "@Exchange/Mariam/dataSet.V1/Output/Trading-Process", - "fileName": "Execution.History.json" - } - ], - "exchangeList": [ - { - "name": "Poloniex" - } - ], - "plotter": { - "devTeam": "AAMasters", - "repo": "Plotters-Trading", - "moduleName": "History" - } - } - ], - "storage": { - "sas": "?sv=2017-07-29&ss=f&srt=sco&sp=r&se=2018-12-30T23:44:52Z&st=2018-02-25T15:44:52Z&spr=https&sig=0pzOTcVAAOkgH7C4KmA1Rbs15kyjvVC1XFCsLQYjXKU%3D", - "fileUri": "https://aamariam.file.core.windows.net" - } - } - ], - "plotters": [ - { - "description": "Plots traditional red and green candles.", - "repo": "Plotters-Candles-Volumes", - "moduleName": "Candles", - "target": "Timeline" - }, - { - "description": "Plots volumes separated in buy and sell.", - "repo": "Plotters-Candles-Volumes", - "moduleName": "Volumes", - "target": "Timeline" - }, - { - "description": "Plots Candle Stairs patterns.", - "repo": "Plotters-Stairs-Patterns", - "moduleName": "CandleStairs", - "target": "Timeline" - }, - { - "description": "Plots Volume Stairs patterns.", - "repo": "Plotters-Stairs-Patterns", - "moduleName": "VolumeStairs", - "target": "Timeline" - }, - { - "description": "Plots a trading history.", - "repo": "Plotters-Trading", - "moduleName": "History", - "target": "Timeline" - }, - { - "description": "Plots trading decitions in an easy to understand way.", - "repo": "Plotters-Trading", - "moduleName": "Details", - "target": "Timeline" - } - ] - } - ] -} \ No newline at end of file diff --git a/server.js b/server.js index 1b8a9449b..acf52b795 100644 --- a/server.js +++ b/server.js @@ -6,7 +6,7 @@ if (CONSOLE_LOG === true) { } -let debugMode = false; // This forces the server to read Plotters from the local drive. +let debugMode = true; // This forces the server to read Plotters from the local drive. if (CONSOLE_LOG === true && debugMode === true) { @@ -14,7 +14,7 @@ if (CONSOLE_LOG === true && debugMode === true) { } -let githubPages = new Map; +let githubData = new Map; let ecosystem; let ecosystemObject; @@ -34,7 +34,7 @@ function initialize() { let fs = require('fs'); try { - let fileName = 'ecosystem.json'; + let fileName = '../AAPlatform/ecosystem.json'; fs.readFile(fileName, onFileRead); function onFileRead(err, file) { @@ -83,7 +83,7 @@ function onBrowserRequest(request, response) { case "clear-cache": { - githubPages = new Map; + githubData = new Map; respondWithContent("command acepted", response); @@ -91,6 +91,14 @@ function onBrowserRequest(request, response) { break; case "Plotters.js": { + /* + + This file is build dinamically because it has the code to instantiate the different configured Plotters. The instantiation code + will be generated using a pre-defined string with replacement points. We will go through the configuration file to learn + about all the possible plotters the system can load. + + */ + let fs = require('fs'); try { let fileName = 'Plotters.js'; @@ -121,8 +129,6 @@ function onBrowserRequest(request, response) { let plotter = devTeam.plotters[j]; - /* Now each of these layers has a plotter that we need to define on the Plotter.js file. */ - let caseStringCopy = caseString; let newFunctionName = devTeam.codeName + plotter.repo + plotter.moduleName; @@ -158,6 +164,13 @@ function onBrowserRequest(request, response) { case "Ecosystem.js": { + /* + + At this page we need to insert the configuration file for the whole system that we assamble before at the begining of this module + execution. So what we do is to load a template file with an insertion point where the configuration json is injected in. + + */ + let fs = require('fs'); try { let fileName = 'Ecosystem.js'; @@ -190,6 +203,15 @@ function onBrowserRequest(request, response) { case "Plotters": // This means the plotter folder, not to be confused with the Plotters script! { + /* + + There are 3 different sources for plotters: + + 1.If we are in debug mode, from the filesystem. + 2.If we are in production from a cache we keep in memory at the node server. + 3.If the cache does not have the file, then we get it from github.com, put in on the cache and serve it. + + */ if (debugMode === true) { @@ -197,7 +219,7 @@ function onBrowserRequest(request, response) { } else { - let cacheVersion = githubPages.get(requestParameters[2] + requestParameters[3] + requestParameters[4]) + let cacheVersion = githubData.get(requestParameters[2] + requestParameters[3] + requestParameters[4]) if (cacheVersion !== undefined) { @@ -226,7 +248,7 @@ function onBrowserRequest(request, response) { respondWithContent(cleanString, response); - githubPages.set(requestParameters[2] + requestParameters[3] + requestParameters[4], cleanString); + githubData.set(requestParameters[2] + requestParameters[3] + requestParameters[4], cleanString); } }