hedgequantx 2.6.78 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedgequantx",
3
- "version": "2.6.78",
3
+ "version": "2.6.79",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -143,6 +143,9 @@ class AlgoUI {
143
143
  this.isDrawing = false;
144
144
  this.lines = [];
145
145
  this.lastOutput = '';
146
+ this.lastStatsHash = ''; // Track stats changes
147
+ this.lastLogsHash = ''; // Track logs changes
148
+ this.lastSpinnerUpdate = 0; // Rate limit spinner updates
146
149
  }
147
150
 
148
151
  addLog(type, message) {
@@ -327,11 +330,16 @@ class AlgoUI {
327
330
  const { W, logs, maxLogs } = this;
328
331
 
329
332
  // Activity header - HF style
330
- this.spinnerFrame = (this.spinnerFrame + 1) % SPINNER.length;
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
+ }
331
339
  const spinner = SPINNER[this.spinnerFrame];
332
- const now = new Date();
333
- const timeStr = now.toLocaleTimeString('en-US', { hour12: false });
334
- const dateStr = now.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
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' });
335
343
 
336
344
  const leftText = ` EXECUTION LOG ${spinner}`;
337
345
  const rightText = `[X] STOP `;
@@ -380,27 +388,49 @@ class AlgoUI {
380
388
  if (this.isDrawing) return;
381
389
  this.isDrawing = true;
382
390
 
383
- this.lines = [];
384
-
385
- if (this.firstDraw) {
386
- // Enter alternate screen, hide cursor, clear once
387
- process.stdout.write('\x1B[?1049h\x1B[?25l\x1B[2J');
388
- this.firstDraw = false;
389
- }
390
-
391
- this._line('');
392
- this._drawHeader();
393
- this._drawStats(stats);
394
- this._drawLogs();
395
-
396
- // Build output with fixed line positions
397
- const output = this.lines.join('\n');
398
-
399
- // Only write if content changed (reduces flicker significantly)
400
- if (output !== this.lastOutput) {
401
- // Move cursor to home, then write all lines
402
- process.stdout.write('\x1B[H' + output);
403
- this.lastOutput = output;
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
+ }
404
434
  }
405
435
 
406
436
  this.isDrawing = false;