Conditions Panel Working from SimulationLogic

This commit is contained in:
Luis Fernando Molina committed 2019-03-07 13:57:15 +01:00
1 parent 94a3b8d330
commit e0e7483e38
2 files changed
+54 -17

No files matched your search

+8 -9
View File
@@ -48,6 +48,7 @@
/* these are module specific variables: */
let conditions = [];
let headers;
let smileyHappy;
let smileySad;
@@ -390,8 +391,9 @@
rightDate = new Date(rightDate.valueOf() + dateDiff * 1.5);
conditions = [];
headers = marketFile[0];
for (let i = 0; i < marketFile.length; i++) {
for (let i = 0; i < marketFile[1].length; i++) {
let record = {
begin: undefined,
@@ -399,13 +401,9 @@
conditions: undefined
};
record.begin = marketFile[i][0];
record.end = marketFile[i][1];
record.conditions = marketFile[i];
if (i === 0) { // The first record contains headers needed to be printed.
conditions.push(record);
}
record.begin = marketFile[1][i][0];
record.end = marketFile[1][i][1];
record.conditions = marketFile[1][i];
if (record.begin >= leftDate.valueOf() && record.end <= rightDate.valueOf()) {
@@ -500,7 +498,7 @@
if (dateValue >= conditionRecord.begin && dateValue <= conditionRecord.end) {
let currentRecord = {
conditionsNames: conditions[0].conditions,
conditionsNames: headers,
conditionsValues: conditionRecord.conditions
};
thisObject.container.eventHandler.raiseEvent("Current Condition Record Changed", currentRecord);
@@ -576,3 +574,4 @@
+46 -8
View File
@@ -79,21 +79,59 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() {
let y = 0;
let increment = 0.06;
let opacity;
let label;
browserCanvasContext.beginPath();
for (let i = 2; i < currentRecord.conditionsNames.length; i++) { // Jump the first 2 items since they are the .begin and the .end of the record.
let simulationLogic = currentRecord.conditionsNames;
let conditionIndex = 2; // Jump the first 2 items since they are the .begin and the .end of the record.
for (let j = 0; j < simulationLogic.strategies.length; j++) {
let strategy = simulationLogic.strategies[j];
y = y + increment;
let opacity;
if (currentRecord.conditionsValues[i] === 1) {
opacity = '1.00'
} else {
y = y + increment;
opacity = '1.00';
label = 'Strategy: ' + strategy.name;
printLabel(label, X_AXIS, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK);
y = y + increment;
opacity = '0.50';
label = 'Entry Point';
printLabel(label, X_AXIS, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK);
for (let k = 0; k < strategy.entryPoint.situations.length; k++) {
let situation = strategy.entryPoint.situations[k];
y = y + increment;
opacity = '0.50';
label = 'Situation: ' + situation.name;
printLabel(label, X_AXIS, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK);
for (let m = 0; m < situation.conditions.length; m++) {
let condition = situation.conditions[m];
let color;
y = y + increment;
if (currentRecord.conditionsValues[conditionIndex] === 1) {
opacity = '0.50'
color = UI_COLOR.PATINATED_TURQUOISE;
} else {
opacity = '0.50';
color = UI_COLOR.RUSTED_RED;
}
conditionIndex++;
label = condition.name;
printLabel(label, X_AXIS, frameTitleHeight + frameBodyHeight * y, opacity, color);
}
}
printLabel(currentRecord.conditionsNames[i], X_AXIS, frameTitleHeight + frameBodyHeight * y, opacity);
}
function printLabel(labelToPrint, x, y, opacity) {
function printLabel(labelToPrint, x, y, opacity, color) {
let labelPoint;
let fontSize = 10;
@@ -113,7 +151,7 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() {
labelPoint = thisObject.container.frame.frameThisPoint(labelPoint);
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.DARK + ', ' + opacity + ')';
browserCanvasContext.fillStyle = 'rgba(' + color + ', ' + opacity + ')';
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y);
}