hedgequantx 2.6.77 → 2.6.79
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/ui.js +59 -23
package/package.json
CHANGED
package/src/pages/algo/ui.js
CHANGED
|
@@ -141,7 +141,11 @@ class AlgoUI {
|
|
|
141
141
|
this.spinnerFrame = 0;
|
|
142
142
|
this.firstDraw = true;
|
|
143
143
|
this.isDrawing = false;
|
|
144
|
-
this.
|
|
144
|
+
this.lines = [];
|
|
145
|
+
this.lastOutput = '';
|
|
146
|
+
this.lastStatsHash = ''; // Track stats changes
|
|
147
|
+
this.lastLogsHash = ''; // Track logs changes
|
|
148
|
+
this.lastSpinnerUpdate = 0; // Rate limit spinner updates
|
|
145
149
|
}
|
|
146
150
|
|
|
147
151
|
addLog(type, message) {
|
|
@@ -151,7 +155,7 @@ class AlgoUI {
|
|
|
151
155
|
}
|
|
152
156
|
|
|
153
157
|
_line(text) {
|
|
154
|
-
this.
|
|
158
|
+
this.lines.push(text);
|
|
155
159
|
}
|
|
156
160
|
|
|
157
161
|
_drawHeader() {
|
|
@@ -326,11 +330,16 @@ class AlgoUI {
|
|
|
326
330
|
const { W, logs, maxLogs } = this;
|
|
327
331
|
|
|
328
332
|
// Activity header - HF style
|
|
329
|
-
|
|
333
|
+
// Rate limit spinner: only update every 250ms to reduce flicker
|
|
334
|
+
const now = Date.now();
|
|
335
|
+
if (now - this.lastSpinnerUpdate >= 250) {
|
|
336
|
+
this.spinnerFrame = (this.spinnerFrame + 1) % SPINNER.length;
|
|
337
|
+
this.lastSpinnerUpdate = now;
|
|
338
|
+
}
|
|
330
339
|
const spinner = SPINNER[this.spinnerFrame];
|
|
331
|
-
const
|
|
332
|
-
const timeStr =
|
|
333
|
-
const dateStr =
|
|
340
|
+
const nowDate = new Date();
|
|
341
|
+
const timeStr = nowDate.toLocaleTimeString('en-US', { hour12: false });
|
|
342
|
+
const dateStr = nowDate.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
|
|
334
343
|
|
|
335
344
|
const leftText = ` EXECUTION LOG ${spinner}`;
|
|
336
345
|
const rightText = `[X] STOP `;
|
|
@@ -379,25 +388,52 @@ class AlgoUI {
|
|
|
379
388
|
if (this.isDrawing) return;
|
|
380
389
|
this.isDrawing = true;
|
|
381
390
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
391
|
+
// Quick hash to detect meaningful changes (skip spinner in hash)
|
|
392
|
+
const statsHash = JSON.stringify({
|
|
393
|
+
pnl: stats.pnl,
|
|
394
|
+
openPnl: stats.openPnl,
|
|
395
|
+
closedPnl: stats.closedPnl,
|
|
396
|
+
position: stats.position,
|
|
397
|
+
trades: stats.trades,
|
|
398
|
+
wins: stats.wins,
|
|
399
|
+
losses: stats.losses,
|
|
400
|
+
connected: stats.connected,
|
|
401
|
+
});
|
|
402
|
+
const logsHash = this.logs.length + (this.logs[this.logs.length - 1]?.message || '');
|
|
403
|
+
|
|
404
|
+
// Check if anything meaningful changed
|
|
405
|
+
const hasChanges = statsHash !== this.lastStatsHash || logsHash !== this.lastLogsHash;
|
|
406
|
+
|
|
407
|
+
// First draw or changes detected
|
|
408
|
+
if (this.firstDraw || hasChanges) {
|
|
409
|
+
this.lastStatsHash = statsHash;
|
|
410
|
+
this.lastLogsHash = logsHash;
|
|
411
|
+
|
|
412
|
+
this.lines = [];
|
|
413
|
+
|
|
414
|
+
if (this.firstDraw) {
|
|
415
|
+
// Enter alternate screen, hide cursor, clear once
|
|
416
|
+
process.stdout.write('\x1B[?1049h\x1B[?25l\x1B[2J');
|
|
417
|
+
this.firstDraw = false;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
this._line('');
|
|
421
|
+
this._drawHeader();
|
|
422
|
+
this._drawStats(stats);
|
|
423
|
+
this._drawLogs();
|
|
424
|
+
|
|
425
|
+
// Build output with fixed line positions
|
|
426
|
+
const output = this.lines.join('\n');
|
|
427
|
+
|
|
428
|
+
// Only write if content changed (reduces flicker significantly)
|
|
429
|
+
if (output !== this.lastOutput) {
|
|
430
|
+
// Move cursor to home, then write all lines
|
|
431
|
+
process.stdout.write('\x1B[H' + output);
|
|
432
|
+
this.lastOutput = output;
|
|
433
|
+
}
|
|
388
434
|
}
|
|
389
435
|
|
|
390
|
-
|
|
391
|
-
this.buffer += '\x1B[H';
|
|
392
|
-
this._line('');
|
|
393
|
-
this._drawHeader();
|
|
394
|
-
this._drawStats(stats);
|
|
395
|
-
this._drawLogs();
|
|
396
|
-
|
|
397
|
-
// Write buffer in one shot, then flush
|
|
398
|
-
process.stdout.write(this.buffer, () => {
|
|
399
|
-
this.isDrawing = false;
|
|
400
|
-
});
|
|
436
|
+
this.isDrawing = false;
|
|
401
437
|
}
|
|
402
438
|
|
|
403
439
|
cleanup() {
|