New Product Panel Working

This commit is contained in:
Luis Fernando Molina committed 2018-03-02 11:18:54 +01:00
1 parent 105768ba17
commit 3dec0438cf
15 files changed
+198 -188

No files matched your search

Binary file not shown.
+1
View File
@@ -1,4 +1,5 @@
/* The Dashboard is the root object that contains all the other stuff in it. Some of that stuff is visible, some other is invisible. */
var canvas;
+20 -4
View File
@@ -6,6 +6,7 @@ function newEcosystem() {
getTeams: getTeams,
getBot: getBot,
getProduct: getProduct,
getSet: getSet,
getExchange: getExchange,
initialize: initialize
}
@@ -60,15 +61,30 @@ function newEcosystem() {
}
}
function getExchange(pProduct, pName) {
function getSet(pProduct, pSetCodeName) {
for (let i = 0; i < pProduct.exchangeList.exchange.length; i++) {
for (let i = 0; i < pProduct.sets.length; i++) {
if (pProduct.exchangeList.exchange[i].name === pName) {
if (pProduct.sets[i].codeName === pSetCodeName) {
return pProduct.exchangeList.exchange[i];
return pProduct.sets[i];
}
}
}
function getExchange(pProduct, pName) {
for (let i = 0; i < pProduct.exchangeList.length; i++) {
if (pProduct.exchangeList[i].name === pName) {
return pProduct.exchangeList[i];
}
}
}
return false;
}
+1 -4
View File
@@ -1,7 +1,7 @@
function newEventHandler() {
var eventHandler = {
let eventHandler = {
containerName: "", // This is for debugging purposes only.
parentEventHandler: undefined, // Here we store the parent cointainer zoom object.
listenToEvent: listenToEvent,
@@ -38,9 +38,6 @@ function newEventHandler() {
handler(event, extraData);
}
}
}
}
+5 -5
View File
@@ -11,7 +11,7 @@ function newFile() {
return fileObject;
function initialize(pTeamCodeName, pBotCodeName, pProductCodeName, pLayerCodeName, pExchange, pMarket, callBackFunction) {
function initialize(pTeamCodeName, pBotCodeName, pProductCodeName, pSetCodeName, pExchange, pMarket, callBackFunction) {
let product = ecosystem.getProduct(ecosystem.getBot(ecosystem.getTeam(pTeamCodeName), pBotCodeName), pProductCodeName);
@@ -29,11 +29,11 @@ function newFile() {
}
let layer = ecosystem.getLayer(product, pLayerCodeName);
let productSet = ecosystem.getSet(product, pSetCodeName);
if (layer === undefined) {
if (productSet === undefined) {
throw "Layer not found at this product of the ecosystem! - pTeamCodeName = " + pTeamCodeName + ", pBotCodeName = " + pBotCodeName + ", pProductCodeName = " + pProductCodeName + ", pLayerCodeName = " + pLayerCodeName;
throw "Set not found at this product of the ecosystem! - pTeamCodeName = " + pTeamCodeName + ", pBotCodeName = " + pBotCodeName + ", pProductCodeName = " + pProductCodeName + ", pSetCodeName = " + pSetCodeName;
}
@@ -42,7 +42,7 @@ function newFile() {
/* Now we will get the file */
fileCloud.getFile(product, exchange, pMarket, undefined, undefined, onFileReceived);
fileCloud.getFile(productSet, exchange, pMarket, undefined, undefined, onFileReceived);
function onFileReceived(pFile) {
+6 -6
View File
@@ -14,7 +14,7 @@ function newFileCache() {
return fileCache;
function initialize(pTeamCodeName, pBotCodeName, pProductCodeName, pLayerCodeName, pExchange, pMarket, callBackFunction) {
function initialize(pTeamCodeName, pBotCodeName, pProductCodeName, pSetCodeName, pExchange, pMarket, callBackFunction) {
let product = ecosystem.getProduct(ecosystem.getBot(ecosystem.getTeam(pTeamCodeName), pBotCodeName), pProductCodeName);
@@ -32,11 +32,11 @@ function newFileCache() {
}
let layer = ecosystem.getLayer(product, pLayerCodeName);
let productSet = ecosystem.getSet(product, pSetCodeName);
if (layer === undefined) {
if (productSet === undefined) {
throw "Layer not found at this product of the ecosystem! - pTeamCodeName = " + pTeamCodeName + ", pBotCodeName = " + pBotCodeName + ", pProductCodeName = " + pProductCodeName + ", pLayerCodeName = " + pLayerCodeName;
throw "Set not found at this product of the ecosystem! - pTeamCodeName = " + pTeamCodeName + ", pBotCodeName = " + pBotCodeName + ", pProductCodeName = " + pProductCodeName + ", pSetCodeName = " + pSetCodeName;
}
@@ -50,9 +50,9 @@ function newFileCache() {
let periodTime = marketFilesPeriods[i][0];
let periodName = marketFilesPeriods[i][1];
if (layer.validPeriods.includes(periodName) === true) {
if (productSet.validPeriods.includes(periodName) === true) {
fileCloud.getFile(product, exchange, pMarket, periodName, undefined, onFileReceived);
fileCloud.getFile(productSet, exchange, pMarket, periodName, undefined, onFileReceived);
function onFileReceived(file) {
+14 -3
View File
@@ -18,10 +18,21 @@ function newFileCloud() {
}
function getFile(pProduct, pExchange, pMarket, pPeriodName, pDatetime, callBackFunction) {
function getFile(pSet, pExchange, pMarket, pPeriodName, pDatetime, callBackFunction) {
let fileName = pProduct.fileName;
let filePath = pProduct.filePath;
let fileName = pSet.fileName;
let filePath = pSet.filePath;
if (fileName === undefined) {
console.log("Inconsistant data. Check the following. ");
console.log(JSON.stringify(pSet));
console.log(JSON.stringify(pExchange));
console.log(JSON.stringify(pMarket));
console.log(JSON.stringify(pPeriodName));
throw ("Inconsistant data received.");
}
fileName = fileName.replace("@AssetA", pMarket.assetA);
fileName = fileName.replace("@AssetB", pMarket.assetB);
+4 -4
View File
@@ -19,18 +19,18 @@ function newFileCursor() {
let market;
let exchange;
let fileCloud;
let product;
let productSet;
let periodName;
let timePeriod;
return fileCursor;
function initialize(pFileCloud, pProduct, pExchange, pMarket, pPeriodName, pTimePeriod, pCursorDate, pCurrentTimePeriod, callBackFunction) {
function initialize(pFileCloud, pProductSet, pExchange, pMarket, pPeriodName, pTimePeriod, pCursorDate, pCurrentTimePeriod, callBackFunction) {
market = pMarket;
exchange = pExchange;
fileCloud = pFileCloud;
product = pProduct;
productSet = pProductSet;
periodName = pPeriodName;
cursorDate = pCursorDate;
timePeriod = pTimePeriod;
@@ -289,7 +289,7 @@ function newFileCursor() {
if (fileCursor.files.get(dateString) === undefined) { // We dont reload files we already have.
fileCloud.getFile(product, exchange, market, periodName, targetDate, onFileReceived);
fileCloud.getFile(productSet, exchange, market, periodName, targetDate, onFileReceived);
} else {
+6 -6
View File
@@ -15,7 +15,7 @@ function newFileCursorCache() {
return fileCursorCache;
function initialize(pTeamCodeName, pBotCodeName, pProductCodeName, pLayerCodeName, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) {
function initialize(pTeamCodeName, pBotCodeName, pProductCodeName, pSetCodeName, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) {
let product = ecosystem.getProduct(ecosystem.getBot(ecosystem.getTeam(pTeamCodeName), pBotCodeName), pProductCodeName);
@@ -33,11 +33,11 @@ function newFileCursorCache() {
}
let layer = ecosystem.getLayer(product, pLayerCodeName);
let productSet = ecosystem.getSet(product, pSetCodeName);
if (layer === undefined) {
if (productSet === undefined) {
throw "Layer not found at this product of the ecosystem! - pTeamCodeName = " + pTeamCodeName + ", pBotCodeName = " + pBotCodeName + ", pProductCodeName = " + pProductCodeName + ", pLayerCodeName = " + pLayerCodeName;
throw "Set not found at this product of the ecosystem! - pTeamCodeName = " + pTeamCodeName + ", pBotCodeName = " + pBotCodeName + ", pProductCodeName = " + pProductCodeName + ", pSetCodeName = " + pSetCodeName;
}
@@ -51,10 +51,10 @@ function newFileCursorCache() {
let periodTime = dailyFilePeriods[i][0];
let periodName = dailyFilePeriods[i][1];
if (layer.validPeriods.includes(periodName) === true) {
if (productSet.validPeriods.includes(periodName) === true) {
let fileCursor = newFileCursor();
fileCursor.initialize(fileCloud, product, exchange, pMarket, periodName, periodTime, pDatetime, pTimePeriod, onFileReceived);
fileCursor.initialize(fileCloud, productSet, exchange, pMarket, periodName, periodTime, pDatetime, pTimePeriod, onFileReceived);
fileCursors.set(periodTime, fileCursor);
+6 -63
View File
@@ -6,7 +6,6 @@ function newProductsPanel() {
var thisObject = {
container: undefined,
getOnProductCards: getOnProductCards,
getProductStatus: getProductStatus,
draw: draw,
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize
@@ -17,17 +16,17 @@ function newProductsPanel() {
container.isDraggeable = true;
container.isZoomeable = false;
thisObject.container = container;
thisObject.container.frame.containerName = "Chart Layers Panel";
thisObject.container.frame.containerName = "Bot's Products";
let isInitialized = false;
let productCards;
let productCards = [];
return thisObject;
function initialize() {
this.container.frame.width = 200;
this.container.frame.height = 200;
this.container.frame.width = 300;
this.container.frame.height = 500;
var position = {
x: viewPort.visibleArea.topRight.x - this.container.frame.width,
@@ -86,25 +85,7 @@ function newProductsPanel() {
productCard.container.frame.position.x = position.x;
productCard.container.frame.position.y = position.y + lastY;
lastY = lastY + productCard.container.frame.height;
/* We start listening to the productCard click event, so as to know when one was pressed. */
productCard.container.eventHandler.listenToEvent('onMouseClick', buttonPressed, i);
/* We retrieve the locally stored status of the Product */
let storedValue = window.localStorage.getItem(productCard.code);
if (storedValue !== null) {
productCard.status = storedValue;
} else {
productCard.status = PRODUCT_CARD_STATUS.ON;
}
lastY = lastY + productCard.container.frame.height * 1.25;
/* Add to the Product Array */
@@ -126,7 +107,7 @@ function newProductsPanel() {
for (let i = 0; i < productCards.length; i++) {
if (productCards[i].status = PRODUCT_CARD_STATUS.ON) {
if (productCards[i].status === PRODUCT_CARD_STATUS.ON) {
onProducts.push(productCards[i]);
}
@@ -135,23 +116,6 @@ function newProductsPanel() {
return onProducts;
}
function getProductStatus(pProductCode) {
for (let i = 0; i < productCards.length; i++) {
let button = productCards[i];
if (button.code === pProductCode) {
return button.status;
}
}
return PRODUCT_CARD_STATUS.OFF;
}
function getContainer(point) {
var container;
@@ -188,27 +152,6 @@ function newProductsPanel() {
}
function buttonPressed(event, index) {
switch (productCards[index].status) {
case PRODUCT_CARD_STATUS.ON:
productCards[index].status = PRODUCT_CARD_STATUS.OFF;
break;
case PRODUCT_CARD_STATUS.OFF:
productCards[index].status = PRODUCT_CARD_STATUS.ON;
break;
}
let eventData = productCards[index];
thisObject.container.eventHandler.raiseEvent('Product Card Status Changed', eventData);
window.localStorage.setItem(productCards[index].code, productCards[index].status);
}
function draw() {
+1
View File
@@ -4,6 +4,7 @@ function getNewPlotter(pDevTeam, pRepo, pModule) {
let plotter;
let fullCode = pDevTeam + pRepo + pModule;
fullCode = fullCode.replace(/-/g, "");
switch (fullCode) {
+76 -47
View File
@@ -8,7 +8,6 @@
bot: undefined,
product: undefined,
code: undefined,
layer: undefined,
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize
};
@@ -33,7 +32,29 @@
this.container.frame.position = position;
this.container.frame.width = 280;
this.container.frame.height = 28;
this.container.frame.height = 45;
/* We retrieve the locally stored status of the Product */
let storedValue = window.localStorage.getItem(thisObject.code);
if (storedValue !== null) {
thisObject.status = storedValue;
} else {
thisObject.status = PRODUCT_CARD_STATUS.ON;
/* Save the value for future use */
window.localStorage.setItem(thisObject.code, thisObject.status);
}
/* Lets listen to our own events to react when we have a Mouse Click */
thisObject.container.eventHandler.listenToEvent('onMouseClick', buttonPressed);
}
@@ -56,6 +77,28 @@
}
function buttonPressed(event) {
switch (thisObject.status) {
case PRODUCT_CARD_STATUS.ON:
thisObject.status = PRODUCT_CARD_STATUS.OFF;
break;
case PRODUCT_CARD_STATUS.OFF:
thisObject.status = PRODUCT_CARD_STATUS.ON;
break;
}
let eventData = thisObject;
thisObject.container.eventHandler.raiseEvent('Status Changed', eventData);
window.localStorage.setItem(thisObject.code, thisObject.status);
}
function draw() {
drawIcon();
@@ -84,11 +127,11 @@
switch (thisObject.status) {
case 'on':
case PRODUCT_CARD_STATUS.ON:
browserCanvasContext.fillStyle = onFillStyle;
break;
case 'off':
case PRODUCT_CARD_STATUS.OFF:
browserCanvasContext.fillStyle = offFillStyle;
break;
@@ -116,11 +159,39 @@
/* devTeam */
label = thisObject.devTeam;
label = "Dev Team: " + thisObject.devTeam.displayName;
xOffset = 0;
yOffset = 0;
labelPoint = {
x: 20,
y: thisObject.container.frame.height - 35
};
labelPoint = thisObject.container.frame.frameThisPoint(labelPoint);
browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)';
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y);
/* bot */
label = "Bot: " + thisObject.bot.displayName;
labelPoint = {
x: 20,
y: thisObject.container.frame.height - 20
};
labelPoint = thisObject.container.frame.frameThisPoint(labelPoint);
browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)';
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y);
/* product */
label = "Product: " + thisObject.product.displayName;
labelPoint = {
x: 20,
y: thisObject.container.frame.height - 5
@@ -131,47 +202,5 @@
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);
}
}
+7 -1
View File
@@ -46,6 +46,8 @@ function newSplashScreen() {
function draw() {
splashScreenNeeded = false;
if (splashScreenNeeded === false) {
stepsInitializationCounter = 100;
@@ -65,7 +67,11 @@ function newSplashScreen() {
let label = '' + Math.trunc(stepsInitializationCounter) + ' %';
stepsInitializationCounter = stepsInitializationCounter + 0.2;
if (stepsInitializationCounter > 99) { stepsInitializationCounter = 99;}
if (stepsInitializationCounter > 99) {
splashScreenNeeded = false;
stepsInitializationCounter = 99;
}
let fontSize = 50;
+10 -4
View File
@@ -50,8 +50,6 @@ function newTimelineChart() {
productsPanel = pProductsPanel;
productsPanel.eventHandler.listenToEvent("Product Card Status Changed", onProductCardStatusChanged);
marketId = market;
exchangeId = exchange;
@@ -139,6 +137,12 @@ function newTimelineChart() {
plotter: plotter
};
/* Listen to the event of change of status */
pProductCard.container.eventHandler.listenToEvent("Status Changed", onProductCardStatusChanged);
/* Add the new Active Protter to the Array */
activePlotters.push(activePlotter);
}
@@ -305,6 +309,8 @@ function newTimelineChart() {
function draw() {
if (activePlotters === undefined) { return; } // We need to wait
if (timelineChart.container.frame.isInViewPort()) {
this.container.frame.draw();
@@ -313,9 +319,9 @@ function newTimelineChart() {
chartGrid.draw(timelineChart.container, plotArea);
for (var i = 0; i < this.activePlotters.length; i++) {
for (var i = 0; i < activePlotters.length; i++) {
let activePlotter = this.activePlotters[i];
let activePlotter = activePlotters[i];
activePlotter.plotter.draw();
}
+41 -41
View File
@@ -2,7 +2,7 @@
"devTeams": [
{
"codeName": "AAMasters",
"displayName": "Advanced Algos Masters",
"displayName": "AA Masters",
"organization": {
"name": "AAMasters",
"type": "Open Source Community",
@@ -31,29 +31,30 @@
},
"products": [
{
"codeName": "Market Candles",
"codeName": "Candles",
"displayName": "Market Candles per Period",
"description": "Two sets of files per period that contains candles.",
"storageAccount": "aaolivia",
"sets": [
{
"codeName": "Market Files",
"validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ],
"filePath": "@Exchange/Output/Candles/Multi-Period-Market/@Period",
"fileName": "@AssetA_@AssetB.json"
},
{
"codeName": "Daily Files",
"validPeriods": [ "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ],
"filePath": "@Exchange/Output/Candles/Multi-Period-Daily/@Period/@Year/@Month/@Day",
"fileName": "@AssetA_@AssetB.json"
}
],
"exchangeList": {
"exchange": [
"exchangeList": [
{
"name": "Poloniex"
}
]
},
,
"plotter": {
"devTeam": "AAMasters",
"repo": "Plotters-Candles-Volumes",
@@ -61,29 +62,29 @@
}
},
{
"codeName": "Market Volumes",
"displayName": "Market Volumes per Period",
"codeName": "Volumes",
"displayName": "Buy and Sell Volumes",
"description": "Two sets of files per period that contains buy and sell volumes.",
"storageAccount": "aaolivia",
"sets": [
{
"codeName": "Market Files",
"validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ],
"filePath": "@Exchange/Output/Volumes/Multi-Period-Market/@Period",
"fileName": "@AssetA_@AssetB.json"
},
{
"codeName": "Daily Files",
"validPeriods": [ "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ],
"filePath": "@Exchange/Output/Volumes/Multi-Period-Daily/@Period/@Year/@Month/@Day",
"fileName": "@AssetA_@AssetB.json"
}
],
"exchangeList": {
"exchange": [
{
"name": "Poloniex"
}
]
},
"exchangeList": [
{
"name": "Poloniex"
}
],
"plotter": {
"devTeam": "AAMasters",
"repo": "Plotters-Candles-Volumes",
@@ -106,29 +107,29 @@
},
"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.",
"codeName": "Candle-Stairs",
"displayName": "Candle-Stairs Patters",
"description": "Two sets of files per period that contains candle-stairs patterns.",
"storageAccount": "aatom",
"sets": [
{
"codeName": "Market Files",
"validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ],
"filePath": "@Exchange/Tom/dataSet.V1/Output/Candle-Stairs/Multi-Period-Market/@Period",
"fileName": "@AssetA_@AssetB.json"
},
{
"codeName": "Daily Files",
"validPeriods": [ "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ],
"filePath": "@Exchange/Tom/dataSet.V1/Output/Candle-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day",
"fileName": "@AssetA_@AssetB.json"
}
],
"exchangeList": {
"exchange": [
{
"name": "Poloniex"
}
]
},
"exchangeList": [
{
"name": "Poloniex"
}
],
"plotter": {
"devTeam": "AAMasters",
"repo": "Plotters-Stairs-Patterns",
@@ -136,29 +137,29 @@
}
},
{
"codeName": "Market Volume-Stairs",
"displayName": "Market Volume-Stairs per Period",
"description": "Two sets of files per period that contains volume-stairs.",
"codeName": "Volume-Stairs",
"displayName": "Volume-Stairs Patters",
"description": "Two sets of files per period that contains volume-stairs patterns.",
"storageAccount": "aatom",
"sets": [
{
"codeName": "Market Files",
"validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ],
"filePath": "@Exchange/Tom/dataSet.V1/Output/Volume-Stairs/Multi-Period-Market/@Period",
"fileName": "@AssetA_@AssetB.json"
},
{
"codeName": "Daily Files",
"validPeriods": [ "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ],
"filePath": "@Exchange/Tom/dataSet.V1/Output/Volume-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day",
"fileName": "@AssetA_@AssetB.json"
}
],
"exchangeList": {
"exchange": [
{
"name": "Poloniex"
}
]
},
"exchangeList": [
{
"name": "Poloniex"
}
],
"plotter": {
"devTeam": "AAMasters",
"repo": "Plotters-Stairs-Patterns",
@@ -187,18 +188,17 @@
"storageAccount": "aamariam",
"sets": [
{
"codeName": "Trading History File",
"validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs", "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ],
"filePath": "@Exchange/Mariam/dataSet.V1/Output/Trading-Process",
"fileName": "Execution.History.json"
}
],
"exchangeList": {
"exchange": [
{
"name": "Poloniex"
}
]
},
"exchangeList": [
{
"name": "Poloniex"
}
],
"plotter": {
"devTeam": "AAMasters",
"repo": "Plotters-Trading",