hedgequantx 2.5.40 → 2.5.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/pages/stats.js +35 -73
- package/src/services/ai/strategy-supervisor.js +1042 -48
package/package.json
CHANGED
package/src/pages/stats.js
CHANGED
|
@@ -481,7 +481,7 @@ const showStats = async (service) => {
|
|
|
481
481
|
|
|
482
482
|
drawBoxFooter(boxWidth);
|
|
483
483
|
|
|
484
|
-
// ========== AI BEHAVIOR DIAGRAM ==========
|
|
484
|
+
// ========== AI BEHAVIOR DIAGRAM (HORIZONTAL BARS) ==========
|
|
485
485
|
const behaviorData = StrategySupervisor.getBehaviorHistory(100);
|
|
486
486
|
const learningStats = StrategySupervisor.getLearningStats();
|
|
487
487
|
|
|
@@ -511,28 +511,10 @@ const showStats = async (service) => {
|
|
|
511
511
|
PAUSE: Math.round((behaviorCounts.PAUSE / total) * 100)
|
|
512
512
|
};
|
|
513
513
|
|
|
514
|
-
// Bar chart configuration
|
|
515
|
-
const labelWidth = 12;
|
|
516
|
-
const percentWidth = 6;
|
|
517
|
-
const barMaxWidth = behaviorInnerWidth - labelWidth - percentWidth - 6;
|
|
518
|
-
|
|
519
514
|
// Get current behavior
|
|
520
515
|
const currentValue = behaviorData.values.length > 0 ? behaviorData.values[behaviorData.values.length - 1] : 2;
|
|
521
516
|
const currentAction = valueToAction[Math.round(currentValue)] || 'NORMAL';
|
|
522
517
|
|
|
523
|
-
// Draw vertical bar chart (bars going up)
|
|
524
|
-
const chartHeight = 8;
|
|
525
|
-
const barWidth = Math.floor((barMaxWidth - 12) / 4); // 4 bars with spacing
|
|
526
|
-
|
|
527
|
-
// Calculate bar heights (max height = chartHeight)
|
|
528
|
-
const maxPercent = Math.max(...Object.values(percentages), 1);
|
|
529
|
-
const barHeights = {
|
|
530
|
-
AGGRESSIVE: Math.round((percentages.AGGRESSIVE / 100) * chartHeight),
|
|
531
|
-
NORMAL: Math.round((percentages.NORMAL / 100) * chartHeight),
|
|
532
|
-
CAUTIOUS: Math.round((percentages.CAUTIOUS / 100) * chartHeight),
|
|
533
|
-
PAUSE: Math.round((percentages.PAUSE / 100) * chartHeight)
|
|
534
|
-
};
|
|
535
|
-
|
|
536
518
|
// Colors for each behavior
|
|
537
519
|
const barColors = {
|
|
538
520
|
AGGRESSIVE: chalk.green,
|
|
@@ -541,70 +523,50 @@ const showStats = async (service) => {
|
|
|
541
523
|
PAUSE: chalk.red
|
|
542
524
|
};
|
|
543
525
|
|
|
544
|
-
//
|
|
526
|
+
// Horizontal bar chart configuration
|
|
545
527
|
const barLabels = ['AGGRESSIVE', 'NORMAL', 'CAUTIOUS', 'PAUSE'];
|
|
546
528
|
const shortLabels = ['AGR', 'NOR', 'CAU', 'PAU'];
|
|
529
|
+
const labelWidth = 6; // "AGR " etc.
|
|
530
|
+
const pctWidth = 6; // "100% "
|
|
531
|
+
const spacing = 4; // spaces between bars
|
|
532
|
+
|
|
533
|
+
// Calculate bar width for each category (total 4 bars with spacing)
|
|
534
|
+
const availableWidth = behaviorInnerWidth - (labelWidth * 4) - (pctWidth * 4) - (spacing * 3) - 4;
|
|
535
|
+
const maxBarWidth = Math.floor(availableWidth / 4);
|
|
536
|
+
|
|
537
|
+
// Calculate bar widths based on percentage (max 100% = maxBarWidth)
|
|
538
|
+
const barWidths = {
|
|
539
|
+
AGGRESSIVE: Math.round((percentages.AGGRESSIVE / 100) * maxBarWidth),
|
|
540
|
+
NORMAL: Math.round((percentages.NORMAL / 100) * maxBarWidth),
|
|
541
|
+
CAUTIOUS: Math.round((percentages.CAUTIOUS / 100) * maxBarWidth),
|
|
542
|
+
PAUSE: Math.round((percentages.PAUSE / 100) * maxBarWidth)
|
|
543
|
+
};
|
|
547
544
|
|
|
548
|
-
//
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
545
|
+
// Draw horizontal bars (each bar is a row)
|
|
546
|
+
for (let i = 0; i < 4; i++) {
|
|
547
|
+
const label = barLabels[i];
|
|
548
|
+
const shortLabel = shortLabels[i];
|
|
549
|
+
const pct = percentages[label];
|
|
550
|
+
const barWidth = barWidths[label];
|
|
551
|
+
const color = barColors[label];
|
|
552
|
+
const isCurrent = label === currentAction;
|
|
554
553
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
const isCurrent = label === currentAction;
|
|
560
|
-
|
|
561
|
-
if (row <= height) {
|
|
562
|
-
// Draw filled bar
|
|
563
|
-
const block = isCurrent ? '█' : '▓';
|
|
564
|
-
line += color(block.repeat(barWidth));
|
|
565
|
-
} else {
|
|
566
|
-
// Empty space
|
|
567
|
-
line += ' '.repeat(barWidth);
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
if (i < 3) line += ' '; // Space between bars
|
|
571
|
-
}
|
|
554
|
+
// Build the bar
|
|
555
|
+
const block = isCurrent ? '█' : '▓';
|
|
556
|
+
const bar = barWidth > 0 ? color(block.repeat(barWidth)) : '';
|
|
557
|
+
const emptySpace = ' '.repeat(Math.max(0, maxBarWidth - barWidth));
|
|
572
558
|
|
|
559
|
+
// Format: " AGR ████████████████ 100% "
|
|
560
|
+
const labelPart = ' ' + color(shortLabel.padEnd(labelWidth));
|
|
561
|
+
const barPart = bar + emptySpace;
|
|
562
|
+
const pctPart = chalk.white((pct + '%').padStart(pctWidth));
|
|
563
|
+
|
|
564
|
+
let line = labelPart + barPart + pctPart;
|
|
573
565
|
const lineLen = line.replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
574
566
|
line += ' '.repeat(Math.max(0, behaviorInnerWidth - lineLen));
|
|
575
567
|
console.log(chalk.cyan('\u2551') + line + chalk.cyan('\u2551'));
|
|
576
568
|
}
|
|
577
569
|
|
|
578
|
-
// Draw baseline
|
|
579
|
-
let baseLine = ' '.repeat(leftPad) + '─'.repeat(totalBarWidth);
|
|
580
|
-
const baseLen = baseLine.length;
|
|
581
|
-
baseLine += ' '.repeat(Math.max(0, behaviorInnerWidth - baseLen));
|
|
582
|
-
console.log(chalk.cyan('\u2551') + chalk.white(baseLine) + chalk.cyan('\u2551'));
|
|
583
|
-
|
|
584
|
-
// Draw labels
|
|
585
|
-
let labelLine = ' '.repeat(leftPad);
|
|
586
|
-
for (let i = 0; i < 4; i++) {
|
|
587
|
-
const lbl = shortLabels[i];
|
|
588
|
-
const pad = Math.floor((barWidth - lbl.length) / 2);
|
|
589
|
-
labelLine += ' '.repeat(pad) + barColors[barLabels[i]](lbl) + ' '.repeat(barWidth - pad - lbl.length);
|
|
590
|
-
if (i < 3) labelLine += ' ';
|
|
591
|
-
}
|
|
592
|
-
const lblLen = labelLine.replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
593
|
-
labelLine += ' '.repeat(Math.max(0, behaviorInnerWidth - lblLen));
|
|
594
|
-
console.log(chalk.cyan('\u2551') + labelLine + chalk.cyan('\u2551'));
|
|
595
|
-
|
|
596
|
-
// Draw percentages
|
|
597
|
-
let pctLine = ' '.repeat(leftPad);
|
|
598
|
-
for (let i = 0; i < 4; i++) {
|
|
599
|
-
const pct = percentages[barLabels[i]] + '%';
|
|
600
|
-
const pad = Math.floor((barWidth - pct.length) / 2);
|
|
601
|
-
pctLine += ' '.repeat(pad) + chalk.white(pct) + ' '.repeat(barWidth - pad - pct.length);
|
|
602
|
-
if (i < 3) pctLine += ' ';
|
|
603
|
-
}
|
|
604
|
-
const pctLen = pctLine.replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
605
|
-
pctLine += ' '.repeat(Math.max(0, behaviorInnerWidth - pctLen));
|
|
606
|
-
console.log(chalk.cyan('\u2551') + pctLine + chalk.cyan('\u2551'));
|
|
607
|
-
|
|
608
570
|
// Empty line
|
|
609
571
|
console.log(chalk.cyan('\u2551') + ' '.repeat(behaviorInnerWidth) + chalk.cyan('\u2551'));
|
|
610
572
|
|