hedgequantx 2.6.52 → 2.6.54

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.52",
3
+ "version": "2.6.54",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -724,7 +724,7 @@ const launchAlgo = async (service, account, contract, config) => {
724
724
 
725
725
  stats.latency = Date.now() - latencyStart;
726
726
 
727
- // Smart logs every 1 second - non-repetitive, varied messages
727
+ // Smart logs - only on STATE CHANGES (not every second when in position)
728
728
  const now = Date.now();
729
729
  if (now - lastHeartbeat > 1000) {
730
730
  const modelValues = strategy.getModelValues?.() || strategy.getModelValues?.(contractId) || null;
@@ -735,32 +735,28 @@ const launchAlgo = async (service, account, contract, config) => {
735
735
  const zscore = modelValues.zscore || 0;
736
736
  const mom = modelValues.momentum || 0;
737
737
 
738
- // Get smart varied log based on market state
739
- const smartLogs = require('./smart-logs');
740
- const stateLog = smartLogs.getMarketStateLog(ofi, zscore, mom, delta);
741
-
742
738
  // Use stats.position from Rithmic API (real-time WebSocket)
743
739
  const positionQty = stats.position || 0;
744
- if (positionQty !== 0) {
745
- // In position - show position status with varied messages
746
- const side = positionQty > 0 ? 'LONG' : 'SHORT';
747
- const unrealizedPnl = stats.openPnl || 0;
748
- const holdTime = Math.floor((now - (stats.entryTime || now)) / 1000);
749
- const posLog = smartLogs.getPositionUpdateLog(side, Math.abs(positionQty), unrealizedPnl, stats.entryPrice, tickData.price, holdTime);
750
- ui.addLog('trade', `${posLog.message} - ${posLog.details}`);
751
- } else {
752
- // Not in position - show market state with varied messages
740
+
741
+ if (positionQty === 0) {
742
+ // Not in position - show market analysis (varied messages)
743
+ const smartLogs = require('./smart-logs');
744
+ const stateLog = smartLogs.getMarketStateLog(ofi, zscore, mom, delta);
753
745
  if (stateLog.details) {
754
746
  ui.addLog('analysis', `${stateLog.message} - ${stateLog.details}`);
755
747
  } else {
756
748
  ui.addLog('info', stateLog.message);
757
749
  }
758
750
  }
751
+ // When IN POSITION: Don't spam logs every second
752
+ // Position updates come from order fills and exit events
759
753
  } else {
760
- // Waiting for data
761
- const smartLogs = require('./smart-logs');
762
- const scanLog = smartLogs.getScanningLog(true);
763
- ui.addLog('info', `${scanLog.message} ${tps} ticks/s`);
754
+ // Waiting for data - log every 5 seconds only
755
+ if (now - lastHeartbeat > 5000) {
756
+ const smartLogs = require('./smart-logs');
757
+ const scanLog = smartLogs.getScanningLog(true);
758
+ ui.addLog('info', `${scanLog.message} ${tps} ticks/s`);
759
+ }
764
760
  }
765
761
  lastHeartbeat = now;
766
762
  tps = 0;
@@ -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
- // Executions
21
- fill_buy: chalk.green.bold,
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
- // Status
26
- connected: chalk.green.bold,
27
- ready: chalk.cyan.bold,
28
- // Errors
29
- error: chalk.red.bold,
30
- reject: chalk.red.bold,
31
- // Info
32
- info: chalk.gray,
33
- system: chalk.blue.bold,
34
- // Trading
35
- signal: chalk.magenta.bold,
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: '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 line = ` ${chalk.gray(log.timestamp)} ${color(icon)}${log.message}`;
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++) {