From 42869fa65014eeabd74e73039d7cb011468aa756 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 1 Mar 2018 13:43:06 +0100 Subject: [PATCH] Ecosystem.json read from the server and injected into Plottters.js and Index.html --- .vs/AAWebPlatform/v15/.suo | Bin 61440 -> 74752 bytes AAWebPlatform.njsproj | 14 +- BotCard.js | 189 +++++++ ChartLayers/AccumulatedVolumeChartLayer.js | 6 +- ChartLayers/AllTimeChartlayer.js | 4 +- ChartLayers/CandeStickChartLayer.js | 4 +- .../CandleTechnicalAnalisysChartLayer.js | 6 +- ChartLayers/ForecastChartLayer.js | 6 +- ChartLayers/HighLowChartLayer.js | 6 +- ChartLayers/LinearRegressionCurve.js | 4 +- ChartLayers/OrderBooksChartLayer.js | 4 +- ChartLayers/SupportResistanceChartLayer.js | 4 +- ChartLayers/VolumeChartLayer.js | 4 +- .../VolumeTechnicalAnalisysChartLayer.js | 6 +- Ecosystem.js | 456 ++-------------- Panels/BotsLayersPanel.js | 233 -------- Panels/BotsPanel.js | 237 ++++++++ Panels/ChartLayersPanel.js | 244 --------- Plotters.js | 22 + TimeMachine.js | 28 +- TimelineChart.js | 237 ++------ ecosystem.json | 509 ++++++++++++++++++ index.html | 13 +- server.js | 420 ++++++++------- 24 files changed, 1279 insertions(+), 1377 deletions(-) create mode 100644 BotCard.js delete mode 100644 Panels/BotsLayersPanel.js create mode 100644 Panels/BotsPanel.js delete mode 100644 Panels/ChartLayersPanel.js create mode 100644 Plotters.js create mode 100644 ecosystem.json diff --git a/.vs/AAWebPlatform/v15/.suo b/.vs/AAWebPlatform/v15/.suo index 2b3cd7b277d04633c624c6eb5b414f29a4620061..5decbe8809f965199786c690b1d7f69bd2441878 100644 GIT binary patch delta 7728 zcmd^DdvKFg7XQ8^rH>>f(DXs2(v|`(G?=6%ZAyiv4dLAvg%&L+3@%m(#k-z7<6+rKrY4mrh-~@3!vK z;v{aIN$XUzsmN?m?Gxx5)jg`eX=t4qlCe|TJ|4wA1R)&w4wET~C+4JqJPJqw#sD`1 zET4;f7+?t2BamkRJjV>=cLU>r$p9~51f~Hz_LgA&h#<5Hk*K5tzj_k2*5=?O-#le zD9r?B13aW8n9mR97UV@hrLQc0#Ezh_3i)Ed17TZ2P`C{Fs$iLC;*Fbw^?KwhfQDeb z5qT5P3bX`eJZ2-xUSKt#XoTgQ7KZfW`sP5Lz7@-YBslqM_-~j5bI|gGBzR3_XGOkS2rz%ov`A>~ArnFxWFzCLTP%tTIU2B5i(`^f1o2&#c4z%PKM0MnrcQ0P#L@|}P(W@Sj3 zWz8XVrUT1DsS`?vU!r|2o8>wbm=EiL4ZtRV2eu(^_mxeG)QYea;Cr8YLTo$=30y&s zMC3Pdx!X;mzx;rPg>1E9G3V`A9q+3wutIbdP0`>DOQ#v94JL+Et`eohN z$)bz&0=6mp5nhnW;?q>K1X>flNi`E*EqcCQ{>My`{&pAIN4%{UO%P5BX&~>&5(4q1 z-jO=dUr`h$GQ(+eQzm&UPOzsW@4~JAVyA|w!17`FDC~-%b;YywBG1p9P}ZT|;&w5g zR+p6M3=l&f{Y^S{IVymY|EhnYSf@w7&PCTZH;G>rH^QAG3DvSn7i#5s$ zlk#JAVnhtaDtnT=aa)J}HND9DW+PMj;g6Q;Mnb^8RS`uCZB1qxl~txZn1!} z6nQPB@}HglCyIZ}U#>p#M zn^tYuu-R+Hrq`OYi_P-hSlZDwa>8ITn_Wbr$uL;8Nc;eGh7yn z&0;q>{Z&P5ALOm7h+zM$km8DbB=E6olZKA&zCEI}p~>s@w6scJy)s>-v)$R^v)EZi z*KHdA{j+G6IWz1JnC?EhdsGIcCZy^(tYe3wED#n2wY~_8%%CpQczHk^BoE1w)Oo2o z4hX74256xr!3P0Szg_EOyABA2YdPhMRM3;2Zb5|W6kO1URWKv=$$?%r!Yia3USGZa zw@HN`oagrc{E^E?J*yJs8x71$8Y-|L8oaze(6GRg! zIG<)_^y`He(`ywiVWDj5-akSv$GT+t`pr=k{bk7$x?XXx`oo^%RShMqG&Ju(Cge2TRVuf5R9V;5@cx zEy}B2h+1nkT$n!(cLoQ`N`TA}i{#CN-}0*9{wO)~xd@IV6?RFznVIlo8`zI=w8u~(+x}CCOUH_g5Mh_g8!wU|-f^1Mf zKFY4;svGDtsi31h#66knTdP}}R=3o6*ye=RYKNoJv#hki?Ooo~(pWuohe?S+*Ch;X z$8N{N&NAYAFjYDq*+9=jWyhyp)d8z**#YJpS7?ukK1P|pJ_0%zY+Q!u5NiX6a>#wa zqzzi1QV&Cq7E4Qg zsT}8%Wm^GtcP9M2Zt5Vu}TqV+9{!}rp5Kp&WJQ}+3-0Q&dd1qbZfV=NHZaQhxJL^$x+F?mCo~5;*MnIHwvMc)fgD z${A&2NMP?D-)W?2@7_Z_Z&f5!;2hWDGz;+n?!}M)r!pdoUU}EeK?sK;*KLFR+SQ*1 z*&z8`V~FF54_?aUPp=znQ_tLdT19tswu^ppq_51qRw^D&_^x@1@3GaNocc#n)!X;} z6Q*j6Fgdaw)662A;vD0;v3#~cwyj{PYbC4Q3+aYQuSI*KNDCh()? zz-#*4g)#7EBg9(ToK~JXR6X9_XkwCj!KnbYa3eF=2lF%qvUdLzG0@isUqQ9SAQ$_k>Co`jnQe+LJ;CL)Wb z-G}4o)5ChaIK6s!3L<@-_+RJ|4(>y!gD()$?}#@H{x@VGGu8Sy#!b5(53pdY;^c0q z-BHW2L@D==W>J)lHg+fj1i?z~Q}d;pPtQ?brBkK!@_XNi(!uwN!>KuKm^AF{C6RU= zbJ4t0I!c~n!>9K+)+V{r$4Up^FAlqEuP(nh^aS}`1TR}Z)*!3GLHhpBxB#xQ;VddW5p~5W;V8%9NnpazjUwE=&L2CfDI0f=CI)ZVHugcwa3(&(6;Jj1}= zJ;%gk^!dxFQ<_Z&!|YO&po>zsq&HG$*ldFcM=w3rYTL9Nm7XO0phSSLV0L)nWw;cf z&jN5HbtItNKz^vLP-h&}%?Fs09y$I`9zSe(gM0^;Tum%aO*hYtZ2V?Z68< zzz+crUI)1zbkgUhQL)APrz6!_Qly}@mW`4TsUl^*iQTHX zJlGw9?${?sKJ`6LMC6TIU>3Y2M}@YuG8ktPa@rXq-(gM_bRjLvsCkLf($n-Wqg5$Q zHwmM5C3#cwRK2op=1W4cE`MH_gIPzrsoZVYjal23%c*o7olTNP{msatH`sBNC?SqVzrxaSa{mGVxfSvLoU`0i;7DBhho#yi~> z4d&St>zEgWo>L6J!VFtcfsczKBzd}%oHLdw&sElm{xJhzA2aFtF|?>Tj(R@PD@pZH zl431K2nkL=+KVn2LY(P+bUAUZo?jxoV)%YkR!36jlq;fwI+7Qd`2L%L_G|`DQ4-B> zPKEiqeQ!mHQl+tRr;ts1^uI(Gy=Jo6euc`f!CT->@EgGQ`)x?ST0a2!5g?Pfanr}B zoCK%9Y4BI@H}H4x5AX^2CpZJnf^*uQ<6E`9P_wNl%w5DverRZ_CFpUk3J z)i%R%n0OrBbCrSWQXv;EQ(*}_|OLnCh}h{+1KQTN9l6QbY*gq>ki_<6pRPh=klEn z0`ssSKz3Rx$qC41*9XGLT;2b(gGh!8aX|c54c(-JP##w<|0qIF`@)+eNWQ7v08bmgN-F-rls>8qK0E*B^r`-xA0K^phJjO+W*u91Oh+Qp2CRH*Nz}`LK`+bYA0^M-kqK6olk+18yPB3>%e`5IU;tFlua^u!{H;M5#wrVbq zP+flOxQY)&Md(PrZP4`7#FNqA5DEpi3WXN8cg1Q?YyPUH_BPMzrVaG=r<3W`&8D0A z^QMRL9roH?s@InMA&TQm=R1-qCQ|;%NbbG# zqD3Yt1M^a);Ed3Z0kx4vkPAs8GeX@21-6z@*VY{B?M(UF@^pH8EmiKg*B6&0^2xHp z5jk^ZOM}z>NMi%XClzj + + Code + Code @@ -51,9 +54,6 @@ Code - - Code - @@ -81,6 +81,9 @@ Code + + Code + @@ -96,7 +99,7 @@ - + @@ -124,6 +127,9 @@ + + Code + diff --git a/BotCard.js b/BotCard.js new file mode 100644 index 000000000..0be651231 --- /dev/null +++ b/BotCard.js @@ -0,0 +1,189 @@ +function newBotCard() { + + var thisObject = { + container: undefined, + draw: draw, + status: 'off', + devTeam: undefined, + bot: undefined, + product: undefined, + code: undefined, + layer: undefined, + getContainer: getContainer, // returns the inner most container that holds the point received by parameter. + initialize: initialize + }; + + var container = newContainer(); + container.initialize(); + container.isDraggeable = false; + container.isZoomeable = false; + container.isClickeable = true; + thisObject.container = container; + + return thisObject; + + function initialize() { + + /* Lets set the basic dimensions of this thisObject. */ + + var position = { + x: 0, + y: 0 + }; + + this.container.frame.position = position; + this.container.frame.width = 280; + this.container.frame.height = 28; + + /* Now we start listening to the onClick event from the mouse, so that we can allow users operate this thisObject. */ + + + } + + function getContainer(point) { + + var container; + + /* First we check if this point is inside this space. */ + + if (this.container.frame.isThisPointHere(point, true) === true) { + + return this.container; + + } else { + + /* This point does not belong to this space. */ + + return undefined; + } + + } + + + + function draw() { + + drawIcon(); + + } + + + function drawIcon() { + + centerPoint = { + x: 7, + y: 7 + }; + + /* Now the transformations. */ + + centerPoint = thisObject.container.frame.frameThisPoint(centerPoint); + + /* Lets start the drawing. */ + + browserCanvasContext.beginPath(); + browserCanvasContext.arc(centerPoint.x, centerPoint.y, 3, 0, 2 * Math.PI); + browserCanvasContext.closePath(); + + let offFillStyle = 'rgba(232, 28, 28, 1)'; + let onFillStyle = 'rgba(45, 232, 28, 1)'; + + switch (thisObject.status) { + + case 'on': + browserCanvasContext.fillStyle = onFillStyle; + break; + + case 'off': + browserCanvasContext.fillStyle = offFillStyle; + break; + + } + + + browserCanvasContext.fill(); + + browserCanvasContext.strokeStyle = 'rgba(150, 150, 150, 1)'; + browserCanvasContext.lineWidth = 1; + browserCanvasContext.stroke(); + + browserCanvasContext.closePath(); + + + /* print the text */ + + let labelPoint; + let fontSize = 10; + + browserCanvasContext.font = fontSize + 'px Courier New'; + + let label; + + let xOffset; + let yOffset; + + /* devTeam */ + + label = thisObject.devTeam; + + xOffset = 0; + yOffset = 0; + + labelPoint = { + x: 20, + y: thisObject.container.frame.height - 5 + }; + + labelPoint = thisObject.container.frame.frameThisPoint(labelPoint); + + browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)'; + browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y); + + /* bot */ + + label = thisObject.bot; + + labelPoint = { + x: 40, + y: thisObject.container.frame.height - 5 + }; + + labelPoint = thisObject.container.frame.frameThisPoint(labelPoint); + + browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)'; + browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y); + + /* product */ + + label = thisObject.product; + + labelPoint = { + x: 60, + y: thisObject.container.frame.height - 5 + }; + + labelPoint = thisObject.container.frame.frameThisPoint(labelPoint); + + browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)'; + browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y); + + /* layer */ + + label = thisObject.layer; + + labelPoint = { + x: 80, + y: thisObject.container.frame.height - 5 + }; + + labelPoint = thisObject.container.frame.frameThisPoint(labelPoint); + + browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)'; + browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y); + + + } + + + +} \ No newline at end of file diff --git a/ChartLayers/AccumulatedVolumeChartLayer.js b/ChartLayers/AccumulatedVolumeChartLayer.js index 17b65f02e..4f8403cf5 100644 --- a/ChartLayers/AccumulatedVolumeChartLayer.js +++ b/ChartLayers/AccumulatedVolumeChartLayer.js @@ -43,7 +43,7 @@ function newAccumulatedVolumeChartLayer() { return accumulatedVolumeChartLayer; - function initialize(exchange, market, index, dailyFiles, chartLayersPanel) { + function initialize(exchange, market, index, dailyFiles, botsPanel) { marketId = market; exchangeId = exchange; @@ -58,8 +58,8 @@ function newAccumulatedVolumeChartLayer() { viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged); canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished); - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.BUY_SELL_BALANCE); - parentLayerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.VOLUME); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.BUY_SELL_BALANCE); + parentLayerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.VOLUME); } diff --git a/ChartLayers/AllTimeChartlayer.js b/ChartLayers/AllTimeChartlayer.js index ffef154d7..fd4f51e22 100644 --- a/ChartLayers/AllTimeChartlayer.js +++ b/ChartLayers/AllTimeChartlayer.js @@ -44,7 +44,7 @@ function newAllTimeChartLayer() { return allTimeChartLayer; - function initialize(exchange, market, index, chartLayersPanel) { + function initialize(exchange, market, index, botsPanel) { marketId = market; exchangeId = exchange; @@ -74,7 +74,7 @@ function newAllTimeChartLayer() { } - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.ATH); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.ATH); } diff --git a/ChartLayers/CandeStickChartLayer.js b/ChartLayers/CandeStickChartLayer.js index 2e16796c9..1596602b6 100644 --- a/ChartLayers/CandeStickChartLayer.js +++ b/ChartLayers/CandeStickChartLayer.js @@ -39,7 +39,7 @@ function newCandleStickChartLayer() { return candleStickChartLayer; - function initialize(exchange, market, index, dailyFiles, chartLayersPanel) { + function initialize(exchange, market, index, dailyFiles, botsPanel) { marketId = market; exchangeId = exchange; @@ -61,7 +61,7 @@ function newCandleStickChartLayer() { viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged); canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished); - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.CANDLESTICKS); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.CANDLESTICKS); } diff --git a/ChartLayers/CandleTechnicalAnalisysChartLayer.js b/ChartLayers/CandleTechnicalAnalisysChartLayer.js index df1880189..25700bd2c 100644 --- a/ChartLayers/CandleTechnicalAnalisysChartLayer.js +++ b/ChartLayers/CandleTechnicalAnalisysChartLayer.js @@ -41,7 +41,7 @@ function newCandleTechnicalAnalisysChartLayer() { return candleTechnicalAnalisysChartLayer; - function initialize(exchange, market, index, dailyFiles, chartLayersPanel) { + function initialize(exchange, market, index, dailyFiles, botsPanel) { marketId = market; exchangeId = exchange; @@ -51,8 +51,8 @@ function newCandleTechnicalAnalisysChartLayer() { recalculateScale(); - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.CANDLE_STAIRS); - parentLayerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.CANDLESTICKS); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.CANDLE_STAIRS); + parentLayerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.CANDLESTICKS); } diff --git a/ChartLayers/ForecastChartLayer.js b/ChartLayers/ForecastChartLayer.js index 006706c12..8e2434afd 100644 --- a/ChartLayers/ForecastChartLayer.js +++ b/ChartLayers/ForecastChartLayer.js @@ -41,7 +41,7 @@ function newForecastChartLayer() { return forecastChartLayer; - function initialize(exchange, market, index, dailyFiles, chartLayersPanel) { + function initialize(exchange, market, index, dailyFiles, botsPanel) { marketId = market; exchangeId = exchange; @@ -54,8 +54,8 @@ function newForecastChartLayer() { viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged); canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished); - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.FORECAST); - parentLayerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.CANDLESTICKS); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.FORECAST); + parentLayerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.CANDLESTICKS); } diff --git a/ChartLayers/HighLowChartLayer.js b/ChartLayers/HighLowChartLayer.js index 64f9b10d9..3cc3991de 100644 --- a/ChartLayers/HighLowChartLayer.js +++ b/ChartLayers/HighLowChartLayer.js @@ -41,7 +41,7 @@ function newHighLowChartLayer() { return highLowChartLayer; - function initialize(exchange, market, index, dailyFiles, chartLayersPanel) { + function initialize(exchange, market, index, dailyFiles, botsPanel) { marketId = market; exchangeId = exchange; @@ -51,8 +51,8 @@ function newHighLowChartLayer() { recalculateScale(); - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.HIGH_LOWS); - parentLayerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.CANDLESTICKS); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.HIGH_LOWS); + parentLayerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.CANDLESTICKS); } diff --git a/ChartLayers/LinearRegressionCurve.js b/ChartLayers/LinearRegressionCurve.js index 817058ba9..a04d20f60 100644 --- a/ChartLayers/LinearRegressionCurve.js +++ b/ChartLayers/LinearRegressionCurve.js @@ -40,7 +40,7 @@ function newLinearRegressionCurve() { return linearRegressionCurveChartLayer; - function initialize(exchange, market, index, dailyFiles, chartLayersPanel) { + function initialize(exchange, market, index, dailyFiles, botsPanel) { marketId = market; exchangeId = exchange; @@ -49,7 +49,7 @@ function newLinearRegressionCurve() { recalculateScale(); - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.LINEAR_REGRESION_CURVE); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.LINEAR_REGRESION_CURVE); } function getContainer(point) { diff --git a/ChartLayers/OrderBooksChartLayer.js b/ChartLayers/OrderBooksChartLayer.js index c5a0b2c65..d6155bbfe 100644 --- a/ChartLayers/OrderBooksChartLayer.js +++ b/ChartLayers/OrderBooksChartLayer.js @@ -53,7 +53,7 @@ function newOrderBooksChartLayer() { return orderBooksChartLayer; - function initialize(exchange, market, index, chartLayersPanel) { + function initialize(exchange, market, index, botsPanel) { marketId = market; exchangeId = exchange; @@ -68,7 +68,7 @@ function newOrderBooksChartLayer() { canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished); canvas.eventHandler.listenToEvent("Dragging", onDragging); - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.ORDER_BOOKS); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.ORDER_BOOKS); } diff --git a/ChartLayers/SupportResistanceChartLayer.js b/ChartLayers/SupportResistanceChartLayer.js index 761b61c57..5715f3ffa 100644 --- a/ChartLayers/SupportResistanceChartLayer.js +++ b/ChartLayers/SupportResistanceChartLayer.js @@ -37,7 +37,7 @@ function newSupportResistanceChartLayer() { return supportResistanceChartLayer; - function initialize(exchange, market, index, dailyFiles, chartLayersPanel) { + function initialize(exchange, market, index, dailyFiles, botsPanel) { marketId = market; exchangeId = exchange; @@ -47,7 +47,7 @@ function newSupportResistanceChartLayer() { recalculateScale(); - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.CANDLESTICKS); // TODO : Put the right layer name here when it exists. + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.CANDLESTICKS); // TODO : Put the right layer name here when it exists. } diff --git a/ChartLayers/VolumeChartLayer.js b/ChartLayers/VolumeChartLayer.js index e4bf9ca7c..8906f4f58 100644 --- a/ChartLayers/VolumeChartLayer.js +++ b/ChartLayers/VolumeChartLayer.js @@ -41,7 +41,7 @@ function newVolumeChartLayer() { return volumeChartLayer; - function initialize(exchange, market, index, dailyFiles, chartLayersPanel) { + function initialize(exchange, market, index, dailyFiles, botsPanel) { marketId = market; exchangeId = exchange; @@ -56,7 +56,7 @@ function newVolumeChartLayer() { viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged); canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished); - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.VOLUME); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.VOLUME); } diff --git a/ChartLayers/VolumeTechnicalAnalisysChartLayer.js b/ChartLayers/VolumeTechnicalAnalisysChartLayer.js index bf3249864..bd21c4890 100644 --- a/ChartLayers/VolumeTechnicalAnalisysChartLayer.js +++ b/ChartLayers/VolumeTechnicalAnalisysChartLayer.js @@ -42,7 +42,7 @@ function newVolumeTechnicalAnalisysChartLayer() { return volumeTechnicalAnalisysChartLayer; - function initialize(exchange, market, index, dailyFiles, chartLayersPanel) { + function initialize(exchange, market, index, dailyFiles, botsPanel) { marketId = market; exchangeId = exchange; @@ -50,8 +50,8 @@ function newVolumeTechnicalAnalisysChartLayer() { marketIndex = index; dailyFilesCursor = dailyFiles; - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.VOLUME_STAIRS); - parentLayerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.VOLUME); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.VOLUME_STAIRS); + parentLayerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.VOLUME); } diff --git a/Ecosystem.js b/Ecosystem.js index 9ebd30d3d..ee488e027 100644 --- a/Ecosystem.js +++ b/Ecosystem.js @@ -3,6 +3,7 @@ function newEcosystem() { let ecosystem = { getTeam: getTeam, + getTeams: getTeams, getBot: getBot, getProduct: getProduct, getLayer: getLayer, @@ -11,431 +12,7 @@ function newEcosystem() { initialize: initialize } - const ECOSYSTEM = { - devTeams: - [{ - codeName: "AAMasters", - 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", - tokens: { - percentDistribution: 100, - totalCollected: 121.45 - } - } - }] - , - bots: - [ - { - codeName: "AAOlivia", - displayName: "Olivia", - type: "Indicator", - version: { - number: "1.0.0", - status: "Mantained", // Discontinued - }, - products: [{ - codeName: "Market Candles", - displayName: "Market Candles per Period", - description: "A set of files per period that contains all candles of one whole market.", - storageAccount: "aaolivia", - filePath: "@Exchange/Output/Candles/Multi-Period-Market/@Period", - fileName: "@AssetA_@AssetB.json", - exchangeList: { - exchange: [{ - name: "Poloniex", - datetimeRange: { - minDatetime: "2017-02-19 19:15:00.000 GMT+0000", - maxDatetime: "2018-02-13 10:10:00.000 GMT+0000" - } - }] - }, - layers: [{ - codeName: "Market Candlesticks", - displayName: "Candlesticks", - exchangeList: ["Poloniex"], - validPeriods: ["24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs"], - plotter: { - devTeam: "AAMasters", - repo: "AAOlivia-Plotter", - moduleName: "Candles", - target: "Timeline" - } - }] - } - , { - codeName: "Market Volumes", - displayName: "Market Volumes per Period", - description: "A set of files per period that contains all volumes of one whole market.", - storageAccount: "aaolivia", - filePath: "@Exchange/Output/Volumes/Multi-Period-Market/@Period", - fileName: "@AssetA_@AssetB.json", - exchangeList: { - exchange: [{ - name: "Poloniex", - datetimeRange: { - minDatetime: "2017-02-19 19:15:00.000 GMT+0000", - maxDatetime: "2018-02-13 10:10:00.000 GMT+0000" - } - }] - }, - layers: [{ - codeName: "Market Volumes", - displayName: "Volumes", - exchangeList: ["Poloniex"], - validPeriods: ["24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs"], - plotter: { - devTeam: "AAMasters", - repo: "AAOlivia-Plotter", - moduleName: "Volumes", - target: "Timeline" - } - }] - }, { - codeName: "Daily Candles", - displayName: "Daily Candles per Period", - description: "A set of files per period that contains all candles of one whole market.", - storageAccount: "aaolivia", - filePath: "@Exchange/Output/Candles/Multi-Period-Daily/@Period/@Year/@Month/@Day", - fileName: "@AssetA_@AssetB.json", - exchangeList: { - exchange: [{ - name: "Poloniex", - datetimeRange: { - minDatetime: "2017-02-19 19:15:00.000 GMT+0000", - maxDatetime: "2018-02-13 10:10:00.000 GMT+0000" - } - }] - }, - layers:[{ - codeName: "Daily Candlesticks", - displayName: "Candlesticks", - exchangeList: ["Poloniex"], - validPeriods: ["45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min"], - plotter: { - devTeam: "AAMasters", - repo: "AAOlivia-Plotter", - moduleName: "Candlesticks", - target: "Timeline" - } - }] - }, { - codeName: "Daily Volumes", - displayName: "Daily Volumes per Period", - description: "A set of files per period that contains all volumes of one whole market.", - storageAccount: "aaolivia", - filePath: "@Exchange/Output/Volumes/Multi-Period-Daily/@Period/@Year/@Month/@Day", - fileName: "@AssetA_@AssetB.json", - exchangeList: { - exchange: [{ - name: "Poloniex", - datetimeRange: { - minDatetime: "2017-02-19 19:15:00.000 GMT+0000", - maxDatetime: "2018-02-13 10:10:00.000 GMT+0000" - } - }] - }, - layers: [{ - codeName: "Daily Volumes", - displayName: "Volumes", - exchangeList: ["Poloniex"], - validPeriods: ["45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min"], - plotter: { - devTeam: "AAMasters", - repo: "AAOlivia-Plotter", - moduleName: "Volumes", - target: "Timeline" - } - }] - }] - , - processes: - { - process: [{ - name: "One-Min-Daily-Candles-Volumes", - description: "Read trades files and generates one minute candles and volumes files for each day." - }] - }, - directDependencies: [], - directDependents: [], - collaboratorsList: [], - github: { - org: "AAMasters", - repos: { - repo: [{ - name: "AABruce", - description: "Produces two data-sets with candles and volumes for all markets at all exchanges.", - openIssues: 0, - openPullRequests: 0, - contributors: 1 - }] - } - }, - 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", // Discontinued - }, - products:[{ - codeName: "Market Candle-Stairs", - displayName: "Market Candle-Stairs per Period", - description: "A set of files per period that contains all candle-stairs of one whole market.", - storageAccount: "aatom", - filePath: "@Exchange/Tom/dataSet.V1/Output/Candle-Stairs/Multi-Period-Market/@Period", - fileName: "@AssetA_@AssetB.json", - exchangeList: { - exchange: [{ - name: "Poloniex", - datetimeRange: { - minDatetime: "2017-02-19 19:15:00.000 GMT+0000", - maxDatetime: "2018-02-13 10:10:00.000 GMT+0000" - } - }] - }, - layers: [{ - codeName: "Market Candle-Stairs", - displayName: "Candle-Stairs", - exchangeList: ["Poloniex"], - validPeriods: ["24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs"], - plotter: { - devTeam: "AAMasters", - repo: "AATom-Plotter", - moduleName: "CandleStairs", - target: "Timeline" - } - }] - }, { - codeName: "Market Volume-Stairs", - displayName: "Market Volume-Stairs per Period", - description: "A set of files per period that contains all volume-stairs of one whole market.", - storageAccount: "aaolivia", - filePath: "@Exchange/Tom/dataSet.V1/Output/Volume-Stairs/Multi-Period-Market/@Period", - fileName: "@AssetA_@AssetB.json", - exchangeList: { - exchange: [{ - name: "Poloniex", - datetimeRange: { - minDatetime: "2017-02-19 19:15:00.000 GMT+0000", - maxDatetime: "2018-02-13 10:10:00.000 GMT+0000" - } - }] - }, - layers: [{ - codeName: "Market Volume-Stairs", - displayName: "Volume-Stairs", - exchangeList: ["Poloniex"], - validPeriods: ["24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs"], - plotter: { - devTeam: "AAMasters", - repo: "AATom-Plotter", - moduleName: "VolumeStairs", - target: "Timeline" - } - }] - }, { - codeName: "Daily Candle-Stairs", - displayName: "Daily Candle-Stairs per Period", - description: "A set of files per period that contains all candle-stairs of one whole market.", - storageAccount: "aatom", - filePath: "@Exchange/Tom/dataSet.V1/Output/Candle-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day", - fileName: "@AssetA_@AssetB.json", - exchangeList: { - exchange: [{ - name: "Poloniex", - datetimeRange: { - minDatetime: "2017-02-19 19:15:00.000 GMT+0000", - maxDatetime: "2018-02-13 10:10:00.000 GMT+0000" - } - }] - }, - layers: [{ - codeName: "Daily Candle-Stairs", - displayName: "Candle-Stairs", - exchangeList: ["Poloniex"], - validPeriods: ["45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min"], - plotter: { - devTeam: "AAMasters", - repo: "AATom-Plotter", - moduleName: "CandleStairs", - target: "Timeline" - } - }] - }, { - codeName: "Daily Volume-Stairs", - displayName: "Daily Volume-Stairs per Period", - description: "A set of files per period that contains all volume-stairs of one whole market.", - storageAccount: "aaotom", - filePath: "@Exchange/Tom/dataSet.V1/Output/Volume-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day", - fileName: "@AssetA_@AssetB.json", - exchangeList: { - exchange: [{ - name: "Poloniex", - datetimeRange: { - minDatetime: "2017-02-19 19:15:00.000 GMT+0000", - maxDatetime: "2018-02-13 10:10:00.000 GMT+0000" - } - }] - }, - layers: [{ - codeName: "Daily Volume-Stairs", - displayName: "Volume-Stairs", - exchangeList: ["Poloniex"], - validPeriods: ["45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min"], - plotter: { - devTeam: "AAMasters", - repo: "AATom-Plotter", - moduleName: "VolumeStairs", - target: "Timeline" - } - }] - }] - , - processes: - { - process: [{ - name: "One-Min-Daily-Candles-Volumes", - description: "Read trades files and generates one minute candles and volumes files for each day." - }] - }, - directDependencies: [], - directDependents: [], - collaboratorsList: [], - github: { - org: "AAMasters", - repos: { - repo: [{ - name: "AABruce", - description: "Produces two data-sets with candles and volumes for all markets at all exchanges.", - openIssues: 0, - openPullRequests: 0, - contributors: 1 - }] - } - }, - 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", // Discontinued - }, - products: [{ - codeName: "Trading History", - displayName: "Mariam Trading History", - description: "General information about Mariam trading history.", - storageAccount: "aamariam", - filePath: "@Exchange/Mariam/dataSet.V1/Output/Trading-Process", - fileName: "Execution.History.json", - exchangeList: { - exchange: [{ - name: "Poloniex", - datetimeRange: { - minDatetime: "2017-02-19 19:15:00.000 GMT+0000", - maxDatetime: "2018-02-13 10:10:00.000 GMT+0000" - } - }] - }, - layers: [{ - codeName: "Trading History", - displayName: "Mariam Trading History", - exchangeList: ["Poloniex"], - validPeriods: ["24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs"], - plotter: { - devTeam: "AAMasters", - repo: "AAMariam-Plotter", - moduleName: "History", - target: "Timeline" - } - }] - }, { - codeName: "Trading Details", - displayName: "Mariam Trading Details", - description: "Detailed information about Mariam execution.", - storageAccount: "aamariam", - filePath: "@Exchange/Mariam/dataSet.V1/Output/Trading-Process//@Year/@Month/@Day/@Hour/@Minute", - fileName: "Execution.Context.json", - exchangeList: { - exchange: [{ - name: "Poloniex", - datetimeRange: { - minDatetime: "2017-02-19 19:15:00.000 GMT+0000", - maxDatetime: "2018-02-13 10:10:00.000 GMT+0000" - } - }] - }, - layers: [{ - codeName: "Trading Details", - displayName: "Mariam Trading Details", - exchangeList: ["Poloniex"], - validPeriods: ["24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs"], - plotter: { - devTeam: "AAMasters", - repo: "AAMariam-Plotter", - moduleName: "Details", - target: "Timeline" - } - }] - }] - , - processes: - { - process: [{ - name: "Trading-Process", - description: "Read trades files and generates one minute candles and volumes files for each day." - }] - }, - directDependencies: [], - directDependents: [], - collaboratorsList: [], - github: { - org: "AAMasters", - repos: { - repo: [{ - name: "AABruce", - description: "Produces two data-sets with candles and volumes for all markets at all exchanges.", - openIssues: 0, - openPullRequests: 0, - contributors: 1 - }] - } - }, - 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' - } - } - ] - } - ] - - }; + const ECOSYSTEM = "@ecosystem.json@"; return ecosystem; @@ -446,6 +23,12 @@ function newEcosystem() { } + function getTeams() { + + return ECOSYSTEM.devTeams; + + } + function getTeam(pTeamCodeName) { for (let i = 0; i < ECOSYSTEM.devTeams.length; i++) { @@ -503,10 +86,31 @@ function newEcosystem() { function getLayers() { - for (let i = 0; i < ecosystem.devTeams.length; i++) { + let allLayers = []; + for (let i = 0; i < ECOSYSTEM.devTeams.length; i++) { + let devTeam = ecosystem.devTeams[i]; + + for (let j = 0; j < devTeam.bots.length; j++) { + + let bot = devTeam.bots[j]; + + for (let k = 0; k < bot.products.length; k++) { + + let product = bot.products[k]; + + for (let l = 0; l < product.layers.length; l++) { + + let layer = product.layers[l]; + + allLayers.push(layer); + } + } + } } + + return allLayers; } } diff --git a/Panels/BotsLayersPanel.js b/Panels/BotsLayersPanel.js deleted file mode 100644 index 8ac476671..000000000 --- a/Panels/BotsLayersPanel.js +++ /dev/null @@ -1,233 +0,0 @@ - - - -function newBotsLayersPanel() { - - - const BUTTONS_STATES = { - ON: 'on', - INVISIBLE: 'invisible', - OFF: 'off' - }; - - const LAYER_NAMES = { - CANDLESTICKS: 'Candlesticks', - VOLUME: 'Volume', - ATH: 'All-time Highs and Lows', - HIGH_LOWS: 'High and Lows', - FORECAST: 'Forecast', - ORDER_BOOKS: 'Order Books', - CANDLE_STAIRS: 'Candle Stairs', - VOLUME_STAIRS: 'Volume Stairs', - BUY_SELL_BALANCE: 'Buy Sell Balance', - LINEAR_REGRESION_CURVE: 'Linear Regression Curve' - }; - - var botsLayersPanel = { - container: undefined, - buttons: undefined, - getLayerStatus: getLayerStatus, - layerNames: LAYER_NAMES, - draw: draw, - getContainer: getContainer, // returns the inner most container that holds the point received by parameter. - initialize: initialize - }; - - var container = newContainer(); - container.initialize(); - container.isDraggeable = true; - container.isZoomeable = false; - botsLayersPanel.container = container; - botsLayersPanel.container.frame.containerName = "Bots Layers Panel"; - - let isInitialized = false; - let buttons; - - return botsLayersPanel; - - - - - function initialize() { - - this.container.frame.width = 200; - this.container.frame.height = 270; - - var position = { - x: viewPort.visibleArea.topLeft.x, - y: viewPort.visibleArea.bottomRight.y - this.container.frame.height - }; - - this.container.frame.position = position; - - var buttonPosition; - - var buttonNames = [LAYER_NAMES.CANDLESTICKS, LAYER_NAMES.VOLUME, LAYER_NAMES.ATH, LAYER_NAMES.HIGH_LOWS, LAYER_NAMES.FORECAST, LAYER_NAMES.ORDER_BOOKS, LAYER_NAMES.CANDLE_STAIRS, LAYER_NAMES.VOLUME_STAIRS, LAYER_NAMES.BUY_SELL_BALANCE, LAYER_NAMES.LINEAR_REGRESION_CURVE]; - var lastY = 5; - buttons = []; - - for (var i = 0; i < buttonNames.length; i++) { - - /* Buttons are going to be one at the right of the other. */ - - var textButton = newTextButton(); - textButton.type = buttonNames[i]; - - textButton.container.displacement.parentDisplacement = this.container.displacement; - textButton.container.zoom.parentZoom = this.container.zoom; - textButton.container.frame.parentFrame = this.container.frame; - - textButton.container.parentContainer = this.container; - - textButton.initialize(); - - buttonPosition = { // The first textButton - x: 10, - y: botsLayersPanel.container.frame.height - botsLayersPanel.container.frame.getBodyHeight() - }; - textButton.container.frame.position.x = buttonPosition.x; - textButton.container.frame.position.y = buttonPosition.y + lastY; - - lastY = lastY + textButton.container.frame.height; - - /* We start listening to the buttons click event, so as to know when one was pressed. */ - - textButton.container.eventHandler.listenToEvent('onMouseClick', buttonPressed, i); - - let storedValue = window.localStorage.getItem(textButton.type); - - if (storedValue !== null) { - - textButton.status = storedValue; - - } else { - - textButton.status = BUTTONS_STATES.ON; - - } - - buttons.push(textButton); - - let eventData = { - layer: textButton.type, - status: textButton.status - } - - botsLayersPanel.container.eventHandler.raiseEvent('Layer Status Changed', eventData); - } - - botsLayersPanel.buttons = buttons; - - isInitialized = true; - - } - - - function getLayerStatus(layerName) { - - for (let i = 0; i < buttons.length; i++) { - - let button = buttons[i]; - - if (button.type === layerName) { - - return button.status; - - } - - } - - return BUTTONS_STATES.OFF; - } - - - function getContainer(point) { - - - - var container; - - /* First we check if this point is inside this space. */ - - if (this.container.frame.isThisPointHere(point, true) === true) { - - /* Now we see which is the inner most container that has it */ - - - for (var i = 0; i < this.buttons.length; i++) { - - container = this.buttons[i].getContainer(point); - - if (container !== undefined) { - - /* We found an inner container which has the point. We return it. */ - - return container; - } - } - - /* The point does not belong to any inner container, so we return the current container. */ - - return this.container; - - } else { - - /* This point does not belong to this space. */ - - return undefined; - } - - } - - - - - function buttonPressed(event, buttonPressedIndex) { - - switch (botsLayersPanel.buttons[buttonPressedIndex].status) { - - case BUTTONS_STATES.ON: - botsLayersPanel.buttons[buttonPressedIndex].status = BUTTONS_STATES.INVISIBLE; - break; - - case BUTTONS_STATES.INVISIBLE: - botsLayersPanel.buttons[buttonPressedIndex].status = BUTTONS_STATES.OFF; - break; - - case BUTTONS_STATES.OFF: - botsLayersPanel.buttons[buttonPressedIndex].status = BUTTONS_STATES.ON; - break; - - } - - - let eventData = { - layer: botsLayersPanel.buttons[buttonPressedIndex].type, - status: botsLayersPanel.buttons[buttonPressedIndex].status - } - - botsLayersPanel.container.eventHandler.raiseEvent('Layer Status Changed', eventData); - - window.localStorage.setItem(botsLayersPanel.buttons[buttonPressedIndex].type, botsLayersPanel.buttons[buttonPressedIndex].status); - - } - - - - function draw() { - - if (isInitialized === false) { return; } - - botsLayersPanel.container.frame.draw(false, false, true); - - for (var i = 0; i < botsLayersPanel.buttons.length; i++) { - botsLayersPanel.buttons[i].draw(); - } - - } - - - - - -} \ No newline at end of file diff --git a/Panels/BotsPanel.js b/Panels/BotsPanel.js new file mode 100644 index 000000000..20efb0a0d --- /dev/null +++ b/Panels/BotsPanel.js @@ -0,0 +1,237 @@ + + + +function newBotsPanel() { + + const CARD_STATES = { + ON: 'on', + OFF: 'off' + }; + + var thisObject = { + container: undefined, + cards: undefined, + getLayerStatus: getLayerStatus, + draw: draw, + getContainer: getContainer, // returns the inner most container that holds the point received by parameter. + initialize: initialize + }; + + var container = newContainer(); + container.initialize(); + container.isDraggeable = true; + container.isZoomeable = false; + thisObject.container = container; + thisObject.container.frame.containerName = "Chart Layers Panel"; + + let isInitialized = false; + let cards; + + let layers = []; + + return thisObject; + + function initialize() { + + this.container.frame.width = 200; + this.container.frame.height = 200; + + var position = { + x: viewPort.visibleArea.topRight.x - this.container.frame.width, + y: viewPort.visibleArea.bottomRight.y - this.container.frame.height + }; + + this.container.frame.position = position; + + /* First thing is to build the layers array */ + + let devTeams = ecosystem.getTeams(); + + for (let i = 0; i < devTeams.length; i++) { + + let devTeam = devTeams[i]; + + for (let j = 0; j < devTeam.bots.length; j++) { + + let bot = devTeam.bots[j]; + + for (let k = 0; k < bot.products.length; k++) { + + let product = bot.products[k]; + + for (let l = 0; l < product.layers.length; l++) { + + let layer = product.layers[l]; + + let panelLayer = { + devTeam: devTeam, + bot: bot, + product: product, + layer: layer + }; + + layers.push(panelLayer); + } + } + } + } + + var cardPosition; + + var lastY = 5; + cards = []; + + for (var i = 0; i < layers.length; i++) { + + let fullCodeName = layers[i].devTeam.codeName + '-' + layers[i].bot.codeName + '-' + layers[i].product.codeName + '-' + layers[i].layer.codeName; + + /* Buttons are going to be one at the right of the other. */ + + var card = newBotCard(); + card.devTeam = layers[i].devTeam.displayName; + card.bot = layers[i].bot.displayName; + card.product = layers[i].product.displayName; + card.layer = layers[i].layer.displayName; + card.code = fullCodeName; + + card.container.displacement.parentDisplacement = this.container.displacement; + card.container.zoom.parentZoom = this.container.zoom; + card.container.frame.parentFrame = this.container.frame; + + card.container.parentContainer = this.container; + + card.initialize(); + + cardPosition = { // The first card + x: 10, + y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight() + }; + card.container.frame.position.x = cardPosition.x; + card.container.frame.position.y = cardPosition.y + lastY; + + lastY = lastY + card.container.frame.height; + + /* We start listening to the cards click event, so as to know when one was pressed. */ + + card.container.eventHandler.listenToEvent('onMouseClick', buttonPressed, i); + + let storedValue = window.localStorage.getItem(card.code); + + if (storedValue !== null) { + + card.status = storedValue; + + } else { + + card.status = CARD_STATES.ON; + + } + + cards.push(card); + + let eventData = { + layer: card.code, + status: card.status + } + + thisObject.container.eventHandler.raiseEvent('Layer Status Changed', eventData); + } + + thisObject.cards = cards; + + isInitialized = true; + + } + + function getLayerStatus(layerName) { + + for (let i = 0; i < cards.length; i++) { + + let button = cards[i]; + + if (button.code === layerName) { + + return button.status; + + } + + } + + return CARD_STATES.OFF; + } + + function getContainer(point) { + + var container; + + /* First we check if this point is inside this space. */ + + if (this.container.frame.isThisPointHere(point, true) === true) { + + /* Now we see which is the inner most container that has it */ + + + for (var i = 0; i < this.cards.length; i++) { + + container = this.cards[i].getContainer(point); + + if (container !== undefined) { + + /* We found an inner container which has the point. We return it. */ + + return container; + } + } + + /* The point does not belong to any inner container, so we return the current container. */ + + return this.container; + + } else { + + /* This point does not belong to this space. */ + + return undefined; + } + + } + + function buttonPressed(event, index) { + + switch (thisObject.cards[index].status) { + + case CARD_STATES.ON: + thisObject.cards[index].status = CARD_STATES.OFF; + break; + + case CARD_STATES.OFF: + thisObject.cards[index].status = CARD_STATES.ON; + break; + + } + + + let eventData = { + layer: thisObject.cards[index].code, + status: thisObject.cards[index].status + } + + thisObject.container.eventHandler.raiseEvent('Layer Status Changed', eventData); + + window.localStorage.setItem(thisObject.cards[index].code, thisObject.cards[index].status); + + } + + function draw() { + + if (isInitialized === false) {return;} + + thisObject.container.frame.draw(false, false, true); + + for (var i = 0; i < thisObject.cards.length; i++) { + thisObject.cards[i].draw(); + } + + } + +} \ No newline at end of file diff --git a/Panels/ChartLayersPanel.js b/Panels/ChartLayersPanel.js deleted file mode 100644 index 282678fd2..000000000 --- a/Panels/ChartLayersPanel.js +++ /dev/null @@ -1,244 +0,0 @@ - - - -function newChartLayersPanel() { - - const BUTTONS_STATES = { - ON: 'on', - INVISIBLE: 'invisible', - OFF: 'off' - }; - - const LAYER_NAMES = { - OLIVIA_CANDLES: 'Olivia Candlesticks', - OLIVIA_VOLUMES: 'Olivia Volumes', - TOM_CANDLE_STAIRS: 'Tom Candle-Stairs', - TOM_VOLUME_STAIRS: 'Tom Volume-Stairs', - MARIAM_TRADE_HISTORY: 'Mariam Trades History', - MARIAM_TRADES_DETAILS: 'Mariam Trades Details', - ATH: 'All-time Highs and Lows', - HIGH_LOWS: 'High and Lows', - FORECAST: 'Forecast', - ORDER_BOOKS: 'Order Books', - CANDLE_STAIRS: 'Candle Stairs', - VOLUME_STAIRS: 'Volume Stairs', - BUY_SELL_BALANCE: 'Buy Sell Balance', - LINEAR_REGRESION_CURVE: 'Linear Regression Curve' - }; - - var panel = { - container: undefined, - buttons: undefined, - getLayerStatus: getLayerStatus, - layerNames: LAYER_NAMES, - draw: draw, - getContainer: getContainer, // returns the inner most container that holds the point received by parameter. - initialize: initialize - }; - - var container = newContainer(); - container.initialize(); - container.isDraggeable = true; - container.isZoomeable = false; - panel.container = container; - panel.container.frame.containerName = "Chart Layers Panel"; - - let isInitialized = false; - let buttons; - - let layers = new Map(); - - return panel; - - function initialize() { - - this.container.frame.width = 200; - this.container.frame.height = 200; - - var position = { - x: viewPort.visibleArea.topRight.x - this.container.frame.width, - y: viewPort.visibleArea.bottomRight.y - this.container.frame.height - }; - - this.container.frame.position = position; - - /* First thing is to build the layers Map */ - - - - - var buttonPosition; - - var buttonNames = [ - LAYER_NAMES.OLIVIA_CANDLES, - LAYER_NAMES.OLIVIA_VOLUMES, - LAYER_NAMES.TOM_CANDLE_STAIRS, - LAYER_NAMES.TOM_VOLUME_STAIRS, - LAYER_NAMES.MARIAM_TRADE_HISTORY, - LAYER_NAMES.MARIAM_TRADES_DETAILS, - LAYER_NAMES.ATH, - LAYER_NAMES.HIGH_LOWS, - LAYER_NAMES.FORECAST, - LAYER_NAMES.ORDER_BOOKS, - LAYER_NAMES.CANDLE_STAIRS, - LAYER_NAMES.VOLUME_STAIRS, - LAYER_NAMES.BUY_SELL_BALANCE, - LAYER_NAMES.LINEAR_REGRESION_CURVE - ]; - var lastY = 5; - buttons = []; - - for (var i = 0; i < buttonNames.length; i++) { - - /* Buttons are going to be one at the right of the other. */ - - var textButton = newTextButton(); - textButton.type = buttonNames[i]; - - textButton.container.displacement.parentDisplacement = this.container.displacement; - textButton.container.zoom.parentZoom = this.container.zoom; - textButton.container.frame.parentFrame = this.container.frame; - - textButton.container.parentContainer = this.container; - - textButton.initialize(); - - buttonPosition = { // The first textButton - x: 10, - y: panel.container.frame.height - panel.container.frame.getBodyHeight() - }; - textButton.container.frame.position.x = buttonPosition.x; - textButton.container.frame.position.y = buttonPosition.y + lastY; - - lastY = lastY + textButton.container.frame.height; - - /* We start listening to the buttons click event, so as to know when one was pressed. */ - - textButton.container.eventHandler.listenToEvent('onMouseClick', buttonPressed, i); - - let storedValue = window.localStorage.getItem(textButton.type); - - if (storedValue !== null) { - - textButton.status = storedValue; - - } else { - - textButton.status = BUTTONS_STATES.ON; - - } - - buttons.push(textButton); - - let eventData = { - layer: textButton.type, - status: textButton.status - } - - panel.container.eventHandler.raiseEvent('Layer Status Changed', eventData); - } - - panel.buttons = buttons; - - isInitialized = true; - - } - - function getLayerStatus(layerName) { - - for (let i = 0; i < buttons.length; i++) { - - let button = buttons[i]; - - if (button.type === layerName) { - - return button.status; - - } - - } - - return BUTTONS_STATES.OFF; - } - - function getContainer(point) { - - - - var container; - - /* First we check if this point is inside this space. */ - - if (this.container.frame.isThisPointHere(point, true) === true) { - - /* Now we see which is the inner most container that has it */ - - - for (var i = 0; i < this.buttons.length; i++) { - - container = this.buttons[i].getContainer(point); - - if (container !== undefined) { - - /* We found an inner container which has the point. We return it. */ - - return container; - } - } - - /* The point does not belong to any inner container, so we return the current container. */ - - return this.container; - - } else { - - /* This point does not belong to this space. */ - - return undefined; - } - - } - - function buttonPressed(event, buttonPressedIndex) { - - switch (panel.buttons[buttonPressedIndex].status) { - - case BUTTONS_STATES.ON: - panel.buttons[buttonPressedIndex].status = BUTTONS_STATES.INVISIBLE; - break; - - case BUTTONS_STATES.INVISIBLE: - panel.buttons[buttonPressedIndex].status = BUTTONS_STATES.OFF; - break; - - case BUTTONS_STATES.OFF: - panel.buttons[buttonPressedIndex].status = BUTTONS_STATES.ON; - break; - - } - - - let eventData = { - layer: panel.buttons[buttonPressedIndex].type, - status: panel.buttons[buttonPressedIndex].status - } - - panel.container.eventHandler.raiseEvent('Layer Status Changed', eventData); - - window.localStorage.setItem(panel.buttons[buttonPressedIndex].type, panel.buttons[buttonPressedIndex].status); - - } - - function draw() { - - if (isInitialized === false) {return;} - - panel.container.frame.draw(false, false, true); - - for (var i = 0; i < panel.buttons.length; i++) { - panel.buttons[i].draw(); - } - - } - -} \ No newline at end of file diff --git a/Plotters.js b/Plotters.js new file mode 100644 index 000000000..1ce6823c0 --- /dev/null +++ b/Plotters.js @@ -0,0 +1,22 @@ + + +function getNewPlotter(pDevTeam, pRepo, pModule) { + + let plotter; + let fullCode = pDevTeam + pRepo + pModule; + + switch (fullCode) { + +// Cases + + default: + { + throw("getNewPlotter: " + fullCode + " not found.") + } + } + + return plotter; +} + + + \ No newline at end of file diff --git a/TimeMachine.js b/TimeMachine.js index cf2be30fa..1dc29ed92 100644 --- a/TimeMachine.js +++ b/TimeMachine.js @@ -24,7 +24,7 @@ function newTimeMachine() { let currentCandlePanel; let currentVolumePanel; - let chartLayersPanel; + let botsPanel; let orderBookPanel; return timeMachine; @@ -46,11 +46,8 @@ function newTimeMachine() { orderBookPanel = newOrderBookPanel(); orderBookPanel.initialize(); - chartLayersPanel = newChartLayersPanel(); - chartLayersPanel.initialize(); - - botsLayersPanel = newBotsLayersPanel(); - botsLayersPanel.initialize(); + botsPanel = newBotsPanel(); + botsPanel.initialize(); let iteration = 0; @@ -70,7 +67,7 @@ function newTimeMachine() { timelineChart.container.frame.position.x = timeMachine.container.frame.width / 2 - timelineChart.container.frame.width / 2; timelineChart.container.frame.position.y = timelineChart.container.frame.height * 1.5 * iteration; - timelineChart.initialize(1, INITIAL_DEFAULT_MARKET, currentCandlePanel, currentVolumePanel, chartLayersPanel, botsLayersPanel, orderBookPanel, onDefaultMarketInitialized); + timelineChart.initialize(1, INITIAL_DEFAULT_MARKET, currentCandlePanel, currentVolumePanel, botsPanel, orderBookPanel, onDefaultMarketInitialized); iteration++; @@ -111,7 +108,7 @@ function newTimeMachine() { timelineChart.container.frame.position.x = timeMachine.container.frame.width / 2 - timelineChart.container.frame.width / 2; timelineChart.container.frame.position.y = timelineChart.container.frame.height * 1.5 * iteration; - timelineChart.initialize(1, key, currentCandlePanel, currentVolumePanel, chartLayersPanel, botsLayersPanel, orderBookPanel, finalSteps); + timelineChart.initialize(1, key, currentCandlePanel, currentVolumePanel, botsPanel, orderBookPanel, finalSteps); iteration++; @@ -259,9 +256,7 @@ function newTimeMachine() { currentVolumePanel.draw(); - chartLayersPanel.draw(); - - botsLayersPanel.draw(); + botsPanel.draw(); orderBookPanel.draw(); @@ -304,16 +299,7 @@ function newTimeMachine() { return container; } - container = chartLayersPanel.getContainer(point); - - if (container !== undefined) { - - /* We found an inner container which has the point. We return it. */ - - return container; - } - - container = botsLayersPanel.getContainer(point); + container = botsPanel.getContainer(point); if (container !== undefined) { diff --git a/TimelineChart.js b/TimelineChart.js index 256fb4f75..c80fdc3dc 100644 --- a/TimelineChart.js +++ b/TimelineChart.js @@ -43,18 +43,16 @@ function newTimelineChart() { let currentCandlePanel; let currentVolumePanel; - let chartLayersPanel; - let botsLayersPanel; + let botsPanel; let orderBookPanel; return timelineChart; - function initialize(exchange, market, currentCandlePanelToUse, currentVolumePanelToUse, chartLayersPanelToUse, botsLayersPanelToUse, orderBookPanelToUse, callBackFunction) { + function initialize(exchange, market, currentCandlePanelToUse, currentVolumePanelToUse, botsPanelToUse, orderBookPanelToUse, callBackFunction) { currentCandlePanel = currentCandlePanelToUse; currentVolumePanel = currentVolumePanelToUse; - chartLayersPanel = chartLayersPanelToUse; - botsLayersPanel = botsLayersPanelToUse; + botsPanel = botsPanelToUse; orderBookPanel = orderBookPanelToUse; marketId = market; @@ -106,9 +104,17 @@ function newTimelineChart() { viewPort.displace(displaceVector); - let layerStatus; + for (let i = 0; i < botsPanel.cards.length; i++) { + + let plotter = newPlotter(); + + + } + + + /* AAMasters AAOlivia Candlesticks */ let layerAAMastersAAOliviaCandlesticks = newAAMastersAAOliviaCandles(); @@ -129,7 +135,7 @@ function newTimelineChart() { layerAAMastersAAOliviaCandlesticks.container.frame.position.x = timelineChart.container.frame.width / 2 - layerAAMastersAAOliviaCandlesticks.container.frame.width / 2; layerAAMastersAAOliviaCandlesticks.container.frame.position.y = timelineChart.container.frame.height / 2 - layerAAMastersAAOliviaCandlesticks.container.frame.height / 2; - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.OLIVIA_CANDLES); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.OLIVIA_CANDLES); layerAAMastersAAOliviaCandlesticks.initialize(DEFAULT_EXCHANGE, DEFAULT_MARKET, INITIAL_DATE, INITIAL_TIME_PERIOD, layerStatus, onInizialized); @@ -162,7 +168,7 @@ function newTimelineChart() { layerAAMastersAAOliviaVolumes.container.frame.position.x = timelineChart.container.frame.width / 2 - layerAAMastersAAOliviaVolumes.container.frame.width / 2; layerAAMastersAAOliviaVolumes.container.frame.position.y = timelineChart.container.frame.height / 2 - layerAAMastersAAOliviaVolumes.container.frame.height / 2; - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.OLIVIA_VOLUMES); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.OLIVIA_VOLUMES); layerAAMastersAAOliviaVolumes.initialize(DEFAULT_EXCHANGE, DEFAULT_MARKET, INITIAL_DATE, INITIAL_TIME_PERIOD, layerStatus, onInizialized); @@ -194,7 +200,7 @@ function newTimelineChart() { layerAAMastersAATomCandleStairs.container.frame.position.x = timelineChart.container.frame.width / 2 - layerAAMastersAATomCandleStairs.container.frame.width / 2; layerAAMastersAATomCandleStairs.container.frame.position.y = timelineChart.container.frame.height / 2 - layerAAMastersAATomCandleStairs.container.frame.height / 2; - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.TOM_CANDLE_STAIRS); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.TOM_CANDLE_STAIRS); layerAAMastersAATomCandleStairs.initialize(DEFAULT_EXCHANGE, DEFAULT_MARKET, INITIAL_DATE, INITIAL_TIME_PERIOD, layerStatus, onInizialized); @@ -227,7 +233,7 @@ function newTimelineChart() { layerAAMastersAATomVolumeStairs.container.frame.position.x = timelineChart.container.frame.width / 2 - layerAAMastersAATomVolumeStairs.container.frame.width / 2; layerAAMastersAATomVolumeStairs.container.frame.position.y = timelineChart.container.frame.height / 2 - layerAAMastersAATomVolumeStairs.container.frame.height / 2; - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.TOM_VOLUME_STAIRS); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.TOM_VOLUME_STAIRS); layerAAMastersAATomVolumeStairs.initialize(DEFAULT_EXCHANGE, DEFAULT_MARKET, INITIAL_DATE, INITIAL_TIME_PERIOD, layerStatus, onInizialized); @@ -260,7 +266,7 @@ function newTimelineChart() { layerAAMastersAAMariamTradingHistory.container.frame.position.x = timelineChart.container.frame.width / 2 - layerAAMastersAAMariamTradingHistory.container.frame.width / 2; layerAAMastersAAMariamTradingHistory.container.frame.position.y = timelineChart.container.frame.height / 2 - layerAAMastersAAMariamTradingHistory.container.frame.height / 2; - layerStatus = chartLayersPanel.getLayerStatus(chartLayersPanel.layerNames.MARIAM_TRADE_HISTORY); + layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.MARIAM_TRADE_HISTORY); layerAAMastersAAMariamTradingHistory.initialize(DEFAULT_EXCHANGE, DEFAULT_MARKET, INITIAL_DATE, INITIAL_TIME_PERIOD, layerStatus, onInizialized); @@ -275,189 +281,6 @@ function newTimelineChart() { } - - /* All Time Layer */ - /* - var allTimeChartLayer = newAllTimeChartLayer(); - - allTimeChartLayer.container.displacement.parentDisplacement = timelineChart.container.displacement; - allTimeChartLayer.container.zoom.parentZoom = timelineChart.container.zoom; - allTimeChartLayer.container.frame.parentFrame = timelineChart.container.frame; - - allTimeChartLayer.container.parentContainer = timelineChart.container; - - allTimeChartLayer.container.frame.width = timelineChart.container.frame.width * 1; - allTimeChartLayer.container.frame.height = timelineChart.container.frame.height * 1; - - allTimeChartLayer.container.frame.position.x = timelineChart.container.frame.width / 2 - allTimeChartLayer.container.frame.width / 2; - allTimeChartLayer.container.frame.position.y = timelineChart.container.frame.height / 2 - allTimeChartLayer.container.frame.height / 2; - - allTimeChartLayer.initialize(exchangeId, marketId, marketIndex, chartLayersPanel); - - /* Orderbook Resistances Layer */ - /* - var orderBooksChartLayer = newOrderBooksChartLayer(); - - orderBooksChartLayer.container.displacement.parentDisplacement = timelineChart.container.displacement; - orderBooksChartLayer.container.zoom.parentZoom = timelineChart.container.zoom; - orderBooksChartLayer.container.frame.parentFrame = timelineChart.container.frame; - - orderBooksChartLayer.container.parentContainer = timelineChart.container; - - orderBooksChartLayer.container.frame.width = timelineChart.container.frame.width * 1; - orderBooksChartLayer.container.frame.height = timelineChart.container.frame.height * 1; - - orderBooksChartLayer.container.frame.position.x = timelineChart.container.frame.width / 2 - orderBooksChartLayer.container.frame.width / 2; - orderBooksChartLayer.container.frame.position.y = timelineChart.container.frame.height / 2 - orderBooksChartLayer.container.frame.height / 2; - - orderBooksChartLayer.initialize(exchangeId, marketId, marketIndex, chartLayersPanel); - - - /* Candle Technical Analisys Layer */ - /* - var candleTechnicalAnalisysChartLayer = newCandleTechnicalAnalisysChartLayer(); - - candleTechnicalAnalisysChartLayer.container.displacement.parentDisplacement = timelineChart.container.displacement; - candleTechnicalAnalisysChartLayer.container.zoom.parentZoom = timelineChart.container.zoom; - candleTechnicalAnalisysChartLayer.container.frame.parentFrame = timelineChart.container.frame; - - candleTechnicalAnalisysChartLayer.container.parentContainer = timelineChart.container; - - candleTechnicalAnalisysChartLayer.container.frame.width = timelineChart.container.frame.width * 1; - candleTechnicalAnalisysChartLayer.container.frame.height = timelineChart.container.frame.height * 1; - - candleTechnicalAnalisysChartLayer.container.frame.position.x = timelineChart.container.frame.width / 2 - candleTechnicalAnalisysChartLayer.container.frame.width / 2; - candleTechnicalAnalisysChartLayer.container.frame.position.y = timelineChart.container.frame.height / 2 - candleTechnicalAnalisysChartLayer.container.frame.height / 2; - - candleTechnicalAnalisysChartLayer.initialize(exchangeId, marketId, marketIndex, dailyFilesCursor, chartLayersPanel); - - - /* Volume Technical Analisys Layer */ - /* - var volumeTechnicalAnalisysChartLayer = newVolumeTechnicalAnalisysChartLayer(); - - volumeTechnicalAnalisysChartLayer.container.displacement.parentDisplacement = timelineChart.container.displacement; - volumeTechnicalAnalisysChartLayer.container.zoom.parentZoom = timelineChart.container.zoom; - volumeTechnicalAnalisysChartLayer.container.frame.parentFrame = timelineChart.container.frame; - - volumeTechnicalAnalisysChartLayer.container.parentContainer = timelineChart.container; - - volumeTechnicalAnalisysChartLayer.container.frame.width = timelineChart.container.frame.width * 1; - volumeTechnicalAnalisysChartLayer.container.frame.height = timelineChart.container.frame.height * 1; - - volumeTechnicalAnalisysChartLayer.container.frame.position.x = timelineChart.container.frame.width / 2 - volumeTechnicalAnalisysChartLayer.container.frame.width / 2; - volumeTechnicalAnalisysChartLayer.container.frame.position.y = timelineChart.container.frame.height / 2 - volumeTechnicalAnalisysChartLayer.container.frame.height / 2; - - volumeTechnicalAnalisysChartLayer.initialize(exchangeId, marketId, marketIndex, dailyFilesCursor, chartLayersPanel); - - - /* Sopport Resistance Layer */ - /* - var supportResistanceChartLayer = newSupportResistanceChartLayer(); - - supportResistanceChartLayer.container.displacement.parentDisplacement = timelineChart.container.displacement; - supportResistanceChartLayer.container.zoom.parentZoom = timelineChart.container.zoom; - supportResistanceChartLayer.container.frame.parentFrame = timelineChart.container.frame; - - supportResistanceChartLayer.container.parentContainer = timelineChart.container; - - supportResistanceChartLayer.container.frame.width = timelineChart.container.frame.width * 1; - supportResistanceChartLayer.container.frame.height = timelineChart.container.frame.height * 1; - - supportResistanceChartLayer.container.frame.position.x = timelineChart.container.frame.width / 2 - supportResistanceChartLayer.container.frame.width / 2; - supportResistanceChartLayer.container.frame.position.y = timelineChart.container.frame.height / 2 - supportResistanceChartLayer.container.frame.height / 2; - - supportResistanceChartLayer.initialize(exchangeId, marketId, marketIndex, dailyFilesCursor, chartLayersPanel); - - - /* High Low Layer */ - /* - var highLowChartLayer = newHighLowChartLayer(); - - highLowChartLayer.container.displacement.parentDisplacement = timelineChart.container.displacement; - highLowChartLayer.container.zoom.parentZoom = timelineChart.container.zoom; - highLowChartLayer.container.frame.parentFrame = timelineChart.container.frame; - - highLowChartLayer.container.parentContainer = timelineChart.container; - - highLowChartLayer.container.frame.width = timelineChart.container.frame.width * 1; - highLowChartLayer.container.frame.height = timelineChart.container.frame.height * 1; - - highLowChartLayer.container.frame.position.x = timelineChart.container.frame.width / 2 - highLowChartLayer.container.frame.width / 2; - highLowChartLayer.container.frame.position.y = timelineChart.container.frame.height / 2 - highLowChartLayer.container.frame.height / 2; - - highLowChartLayer.initialize(exchangeId, marketId, marketIndex, dailyFilesCursor, chartLayersPanel); - - - - - - - - - /* Accumulated Volume Volume Layer */ - /* - var accumulatedVolumeChartLayer = newAccumulatedVolumeChartLayer(); - - accumulatedVolumeChartLayer.container.displacement.parentDisplacement = timelineChart.container.displacement; - accumulatedVolumeChartLayer.container.zoom.parentZoom = timelineChart.container.zoom; - accumulatedVolumeChartLayer.container.frame.parentFrame = timelineChart.container.frame; - - accumulatedVolumeChartLayer.container.parentContainer = timelineChart.container; - - accumulatedVolumeChartLayer.container.frame.width = timelineChart.container.frame.width * 1; - accumulatedVolumeChartLayer.container.frame.height = timelineChart.container.frame.height * 1; - - accumulatedVolumeChartLayer.container.frame.position.x = timelineChart.container.frame.width / 2 - accumulatedVolumeChartLayer.container.frame.width / 2; - accumulatedVolumeChartLayer.container.frame.position.y = timelineChart.container.frame.height / 2 - accumulatedVolumeChartLayer.container.frame.height / 2; - - accumulatedVolumeChartLayer.initialize(exchangeId, marketId, marketIndex, dailyFilesCursor, chartLayersPanel); - - - - /* Forecast Layer */ - /* - var forecastChartLayer = newForecastChartLayer(); - - forecastChartLayer.container.displacement.parentDisplacement = timelineChart.container.displacement; - forecastChartLayer.container.zoom.parentZoom = timelineChart.container.zoom; - forecastChartLayer.container.frame.parentFrame = timelineChart.container.frame; - - forecastChartLayer.container.parentContainer = timelineChart.container; - - forecastChartLayer.container.frame.width = timelineChart.container.frame.width * 1; - forecastChartLayer.container.frame.height = timelineChart.container.frame.height * 1; - - forecastChartLayer.container.frame.position.x = timelineChart.container.frame.width / 2 - forecastChartLayer.container.frame.width / 2; - forecastChartLayer.container.frame.position.y = timelineChart.container.frame.height / 2 - forecastChartLayer.container.frame.height / 2; - - forecastChartLayer.initialize(exchangeId, marketId, marketIndex, dailyFilesCursor, chartLayersPanel); - - // candleStickChartLayer.container.eventHandler.listenToEvent("Current Candle Changed", forecastChartLayer.setCurrentCandle); - // forecastChartLayer.setCurrentCandle(candleStickChartLayer.currentCandle); - - - - /* Linear Regression Curve Layer */ - /* - var linearRegressionCurveChartLayer = newLinearRegressionCurve(); - - linearRegressionCurveChartLayer.container.displacement.parentDisplacement = timelineChart.container.displacement; - linearRegressionCurveChartLayer.container.zoom.parentZoom = timelineChart.container.zoom; - linearRegressionCurveChartLayer.container.frame.parentFrame = timelineChart.container.frame; - - linearRegressionCurveChartLayer.container.parentContainer = timelineChart.container; - - linearRegressionCurveChartLayer.container.frame.width = timelineChart.container.frame.width * 1; - linearRegressionCurveChartLayer.container.frame.height = timelineChart.container.frame.height * 1; - - linearRegressionCurveChartLayer.container.frame.position.x = timelineChart.container.frame.width / 2 - candleTechnicalAnalisysChartLayer.container.frame.width / 2; - linearRegressionCurveChartLayer.container.frame.position.y = timelineChart.container.frame.height / 2 - candleTechnicalAnalisysChartLayer.container.frame.height / 2; - - linearRegressionCurveChartLayer.initialize(exchangeId, marketId, marketIndex, dailyFilesCursor, chartLayersPanel); - */ - - function addLayers() { timelineChart.layers.push(layerAAMastersAATomCandleStairs); // This looks better if it goes below the candles layer. @@ -470,13 +293,13 @@ function newTimelineChart() { /* Connecting all layers to the panel that provides a user interface to turn them on - visible - off */ - chartLayersPanel.container.eventHandler.listenToEvent("Layer Status Changed", layerAAMastersAAOliviaCandlesticks.onLayerStatusChanged); - chartLayersPanel.container.eventHandler.listenToEvent("Layer Status Changed", layerAAMastersAAOliviaVolumes.onLayerStatusChanged); + botsPanel.container.eventHandler.listenToEvent("Layer Status Changed", layerAAMastersAAOliviaCandlesticks.onLayerStatusChanged); + botsPanel.container.eventHandler.listenToEvent("Layer Status Changed", layerAAMastersAAOliviaVolumes.onLayerStatusChanged); - chartLayersPanel.container.eventHandler.listenToEvent("Layer Status Changed", layerAAMastersAATomCandleStairs.onLayerStatusChanged); - chartLayersPanel.container.eventHandler.listenToEvent("Layer Status Changed", layerAAMastersAATomVolumeStairs.onLayerStatusChanged); + botsPanel.container.eventHandler.listenToEvent("Layer Status Changed", layerAAMastersAATomCandleStairs.onLayerStatusChanged); + botsPanel.container.eventHandler.listenToEvent("Layer Status Changed", layerAAMastersAATomVolumeStairs.onLayerStatusChanged); - chartLayersPanel.container.eventHandler.listenToEvent("Layer Status Changed", layerAAMastersAAMariamTradingHistory.onLayerStatusChanged); + botsPanel.container.eventHandler.listenToEvent("Layer Status Changed", layerAAMastersAAMariamTradingHistory.onLayerStatusChanged); } /* Add all layers to the internal array */ @@ -507,16 +330,16 @@ function newTimelineChart() { /* - chartLayersPanel.container.eventHandler.listenToEvent("Layer Status Changed", accumulatedVolumeChartLayer.onLayerStatusChanged); + botsPanel.container.eventHandler.listenToEvent("Layer Status Changed", accumulatedVolumeChartLayer.onLayerStatusChanged); - chartLayersPanel.container.eventHandler.listenToEvent("Layer Status Changed", candleTechnicalAnalisysChartLayer.onLayerStatusChanged); - chartLayersPanel.container.eventHandler.listenToEvent("Layer Status Changed", highLowChartLayer.onLayerStatusChanged); + botsPanel.container.eventHandler.listenToEvent("Layer Status Changed", candleTechnicalAnalisysChartLayer.onLayerStatusChanged); + botsPanel.container.eventHandler.listenToEvent("Layer Status Changed", highLowChartLayer.onLayerStatusChanged); - chartLayersPanel.container.eventHandler.listenToEvent("Layer Status Changed", volumeTechnicalAnalisysChartLayer.onLayerStatusChanged); - chartLayersPanel.container.eventHandler.listenToEvent("Layer Status Changed", allTimeChartLayer.onLayerStatusChanged); - chartLayersPanel.container.eventHandler.listenToEvent("Layer Status Changed", forecastChartLayer.onLayerStatusChanged); - chartLayersPanel.container.eventHandler.listenToEvent("Layer Status Changed", orderBooksChartLayer.onLayerStatusChanged); - chartLayersPanel.container.eventHandler.listenToEvent("Layer Status Changed", linearRegressionCurveChartLayer.onLayerStatusChanged); + botsPanel.container.eventHandler.listenToEvent("Layer Status Changed", volumeTechnicalAnalisysChartLayer.onLayerStatusChanged); + botsPanel.container.eventHandler.listenToEvent("Layer Status Changed", allTimeChartLayer.onLayerStatusChanged); + botsPanel.container.eventHandler.listenToEvent("Layer Status Changed", forecastChartLayer.onLayerStatusChanged); + botsPanel.container.eventHandler.listenToEvent("Layer Status Changed", orderBooksChartLayer.onLayerStatusChanged); + botsPanel.container.eventHandler.listenToEvent("Layer Status Changed", linearRegressionCurveChartLayer.onLayerStatusChanged); */ } diff --git a/ecosystem.json b/ecosystem.json new file mode 100644 index 000000000..7286edc18 --- /dev/null +++ b/ecosystem.json @@ -0,0 +1,509 @@ +{ + "devTeams": [ + { + "codeName": "AAMasters", + "displayName": "Advanced Algos 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", + "tokens": { + "percentDistribution": 100, + "totalCollected": 121.45 + } + } + } + ], + "bots": [ + { + "codeName": "AAOlivia", + "displayName": "Olivia", + "type": "Indicator", + "version": { + "number": "1.0.0", + "status": "Mantained" + }, + "products": [ + { + "codeName": "Market Candles", + "displayName": "Market Candles per Period", + "description": "A set of files per period that contains all candles of one whole market.", + "storageAccount": "aaolivia", + "filePath": "@Exchange/Output/Candles/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json", + "exchangeList": { + "exchange": [ + { + "name": "Poloniex", + "datetimeRange": { + "minDatetime": "2017-02-19 19:15:00.000 GMT+0000", + "maxDatetime": "2018-02-13 10:10:00.000 GMT+0000" + } + } + ] + }, + "layers": [ + { + "codeName": "Market Candlesticks", + "displayName": "Candlesticks", + "exchangeList": [ "Poloniex" ], + "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ], + "plotter": { + "devTeam": "AAMasters", + "repo": "Plotters-Candles-Volumes", + "moduleName": "Candles" + } + } + ] + }, + { + "codeName": "Market Volumes", + "displayName": "Market Volumes per Period", + "description": "A set of files per period that contains all volumes of one whole market.", + "storageAccount": "aaolivia", + "filePath": "@Exchange/Output/Volumes/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json", + "exchangeList": { + "exchange": [ + { + "name": "Poloniex", + "datetimeRange": { + "minDatetime": "2017-02-19 19:15:00.000 GMT+0000", + "maxDatetime": "2018-02-13 10:10:00.000 GMT+0000" + } + } + ] + }, + "layers": [ + { + "codeName": "Market Volumes", + "displayName": "Volumes", + "exchangeList": [ "Poloniex" ], + "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ], + "plotter": { + "devTeam": "AAMasters", + "repo": "Plotters-Candles-Volumes", + "moduleName": "Volumes" + } + } + ] + }, + { + "codeName": "Daily Candles", + "displayName": "Daily Candles per Period", + "description": "A set of files per period that contains all candles of one whole market.", + "storageAccount": "aaolivia", + "filePath": "@Exchange/Output/Candles/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "exchangeList": { + "exchange": [ + { + "name": "Poloniex", + "datetimeRange": { + "minDatetime": "2017-02-19 19:15:00.000 GMT+0000", + "maxDatetime": "2018-02-13 10:10:00.000 GMT+0000" + } + } + ] + }, + "layers": [ + { + "codeName": "Daily Candlesticks", + "displayName": "Candlesticks", + "exchangeList": [ "Poloniex" ], + "validPeriods": [ "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ], + "plotter": { + "devTeam": "AAMasters", + "repo": "Plotters-Candles-Volumes", + "moduleName": "Candlesticks" + } + } + ] + }, + { + "codeName": "Daily Volumes", + "displayName": "Daily Volumes per Period", + "description": "A set of files per period that contains all volumes of one whole market.", + "storageAccount": "aaolivia", + "filePath": "@Exchange/Output/Volumes/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "exchangeList": { + "exchange": [ + { + "name": "Poloniex", + "datetimeRange": { + "minDatetime": "2017-02-19 19:15:00.000 GMT+0000", + "maxDatetime": "2018-02-13 10:10:00.000 GMT+0000" + } + } + ] + }, + "layers": [ + { + "codeName": "Daily Volumes", + "displayName": "Volumes", + "exchangeList": [ "Poloniex" ], + "validPeriods": [ "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ], + "plotter": { + "devTeam": "AAMasters", + "repo": "Plotters-Candles-Volumes", + "moduleName": "Volumes" + } + } + ] + } + ], + "processes": { + "process": [ + { + "name": "One-Min-Daily-Candles-Volumes", + "description": "Read trades files and generates one minute candles and volumes files for each day." + } + ] + }, + "directDependencies": [], + "directDependents": [], + "collaboratorsList": [], + "github": { + "org": "AAMasters", + "repos": { + "repo": [ + { + "name": "AABruce", + "description": "Produces two data-sets with candles and volumes for all markets at all exchanges.", + "openIssues": 0, + "openPullRequests": 0, + "contributors": 1 + } + ] + } + }, + "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": "Market Candle-Stairs", + "displayName": "Market Candle-Stairs per Period", + "description": "A set of files per period that contains all candle-stairs of one whole market.", + "storageAccount": "aatom", + "filePath": "@Exchange/Tom/dataSet.V1/Output/Candle-Stairs/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json", + "exchangeList": { + "exchange": [ + { + "name": "Poloniex", + "datetimeRange": { + "minDatetime": "2017-02-19 19:15:00.000 GMT+0000", + "maxDatetime": "2018-02-13 10:10:00.000 GMT+0000" + } + } + ] + }, + "layers": [ + { + "codeName": "Market Candle-Stairs", + "displayName": "Candle-Stairs", + "exchangeList": [ "Poloniex" ], + "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ], + "plotter": { + "devTeam": "AAMasters", + "repo": "Plotters-Stairs-Patterns", + "moduleName": "CandleStairs" + } + } + ] + }, + { + "codeName": "Market Volume-Stairs", + "displayName": "Market Volume-Stairs per Period", + "description": "A set of files per period that contains all volume-stairs of one whole market.", + "storageAccount": "aaolivia", + "filePath": "@Exchange/Tom/dataSet.V1/Output/Volume-Stairs/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json", + "exchangeList": { + "exchange": [ + { + "name": "Poloniex", + "datetimeRange": { + "minDatetime": "2017-02-19 19:15:00.000 GMT+0000", + "maxDatetime": "2018-02-13 10:10:00.000 GMT+0000" + } + } + ] + }, + "layers": [ + { + "codeName": "Market Volume-Stairs", + "displayName": "Volume-Stairs", + "exchangeList": [ "Poloniex" ], + "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ], + "plotter": { + "devTeam": "AAMasters", + "repo": "Plotters-Stairs-Patterns", + "moduleName": "VolumeStairs" + } + } + ] + }, + { + "codeName": "Daily Candle-Stairs", + "displayName": "Daily Candle-Stairs per Period", + "description": "A set of files per period that contains all candle-stairs of one whole market.", + "storageAccount": "aatom", + "filePath": "@Exchange/Tom/dataSet.V1/Output/Candle-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "exchangeList": { + "exchange": [ + { + "name": "Poloniex", + "datetimeRange": { + "minDatetime": "2017-02-19 19:15:00.000 GMT+0000", + "maxDatetime": "2018-02-13 10:10:00.000 GMT+0000" + } + } + ] + }, + "layers": [ + { + "codeName": "Daily Candle-Stairs", + "displayName": "Candle-Stairs", + "exchangeList": [ "Poloniex" ], + "validPeriods": [ "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ], + "plotter": { + "devTeam": "AAMasters", + "repo": "Plotters-Stairs-Patterns", + "moduleName": "CandleStairs" + } + } + ] + }, + { + "codeName": "Daily Volume-Stairs", + "displayName": "Daily Volume-Stairs per Period", + "description": "A set of files per period that contains all volume-stairs of one whole market.", + "storageAccount": "aaotom", + "filePath": "@Exchange/Tom/dataSet.V1/Output/Volume-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "exchangeList": { + "exchange": [ + { + "name": "Poloniex", + "datetimeRange": { + "minDatetime": "2017-02-19 19:15:00.000 GMT+0000", + "maxDatetime": "2018-02-13 10:10:00.000 GMT+0000" + } + } + ] + }, + "layers": [ + { + "codeName": "Daily Volume-Stairs", + "displayName": "Volume-Stairs", + "exchangeList": [ "Poloniex" ], + "validPeriods": [ "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ], + "plotter": { + "devTeam": "AAMasters", + "repo": "Plotters-Stairs-Patterns", + "moduleName": "VolumeStairs" + } + } + ] + } + ], + "processes": { + "process": [ + { + "name": "One-Min-Daily-Candles-Volumes", + "description": "Read trades files and generates one minute candles and volumes files for each day." + } + ] + }, + "directDependencies": [], + "directDependents": [], + "collaboratorsList": [], + "github": { + "org": "AAMasters", + "repos": { + "repo": [ + { + "name": "AABruce", + "description": "Produces two data-sets with candles and volumes for all markets at all exchanges.", + "openIssues": 0, + "openPullRequests": 0, + "contributors": 1 + } + ] + } + }, + "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", + "filePath": "@Exchange/Mariam/dataSet.V1/Output/Trading-Process", + "fileName": "Execution.History.json", + "exchangeList": { + "exchange": [ + { + "name": "Poloniex", + "datetimeRange": { + "minDatetime": "2017-02-19 19:15:00.000 GMT+0000", + "maxDatetime": "2018-02-13 10:10:00.000 GMT+0000" + } + } + ] + }, + "layers": [ + { + "codeName": "Trading History", + "displayName": "Mariam Trading History", + "exchangeList": [ "Poloniex" ], + "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ], + "plotter": { + "devTeam": "AAMasters", + "repo": "Plotters-Trading", + "moduleName": "History" + } + } + ] + }, + { + "codeName": "Trading Details", + "displayName": "Mariam Trading Details", + "description": "Detailed information about Mariam execution.", + "storageAccount": "aamariam", + "filePath": "@Exchange/Mariam/dataSet.V1/Output/Trading-Process//@Year/@Month/@Day/@Hour/@Minute", + "fileName": "Execution.Context.json", + "exchangeList": { + "exchange": [ + { + "name": "Poloniex", + "datetimeRange": { + "minDatetime": "2017-02-19 19:15:00.000 GMT+0000", + "maxDatetime": "2018-02-13 10:10:00.000 GMT+0000" + } + } + ] + }, + "layers": [ + { + "codeName": "Trading Details", + "displayName": "Mariam Trading Details", + "exchangeList": [ "Poloniex" ], + "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ], + "plotter": { + "devTeam": "AAMasters", + "repo": "Plotters-Trading", + "moduleName": "Details" + } + } + ] + } + ], + "processes": { + "process": [ + { + "name": "Trading-Process", + "description": "Read trades files and generates one minute candles and volumes files for each day." + } + ] + }, + "directDependencies": [], + "directDependents": [], + "collaboratorsList": [], + "github": { + "org": "AAMasters", + "repos": { + "repo": [ + { + "name": "AABruce", + "description": "Produces two data-sets with candles and volumes for all markets at all exchanges.", + "openIssues": 0, + "openPullRequests": 0, + "contributors": 1 + } + ] + } + }, + "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/index.html b/index.html index 98e9ce4a7..f16c1b2e5 100644 --- a/index.html +++ b/index.html @@ -4,15 +4,10 @@ Advanced Algos - - - - - - - - + + + @@ -69,7 +64,7 @@ - + diff --git a/server.js b/server.js index 2ddfe3e83..f38db6ab0 100644 --- a/server.js +++ b/server.js @@ -2,44 +2,59 @@ const MODULE_NAME = "Node Server"; const START_BROWSER_APP = true; - -/* -const octokit = require('@octokit/rest')() -global.atob = require("atob"); - -let owner = "AAMasters"; -let repo = "AABruce-Indicator-Bot"; -let branch = "master"; -let page = 1; -let per_page = 100; -let ref = "master"; -let path = "One-Min-Daily-Candles-Volumes/Interval.js"; - -octokit.repos.getContent({ owner, repo, path, ref }, onContent); - -function onContent (error, result) { - - let decoded = atob(result.data.content); - - console.log(decoded.substring(3)); - - console.log(result); - -} - -return; -*/ - -let debugMode = true; +let debugMode = true; // This forces the server to read Plotters from the local drive. let githubPages = new Map; +let ecosystem; +let ecosystemObject; //'use strict'; var http = require('http'); var port = process.env.PORT || 1337; -startHtttpServer(); +initialize(); -function onRequestReceivedFromBrowser(request, response) { +function initialize() { + + let fs = require('fs'); + try { + let fileName = 'ecosystem.json'; + fs.readFile(fileName, onFileRead); + + function onFileRead(err, file) { + + try { + ecosystem = file.toString(); + ecosystem = ecosystem.trim(); // remove first byte with some encoding. + + ecosystemObject = JSON.parse(ecosystem); + startHtttpServer(); + } + catch (err) { + console.log("File Not Found: " + fileName + " or Error = " + err); + } + + } + } + catch (err) { + console.log(err); + } +} + +function startHtttpServer() { + + if (START_BROWSER_APP === true) { + + try { + + gWebServer = http.createServer(onBrowserRequest).listen(port); + } + catch (err) { + console.log(err); + } + } +} + +function onBrowserRequest(request, response) { var htmlResponse; var requestParameters = request.url.split("/"); @@ -47,16 +62,115 @@ function onRequestReceivedFromBrowser(request, response) { switch (requestParameters[1]) { - case "AAMasters": + case "Plotters.js": + { + let fs = require('fs'); + try { + let fileName = 'Plotters.js'; + fs.readFile(fileName, onFileRead); + + function onFileRead(err, file) { + + try { + + let fileContent = file.toString(); + + /* This is the string we will use to insert into the Plotters.js script. */ + + let caseString = '' + + ' case "@newFunctionName@":' + '\n' + + ' {' + '\n' + + ' plotter = newPlotterName();' + '\n' + + ' }' + '\n' + + ' break;' + '\n' + '\n' + + let devTeams = ecosystemObject.devTeams; + + for (let i = 0; i < devTeams.length; i++) { + + let devTeam = devTeams[i]; + + for (let j = 0; j < devTeam.plotters.length; j++) { + + 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; + newFunctionName = newFunctionName.replace(/-/g, ""); + + let stringToInsert; + stringToInsert = caseStringCopy.replace('@newFunctionName@', newFunctionName); + stringToInsert = stringToInsert.replace('newPlotterName', 'new' + newFunctionName); + + let firstPart = fileContent.substring(0,fileContent.indexOf('// Cases')); + let secondPart = fileContent.substring(fileContent.indexOf('// Cases')); + + fileContent = firstPart + stringToInsert + secondPart; + + } + } + + respondWithContent(fileContent, response); + + } + catch (err) { + console.log("File Not Found: " + fileName + " or Error = " + err); + } + + } + } + catch (err) { + console.log(err); + } + + } + break; + + case "Ecosystem.js": + { + let fs = require('fs'); + try { + let fileName = 'Ecosystem.js'; + fs.readFile(fileName, onFileRead); + + function onFileRead(err, file) { + + try { + + let fileContent = file.toString(); + let trimmedEcosystem = ecosystem.trim(); + + fileContent = fileContent.replace('"@ecosystem.json@"', trimmedEcosystem); + + respondWithContent(fileContent, response); + + } + catch (err) { + console.log("File Not Found: " + fileName); + } + + } + } + catch (err) { + console.log(err); + } + + } + break; + + case "Plotters": // This means the plotter folder, not to be confused with the Plotters script! { if (debugMode === true) { - respondWithFile('../' + requestParameters[2] + "-Plotter" + '/' + requestParameters[3], response); + respondWithFile('../Plotters/' + requestParameters[2] + '/' + requestParameters[3] + '/' + requestParameters[4], response); } else { - let cacheVersion = githubPages.get(requestParameters[1] + requestParameters[2] + requestParameters[3]) + let cacheVersion = githubPages.get(requestParameters[2] + requestParameters[3] + requestParameters[4]) if (cacheVersion !== undefined) { @@ -67,13 +181,13 @@ function onRequestReceivedFromBrowser(request, response) { const octokit = require('@octokit/rest')() global.atob = require("atob"); - let owner = requestParameters[1]; - let repo = requestParameters[2] + "-Plotter"; + let owner = requestParameters[2]; + let repo = requestParameters[3]; let branch = "master"; let page = 1; let per_page = 100; let ref = "master"; - let path = requestParameters[3]; + let path = requestParameters[4]; octokit.repos.getContent({ owner, repo, path, ref }, onContent); @@ -85,7 +199,7 @@ function onRequestReceivedFromBrowser(request, response) { respondWithContent(cleanString, response); - githubPages.set(requestParameters[1] + requestParameters[2] + requestParameters[3], cleanString); + githubPages.set(requestParameters[2] + requestParameters[3] + requestParameters[4], cleanString); } } @@ -129,162 +243,71 @@ function onRequestReceivedFromBrowser(request, response) { } break; - case "lastTrades": - { - const marketId = requestParameters[2]; - const exchangeId = requestParameters[3]; - - const sqlQuery = "SELECT TOP 100000 " - + " InternalExchangeTradeId AS Id, " - + " Type, " - + " Rate, " - + " AmountAssetA AS AmountA, " - + " AmountAssetB AS AmountB, " - + " Timestamp " - + " FROM Trades " - + " WHERE " - + " IdMarket = " + marketId + " " - + " AND " - + " IdExchange = " + exchangeId + " " - + " ORDER BY IdExchange ASC, IdMarket ASC, InternalExchangeTradeId DESC" - ; - - ////console.log("About to execute: " + sqlQuery); - - - /* Then we execute the query */ - - database.executeSQL(sqlQuery, function (err, resultSet) { - - //console.log("Query executed: " + sqlQuery); - - var myJsonString = JSON.stringify(resultSet); - - ////console.log(myJsonString); - - response.writeHead(200, { 'Content-Type': 'text/plain' }); - response.write(myJsonString); - response.end("\n"); - } - ); - - } - break; - - - case "trades": - { - const marketId = requestParameters[2]; - const exchangeId = requestParameters[3]; - const idBegin = unescape(requestParameters[4]); - const idEnd = unescape(requestParameters[5]); - - const sqlQuery = "SELECT " - + " InternalExchangeTradeId AS Id, " - + " Type, " - + " Rate, " - + " AmountAssetA AS AmountA, " - + " AmountAssetB AS AmountB, " - + " Timestamp " - + " FROM Trades " - + " WHERE " - + " IdExchange = " + exchangeId + " " - + " AND " - + " IdMarket = " + marketId + " " - + " AND " - + " InternalExchangeTradeId >= " + idBegin + " " - + " AND " - + " InternalExchangeTradeId <= " + idEnd + " " - + " ORDER BY IdExchange, IdMarket, InternalExchangeTradeId " - ; - - let records = idEnd - idBegin; - console.log("Records Requested: " + records + " idBegin = " + idBegin + " idEnd = " + idEnd); - - - /* Then we execute the query */ - - database.executeSQL(sqlQuery, function (err, resultSet) { - - //console.log("Query executed: " + sqlQuery); - - var myJsonString = JSON.stringify(resultSet); - - ////console.log(myJsonString); - - response.writeHead(200, { 'Content-Type': 'text/plain' }); - response.write(myJsonString); - response.end("\n"); - } - ); - - } - break; - - - case "orderbook": - - { - const marketId = requestParameters[2]; - const datetimeBegin = unescape(requestParameters[3]); - const datetimeEnd = unescape(requestParameters[4]); - - var sqlQuery = "SELECT " - + " Id, " - + " Rate, " - + " Amount * Rate AS AmountA, " - + " Amount AS AmountB, " - + " Type AS Type, " - + " DatetimeIn AS DatetimeIn, " - + " ISNULL(DatetimeOut, '3000-01-01') AS DatetimeOut " - + " FROM OrderBooks " - + " WHERE " - + " ( " - + " IdMarket = " + marketId + " " - + " ) " - + " AND " - + " ( " - + " DatetimeIn <= '" + datetimeEnd + "' " - + " ) " - + " AND " - + " ( " - + " ISNULL(DatetimeOut, '3000-01-01') > '" + datetimeBegin + "' " - + " ) " - ; - - - //console.log(sqlQuery); - - - /* Then we execute the query */ - - database.executeSQL(sqlQuery, function (err, resultSet) { - - var myJsonString = JSON.stringify(resultSet); - - //console.log(myJsonString); - - response.writeHead(200, { 'Content-Type': 'text/plain' }); - response.write(myJsonString); - response.end("\n"); - } - ); - } - break; - - - - default: - ////console.log("Unknown request received from the browser: " + request.url); if (requestParameters[1] === "") { - requestParameters[1] = "index.html"; + + let fs = require('fs'); + try { + let fileName = 'index.html'; + fs.readFile(fileName, onFileRead); + + function onFileRead(err, file) { + + try { + + let fileContent = file.toString(); + + /* This is the string we will use to insert into the Plotters.js script. */ + + let htmlLine = '' + '\n' + + ' ' + + let devTeams = ecosystemObject.devTeams; + + for (let i = 0; i < devTeams.length; i++) { + + let devTeam = devTeams[i]; + + for (let j = 0; j < devTeam.plotters.length; j++) { + + let plotter = devTeam.plotters[j]; + + /* Now each of these layers has a plotter that we need to define on the Plotter.js file. */ + + let htmlLineCopy = htmlLine; + + let stringToInsert; + stringToInsert = htmlLineCopy.replace('@devTeam@', devTeam.codeName); + stringToInsert = stringToInsert.replace('@repo@', plotter.repo); + stringToInsert = stringToInsert.replace('@module@', plotter.moduleName); + + let firstPart = fileContent.substring(0, fileContent.indexOf('') + 15); + let secondPart = fileContent.substring(fileContent.indexOf('') + 15); + + fileContent = firstPart + stringToInsert + secondPart; + + } + } + + respondWithContent(fileContent, response); + + } + catch (err) { + console.log("File Not Found: " + fileName + " or Error = " + err); + } + + } + } + catch (err) { + console.log(err); + } + } else { + + respondWithFile("" + requestParameters[1], response); + } - - respondWithFile("" + requestParameters[1], response); - } function sendResponseToBrowser(htmlResponse) { @@ -295,7 +318,6 @@ function onRequestReceivedFromBrowser(request, response) { } } - function respondWithContent(content, response) { try { @@ -308,7 +330,7 @@ function respondWithContent(content, response) { response.writeHead(200, { 'Content-Type': 'text/html' }); response.write(content); response.end("\n"); - console.log("Content Sent: " + content); + //console.log("Content Sent: " + content); } catch (err) { @@ -316,8 +338,6 @@ function respondWithContent(content, response) { } } - - function respondWithFile(fileName, response) { let fs = require('fs'); @@ -338,7 +358,7 @@ function respondWithFile(fileName, response) { response.writeHead(200, { 'Content-Type': 'text/html' }); response.write(htmlResponse); response.end("\n"); - console.log("File Sent: " + fileName); + //console.log("File Sent: " + fileName); // } catch (err) { @@ -365,18 +385,6 @@ function respondWithFile(fileName, response) { } } -function startHtttpServer() { - if (START_BROWSER_APP === true) { - - try { - - gWebServer = http.createServer(onRequestReceivedFromBrowser).listen(port); - } - catch (err) { - console.log(err); - } - } -}