hedgequantx 2.6.53 → 2.6.55
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/algo/copy-trading.js +7 -13
- package/src/pages/algo/ui.js +49 -21
package/package.json
CHANGED
|
@@ -440,25 +440,19 @@ class CopyEngine {
|
|
|
440
440
|
|
|
441
441
|
this.pollCount++;
|
|
442
442
|
|
|
443
|
-
// Smart logs every second
|
|
443
|
+
// Smart logs - only on STATE CHANGES (not every second when in position)
|
|
444
444
|
const now = Date.now();
|
|
445
445
|
if (now - this.lastLogTime > 1000) {
|
|
446
446
|
const smartLogs = require('./smart-logs');
|
|
447
447
|
|
|
448
|
-
if (this.leadPositions.size
|
|
449
|
-
//
|
|
450
|
-
|
|
451
|
-
const side = pos.quantity > 0 ? 'LONG' : 'SHORT';
|
|
452
|
-
const unrealizedPnl = pos.profitAndLoss || 0;
|
|
453
|
-
const holdTime = Math.floor((now - (this.positionEntryTime || now)) / 1000);
|
|
454
|
-
const posLog = smartLogs.getPositionUpdateLog(side, Math.abs(pos.quantity), unrealizedPnl, pos.averagePrice || 0, pos.averagePrice || 0, holdTime);
|
|
455
|
-
algoLogger.trade(this.ui, posLog.message, posLog.details);
|
|
456
|
-
}
|
|
457
|
-
} else {
|
|
458
|
-
// No position - show scanning status
|
|
448
|
+
if (this.leadPositions.size === 0) {
|
|
449
|
+
// Not in position - show market analysis (varied messages)
|
|
450
|
+
// Use scanning log since copy trading doesn't have strategy model values
|
|
459
451
|
const scanLog = smartLogs.getScanningLog(true);
|
|
460
|
-
|
|
452
|
+
this.ui.addLog('info', `${scanLog.message} poll #${this.pollCount} | ${pollTime}ms`);
|
|
461
453
|
}
|
|
454
|
+
// When IN POSITION: Don't spam logs every second
|
|
455
|
+
// Position updates come from order fills and exit events (copyPositionOpen/copyPositionClose)
|
|
462
456
|
this.lastLogTime = now;
|
|
463
457
|
}
|
|
464
458
|
|
package/src/pages/algo/ui.js
CHANGED
|
@@ -17,24 +17,21 @@ const SPINNER = ['\u280B', '\u2819', '\u2839', '\u2838', '\u283C', '\u2834', '\u
|
|
|
17
17
|
|
|
18
18
|
// Log type colors - HF grade BOLD
|
|
19
19
|
const LOG_COLORS = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
fill_sell: chalk.red.bold,
|
|
20
|
+
fill_buy: chalk.green,
|
|
21
|
+
fill_sell: chalk.red,
|
|
23
22
|
fill_win: chalk.green.bold,
|
|
24
23
|
fill_loss: chalk.red.bold,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
trade: chalk.yellow.bold,
|
|
37
|
-
success: chalk.green.bold
|
|
24
|
+
connected: chalk.cyan,
|
|
25
|
+
ready: chalk.green,
|
|
26
|
+
error: chalk.red,
|
|
27
|
+
reject: chalk.red,
|
|
28
|
+
info: chalk.cyan,
|
|
29
|
+
system: chalk.magenta,
|
|
30
|
+
signal: chalk.yellow.bold,
|
|
31
|
+
trade: chalk.green.bold,
|
|
32
|
+
warning: chalk.yellow,
|
|
33
|
+
success: chalk.green,
|
|
34
|
+
analysis: chalk.magenta
|
|
38
35
|
};
|
|
39
36
|
|
|
40
37
|
// Log type icons - UPPERCASE BOLD HF style
|
|
@@ -49,9 +46,11 @@ const LOG_ICONS = {
|
|
|
49
46
|
reject: 'REJ ',
|
|
50
47
|
info: 'INFO ',
|
|
51
48
|
system: 'SYS ',
|
|
52
|
-
signal: '
|
|
49
|
+
signal: 'SIG ',
|
|
53
50
|
trade: 'TRADE ',
|
|
54
|
-
success: 'OK '
|
|
51
|
+
success: 'OK ',
|
|
52
|
+
warning: 'WARN ',
|
|
53
|
+
analysis: 'ANLYS '
|
|
55
54
|
};
|
|
56
55
|
|
|
57
56
|
/**
|
|
@@ -59,6 +58,32 @@ const LOG_ICONS = {
|
|
|
59
58
|
*/
|
|
60
59
|
const stripAnsi = (str) => str.replace(/\x1B\[[0-9;]*m/g, '');
|
|
61
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Colorize message: positive numbers=cyan, negative=red, symbols=yellow
|
|
63
|
+
*/
|
|
64
|
+
const colorizeMessage = (msg) => {
|
|
65
|
+
if (!msg) return '';
|
|
66
|
+
|
|
67
|
+
// Already has ANSI codes? Return as-is
|
|
68
|
+
if (msg.includes('\x1B[')) return msg;
|
|
69
|
+
|
|
70
|
+
return msg
|
|
71
|
+
// Positive money: +$xxx.xx -> cyan
|
|
72
|
+
.replace(/\+\$[\d,]+\.?\d*/g, (m) => chalk.cyan.bold(m))
|
|
73
|
+
// Negative money: -$xxx.xx -> red
|
|
74
|
+
.replace(/-\$[\d,]+\.?\d*/g, (m) => chalk.red.bold(m))
|
|
75
|
+
// Positive numbers with + prefix: +123 -> cyan
|
|
76
|
+
.replace(/\+\d+\.?\d*/g, (m) => chalk.cyan(m))
|
|
77
|
+
// Negative numbers: -123 -> red
|
|
78
|
+
.replace(/-\d+\.?\d*/g, (m) => chalk.red(m))
|
|
79
|
+
// Symbols (futures contracts): NQ, ES, MNQ, MES, etc. -> yellow
|
|
80
|
+
.replace(/\b(NQ|ES|MNQ|MES|RTY|M2K|YM|MYM|CL|GC|SI)[A-Z]\d\b/g, (m) => chalk.yellow.bold(m))
|
|
81
|
+
// Percentages -> cyan
|
|
82
|
+
.replace(/\d+\.?\d*%/g, (m) => chalk.cyan(m))
|
|
83
|
+
// Prices (5 digits with decimal): 25688.50 -> white bold
|
|
84
|
+
.replace(/\b\d{4,5}\.\d{2}\b/g, (m) => chalk.white.bold(m));
|
|
85
|
+
};
|
|
86
|
+
|
|
62
87
|
/**
|
|
63
88
|
* Center text in width
|
|
64
89
|
*/
|
|
@@ -311,9 +336,12 @@ class AlgoUI {
|
|
|
311
336
|
} else {
|
|
312
337
|
visible.forEach(log => {
|
|
313
338
|
const color = LOG_COLORS[log.type] || chalk.gray;
|
|
314
|
-
const icon = LOG_ICONS[log.type] || '';
|
|
315
|
-
// HF style: TIME | TYPE | MESSAGE
|
|
316
|
-
const
|
|
339
|
+
const icon = LOG_ICONS[log.type] || 'INFO ';
|
|
340
|
+
// HF style: TIME | COLORED TYPE | MESSAGE with colored numbers
|
|
341
|
+
const coloredIcon = color.bold(icon);
|
|
342
|
+
// Color numbers: positive=cyan, negative=red, symbols=yellow
|
|
343
|
+
const coloredMessage = colorizeMessage(log.message);
|
|
344
|
+
const line = ` ${chalk.gray(log.timestamp)} ${coloredIcon}${coloredMessage}`;
|
|
317
345
|
this._line(chalk.cyan(BOX.V) + fitToWidth(line, W) + chalk.cyan(BOX.V));
|
|
318
346
|
});
|
|
319
347
|
for (let i = visible.length; i < maxLogs; i++) {
|