hedgequantx 2.9.65 → 2.9.67

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.9.65",
3
+ "version": "2.9.67",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -1,38 +1,32 @@
1
1
  /**
2
2
  * =============================================================================
3
- * Smart Logging System
3
+ * Smart Logging System - HF Grade
4
4
  * =============================================================================
5
- * Non-repetitive, contextual, varied log messages
6
- * - Uses message pools to avoid repetition
5
+ * Non-repetitive, contextual, varied log messages for professional HF CLI
6
+ * - Large message pools (10-15 per category) to avoid repetition
7
7
  * - Tracks recent messages to ensure variety
8
- * - Provides market-context-aware messages
8
+ * - Professional, institutional-grade messaging
9
9
  */
10
10
 
11
11
  'use strict';
12
12
 
13
13
  // Track recently used messages to avoid repetition
14
14
  const recentMessages = new Map();
15
- const MAX_RECENT = 5;
15
+ const MAX_RECENT = 8; // Increased to handle larger pools
16
16
 
17
17
  /**
18
18
  * Get a message from a pool, avoiding recent ones
19
19
  */
20
20
  function getVariedMessage(category, pool, defaultMsg) {
21
21
  const recent = recentMessages.get(category) || [];
22
-
23
- // Filter out recently used messages
24
22
  const available = pool.filter(msg => !recent.includes(msg));
25
23
 
26
- // If all messages were recently used, reset
27
24
  if (available.length === 0) {
28
25
  recentMessages.set(category, []);
29
26
  return pool[Math.floor(Math.random() * pool.length)] || defaultMsg;
30
27
  }
31
28
 
32
- // Pick a random available message
33
29
  const chosen = available[Math.floor(Math.random() * available.length)] || defaultMsg;
34
-
35
- // Track it
36
30
  recent.push(chosen);
37
31
  if (recent.length > MAX_RECENT) recent.shift();
38
32
  recentMessages.set(category, recent);
@@ -41,35 +35,73 @@ function getVariedMessage(category, pool, defaultMsg) {
41
35
  }
42
36
 
43
37
  // =============================================================================
44
- // MESSAGE POOLS - Market Flow
38
+ // MESSAGE POOLS - Market Flow (Bullish)
45
39
  // =============================================================================
46
40
 
47
41
  const LONG_BIAS_MESSAGES = [
48
- 'Bullish bias detected',
49
- 'Buyers in control',
50
- 'Long-side pressure',
51
- 'Bid accumulation',
42
+ 'Buyers taking control',
43
+ 'Bid side absorbing',
44
+ 'Bullish order flow detected',
52
45
  'Buy programs active',
46
+ 'Strong buyer presence',
47
+ 'Accumulation pattern',
48
+ 'Demand exceeding supply',
49
+ 'Buyers stepping up',
50
+ 'Long-side momentum building',
51
+ 'Bid accumulation detected',
52
+ 'Bullish delta divergence',
53
+ 'Buy-side imbalance',
54
+ 'Institutional buying detected',
55
+ 'Aggressive bid lifting',
56
+ 'Bullish tape reading',
53
57
  ];
54
58
 
59
+ // =============================================================================
60
+ // MESSAGE POOLS - Market Flow (Bearish)
61
+ // =============================================================================
62
+
55
63
  const SHORT_BIAS_MESSAGES = [
56
- 'Bearish bias detected',
57
- 'Sellers in control',
58
- 'Short-side pressure',
59
- 'Offer distribution',
64
+ 'Sellers taking control',
65
+ 'Offer side absorbing',
66
+ 'Bearish order flow detected',
60
67
  'Sell programs active',
68
+ 'Strong seller presence',
69
+ 'Distribution pattern',
70
+ 'Supply exceeding demand',
71
+ 'Sellers stepping in',
72
+ 'Short-side momentum building',
73
+ 'Offer distribution detected',
74
+ 'Bearish delta divergence',
75
+ 'Sell-side imbalance',
76
+ 'Institutional selling detected',
77
+ 'Aggressive offer hitting',
78
+ 'Bearish tape reading',
61
79
  ];
62
80
 
81
+ // =============================================================================
82
+ // MESSAGE POOLS - Market Flow (Neutral)
83
+ // =============================================================================
84
+
63
85
  const FLAT_BIAS_MESSAGES = [
64
86
  'Market balanced',
65
- 'Two-way flow',
87
+ 'Two-way flow active',
66
88
  'Consolidation mode',
67
89
  'No clear direction',
68
- 'Mixed signals',
90
+ 'Mixed signals detected',
91
+ 'Range-bound activity',
92
+ 'Equilibrium state',
93
+ 'Neutral order flow',
94
+ 'Balanced book pressure',
95
+ 'Rotation in progress',
96
+ 'Price discovery phase',
97
+ 'Awaiting catalyst',
98
+ 'Sideways chop detected',
99
+ 'Mean reversion zone',
100
+ 'Liquidity absorption',
69
101
  ];
70
102
 
71
103
  // =============================================================================
72
- // MESSAGE POOLS - Trading Events
104
+ // MESSAGE POOLS - Trading Signals
73
105
  // =============================================================================
74
106
 
75
107
  const SIGNAL_LONG_MESSAGES = [
@@ -78,6 +110,11 @@ const SIGNAL_LONG_MESSAGES = [
78
110
  'Bullish setup confirmed',
79
111
  'Entry signal: LONG',
80
112
  'Buy zone activated',
113
+ 'Long trigger fired',
114
+ 'Bullish confirmation received',
115
+ 'Buy entry validated',
116
+ 'Long setup materialized',
117
+ 'Bullish pattern complete',
81
118
  ];
82
119
 
83
120
  const SIGNAL_SHORT_MESSAGES = [
@@ -86,14 +123,28 @@ const SIGNAL_SHORT_MESSAGES = [
86
123
  'Bearish setup confirmed',
87
124
  'Entry signal: SHORT',
88
125
  'Sell zone activated',
126
+ 'Short trigger fired',
127
+ 'Bearish confirmation received',
128
+ 'Sell entry validated',
129
+ 'Short setup materialized',
130
+ 'Bearish pattern complete',
89
131
  ];
90
132
 
133
+ // =============================================================================
134
+ // MESSAGE POOLS - Trade Execution
135
+ // =============================================================================
136
+
91
137
  const ENTRY_LONG_MESSAGES = [
92
138
  'Long position opened',
93
139
  'Buy order filled',
94
140
  'Entered long',
95
141
  'Long initiated',
96
142
  'Position: LONG',
143
+ 'Long execution complete',
144
+ 'Buy fill confirmed',
145
+ 'Long entry executed',
146
+ 'Bought at market',
147
+ 'Long position established',
97
148
  ];
98
149
 
99
150
  const ENTRY_SHORT_MESSAGES = [
@@ -102,6 +153,11 @@ const ENTRY_SHORT_MESSAGES = [
102
153
  'Entered short',
103
154
  'Short initiated',
104
155
  'Position: SHORT',
156
+ 'Short execution complete',
157
+ 'Sell fill confirmed',
158
+ 'Short entry executed',
159
+ 'Sold at market',
160
+ 'Short position established',
105
161
  ];
106
162
 
107
163
  const EXIT_PROFIT_MESSAGES = [
@@ -110,6 +166,11 @@ const EXIT_PROFIT_MESSAGES = [
110
166
  'Winner closed',
111
167
  'TP hit',
112
168
  'Profit locked',
169
+ 'Gain realized',
170
+ 'Profitable exit',
171
+ 'Target achieved',
172
+ 'Winner booked',
173
+ 'Profit captured',
113
174
  ];
114
175
 
115
176
  const EXIT_LOSS_MESSAGES = [
@@ -118,10 +179,15 @@ const EXIT_LOSS_MESSAGES = [
118
179
  'Loser closed',
119
180
  'SL hit',
120
181
  'Risk contained',
182
+ 'Loss realized',
183
+ 'Stop executed',
184
+ 'Risk managed',
185
+ 'Loser booked',
186
+ 'Loss controlled',
121
187
  ];
122
188
 
123
189
  // =============================================================================
124
- // MESSAGE POOLS - Analysis
190
+ // MESSAGE POOLS - Zone Analysis
125
191
  // =============================================================================
126
192
 
127
193
  const ZONE_APPROACH_MESSAGES = [
@@ -130,6 +196,11 @@ const ZONE_APPROACH_MESSAGES = [
130
196
  'Near decision point',
131
197
  'Level approach detected',
132
198
  'Key zone in range',
199
+ 'Price nearing structure',
200
+ 'Zone proximity alert',
201
+ 'Testing liquidity zone',
202
+ 'Approaching pivot',
203
+ 'Near high-volume node',
133
204
  ];
134
205
 
135
206
  const ZONE_CONFIRMED_MESSAGES = [
@@ -138,14 +209,28 @@ const ZONE_CONFIRMED_MESSAGES = [
138
209
  'Support/resistance active',
139
210
  'Zone reaction detected',
140
211
  'Level holding',
212
+ 'Structure confirmed',
213
+ 'Zone defense active',
214
+ 'Level response detected',
215
+ 'Pivot confirmed',
216
+ 'Volume node reaction',
141
217
  ];
142
218
 
219
+ // =============================================================================
220
+ // MESSAGE POOLS - Volatility
221
+ // =============================================================================
222
+
143
223
  const HIGH_VOLATILITY_MESSAGES = [
144
224
  'Volatility elevated',
145
225
  'High ATR detected',
146
226
  'Increased price range',
147
227
  'Market volatile',
148
228
  'Wide swings detected',
229
+ 'Volatility expansion',
230
+ 'Range expanding',
231
+ 'High activity zone',
232
+ 'Momentum surge',
233
+ 'Breakout conditions',
149
234
  ];
150
235
 
151
236
  const LOW_VOLATILITY_MESSAGES = [
@@ -154,10 +239,15 @@ const LOW_VOLATILITY_MESSAGES = [
154
239
  'Compressed price action',
155
240
  'Market quiet',
156
241
  'Narrow swings',
242
+ 'Volatility contraction',
243
+ 'Range compressing',
244
+ 'Low activity zone',
245
+ 'Momentum cooling',
246
+ 'Consolidation forming',
157
247
  ];
158
248
 
159
249
  // =============================================================================
160
- // MESSAGE POOLS - Risk
250
+ // MESSAGE POOLS - Risk Management
161
251
  // =============================================================================
162
252
 
163
253
  const RISK_PASSED_MESSAGES = [
@@ -166,6 +256,11 @@ const RISK_PASSED_MESSAGES = [
166
256
  'Within risk limits',
167
257
  'Risk validated',
168
258
  'Clear to trade',
259
+ 'Risk parameters met',
260
+ 'Position size approved',
261
+ 'Risk budget OK',
262
+ 'Trade authorized',
263
+ 'Risk constraints satisfied',
169
264
  ];
170
265
 
171
266
  const RISK_BLOCKED_MESSAGES = [
@@ -174,6 +269,11 @@ const RISK_BLOCKED_MESSAGES = [
174
269
  'Exceeds risk threshold',
175
270
  'Risk rejected',
176
271
  'Waiting for conditions',
272
+ 'Risk parameters exceeded',
273
+ 'Position size rejected',
274
+ 'Risk budget depleted',
275
+ 'Trade denied',
276
+ 'Risk constraints violated',
177
277
  ];
178
278
 
179
279
  // =============================================================================
@@ -186,6 +286,16 @@ const SCANNING_MESSAGES = [
186
286
  'Monitoring structure...',
187
287
  'Watching for setups...',
188
288
  'Evaluating conditions...',
289
+ 'Processing market data...',
290
+ 'Analyzing order book...',
291
+ 'Monitoring tape...',
292
+ 'Scanning for alpha...',
293
+ 'Evaluating price action...',
294
+ 'Analyzing microstructure...',
295
+ 'Monitoring imbalances...',
296
+ 'Scanning liquidity zones...',
297
+ 'Evaluating momentum...',
298
+ 'Analyzing market regime...',
189
299
  ];
190
300
 
191
301
  const WAITING_MESSAGES = [
@@ -194,10 +304,15 @@ const WAITING_MESSAGES = [
194
304
  'Standby mode...',
195
305
  'Awaiting signal...',
196
306
  'Ready to act...',
307
+ 'Monitoring for entry...',
308
+ 'Waiting for setup...',
309
+ 'Confirmation pending...',
310
+ 'Entry conditions not met...',
311
+ 'Awaiting confluence...',
197
312
  ];
198
313
 
199
314
  // =============================================================================
200
- // MESSAGE POOLS - Tick Flow
315
+ // MESSAGE POOLS - Data Flow
201
316
  // =============================================================================
202
317
 
203
318
  const TICK_FLOW_MESSAGES = [
@@ -206,6 +321,16 @@ const TICK_FLOW_MESSAGES = [
206
321
  'Live feed active',
207
322
  'Tick stream healthy',
208
323
  'Data streaming',
324
+ 'Feed connection stable',
325
+ 'Real-time data active',
326
+ 'Tick processing nominal',
327
+ 'Data pipeline healthy',
328
+ 'Market feed online',
329
+ 'Tick ingestion active',
330
+ 'Data flow nominal',
331
+ 'Stream latency optimal',
332
+ 'Feed quality excellent',
333
+ 'Data throughput normal',
209
334
  ];
210
335
 
211
336
  const BUILDING_BARS_MESSAGES = [
@@ -214,6 +339,11 @@ const BUILDING_BARS_MESSAGES = [
214
339
  'Forming candles',
215
340
  'Bar construction',
216
341
  'Chart building',
342
+ 'OHLC aggregation',
343
+ 'Bar formation active',
344
+ 'Candle building',
345
+ 'Time bar processing',
346
+ 'Bar data updating',
217
347
  ];
218
348
 
219
349
  const MODEL_ANALYSIS_MESSAGES = [
@@ -222,15 +352,22 @@ const MODEL_ANALYSIS_MESSAGES = [
222
352
  'Computing signals',
223
353
  'Model evaluation',
224
354
  'Strategy analysis',
355
+ 'ML inference active',
356
+ 'Pattern recognition',
357
+ 'Signal computation',
358
+ 'Model processing',
359
+ 'Algorithm evaluation',
360
+ 'Quantitative analysis',
361
+ 'Statistical modeling',
362
+ 'Feature extraction',
363
+ 'Predictive analysis',
364
+ 'Model optimization',
225
365
  ];
226
366
 
227
367
  // =============================================================================
228
368
  // SMART LOG GENERATORS
229
369
  // =============================================================================
230
370
 
231
- /**
232
- * Get a market bias log
233
- */
234
371
  function getMarketBiasLog(direction, delta, buyPressure) {
235
372
  let pool;
236
373
  switch (direction) {
@@ -250,9 +387,6 @@ function getMarketBiasLog(direction, delta, buyPressure) {
250
387
  return { message, details };
251
388
  }
252
389
 
253
- /**
254
- * Get a signal log
255
- */
256
390
  function getSignalLog(direction, symbol, confidence, strategy) {
257
391
  const pool = direction === 'LONG' ? SIGNAL_LONG_MESSAGES : SIGNAL_SHORT_MESSAGES;
258
392
  const message = getVariedMessage(`signal_${direction}`, pool, `${direction} signal`);
@@ -264,9 +398,6 @@ function getSignalLog(direction, symbol, confidence, strategy) {
264
398
  };
265
399
  }
266
400
 
267
- /**
268
- * Get an entry log
269
- */
270
401
  function getEntryLog(direction, symbol, size, price) {
271
402
  const pool = direction === 'LONG' ? ENTRY_LONG_MESSAGES : ENTRY_SHORT_MESSAGES;
272
403
  const message = getVariedMessage(`entry_${direction}`, pool, `${direction} entry`);
@@ -278,9 +409,6 @@ function getEntryLog(direction, symbol, size, price) {
278
409
  };
279
410
  }
280
411
 
281
- /**
282
- * Get an exit log
283
- */
284
412
  function getExitLog(isProfit, symbol, size, price, pnl) {
285
413
  const pool = isProfit ? EXIT_PROFIT_MESSAGES : EXIT_LOSS_MESSAGES;
286
414
  const category = isProfit ? 'exit_profit' : 'exit_loss';
@@ -293,25 +421,16 @@ function getExitLog(isProfit, symbol, size, price, pnl) {
293
421
  };
294
422
  }
295
423
 
296
- /**
297
- * Get a zone approach log
298
- */
299
424
  function getZoneApproachLog(zoneType, level) {
300
425
  const message = getVariedMessage('zone_approach', ZONE_APPROACH_MESSAGES, 'Zone approach');
301
426
  return { message, details: `${zoneType} @ ${level.toFixed(2)}` };
302
427
  }
303
428
 
304
- /**
305
- * Get a zone confirmation log
306
- */
307
429
  function getZoneConfirmationLog(zoneType, level) {
308
430
  const message = getVariedMessage('zone_confirm', ZONE_CONFIRMED_MESSAGES, 'Zone confirmed');
309
431
  return { message, details: `${zoneType} @ ${level.toFixed(2)}` };
310
432
  }
311
433
 
312
- /**
313
- * Get a volatility log
314
- */
315
434
  function getVolatilityLog(isHigh, atr) {
316
435
  const pool = isHigh ? HIGH_VOLATILITY_MESSAGES : LOW_VOLATILITY_MESSAGES;
317
436
  const category = isHigh ? 'vol_high' : 'vol_low';
@@ -319,9 +438,6 @@ function getVolatilityLog(isHigh, atr) {
319
438
  return { message, details: atr ? `ATR: ${atr.toFixed(2)}` : undefined };
320
439
  }
321
440
 
322
- /**
323
- * Get a risk check log
324
- */
325
441
  function getRiskCheckLog(passed, reason) {
326
442
  const pool = passed ? RISK_PASSED_MESSAGES : RISK_BLOCKED_MESSAGES;
327
443
  const category = passed ? 'risk_pass' : 'risk_block';
@@ -329,9 +445,6 @@ function getRiskCheckLog(passed, reason) {
329
445
  return { message, details: reason };
330
446
  }
331
447
 
332
- /**
333
- * Get a scanning/waiting log
334
- */
335
448
  function getScanningLog(isScanning = true) {
336
449
  const pool = isScanning ? SCANNING_MESSAGES : WAITING_MESSAGES;
337
450
  const category = isScanning ? 'scanning' : 'waiting';
@@ -339,25 +452,16 @@ function getScanningLog(isScanning = true) {
339
452
  return { message };
340
453
  }
341
454
 
342
- /**
343
- * Get tick flow log
344
- */
345
455
  function getTickFlowLog(tickCount, ticksPerSecond) {
346
456
  const message = getVariedMessage('tick_flow', TICK_FLOW_MESSAGES, 'Tick flow');
347
457
  return { message, details: `#${tickCount} | ${ticksPerSecond}/sec` };
348
458
  }
349
459
 
350
- /**
351
- * Get building bars log
352
- */
353
460
  function getBuildingBarsLog(barCount) {
354
461
  const message = getVariedMessage('building_bars', BUILDING_BARS_MESSAGES, 'Building bars');
355
462
  return { message, details: `${barCount} bars` };
356
463
  }
357
464
 
358
- /**
359
- * Get model analysis log
360
- */
361
465
  function getModelAnalysisLog(modelValues) {
362
466
  const message = getVariedMessage('model_analysis', MODEL_ANALYSIS_MESSAGES, 'Analyzing');
363
467
  const details = modelValues
@@ -366,14 +470,10 @@ function getModelAnalysisLog(modelValues) {
366
470
  return { message, details };
367
471
  }
368
472
 
369
- /**
370
- * Get position update log with varied messaging
371
- */
372
473
  function getPositionUpdateLog(side, size, unrealizedPnL, distanceToStop, distanceToTarget, holdTime) {
373
474
  const arrow = side === 'LONG' ? '▲' : '▼';
374
475
  const pnlStr = unrealizedPnL >= 0 ? `+$${unrealizedPnL.toFixed(2)}` : `-$${Math.abs(unrealizedPnL).toFixed(2)}`;
375
476
 
376
- // Vary the message based on P&L status
377
477
  let prefix;
378
478
  if (unrealizedPnL > 0 && distanceToTarget < distanceToStop) {
379
479
  const targetPct = Math.round((1 - distanceToTarget / (distanceToStop + distanceToTarget)) * 100);
@@ -393,9 +493,6 @@ function getPositionUpdateLog(side, size, unrealizedPnL, distanceToStop, distanc
393
493
  };
394
494
  }
395
495
 
396
- /**
397
- * Get price change log
398
- */
399
496
  function getPriceChangeLog(direction, price, change) {
400
497
  const arrow = direction === 'UP' ? '▲' : '▼';
401
498
  return { message: `${arrow} ${price.toFixed(2)}`, details: `${direction} ${change.toFixed(2)}` };
@@ -274,14 +274,17 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
274
274
  lastBias = bias;
275
275
  }
276
276
 
277
- // Model analysis every 5 seconds
278
- if (currentSecond % 5 === 0) {
279
- const modelValues = strategy.getModelValues?.(contractId);
280
- if (modelValues) {
281
- barCount = modelValues.bars || barCount;
282
- if (barCount >= 50) {
283
- const modelLog = smartLogs.getModelAnalysisLog(modelValues);
284
- ui.addLog('analysis', `${modelLog.message} ${modelLog.details || ''}`);
277
+ // Strategy state log every 10 seconds
278
+ if (currentSecond % 10 === 0) {
279
+ const state = strategy.getAnalysisState?.(contractId, price);
280
+ if (state) {
281
+ if (!state.ready) {
282
+ ui.addLog('system', state.message);
283
+ } else {
284
+ const resStr = state.nearestResistance ? state.nearestResistance.toFixed(2) : '--';
285
+ const supStr = state.nearestSupport ? state.nearestSupport.toFixed(2) : '--';
286
+ ui.addLog('analysis', `Bars: ${state.barsProcessed} | Zones: ${state.activeZones} | Swings: ${state.swingsDetected}`);
287
+ ui.addLog('analysis', `Resistance: ${resStr} | Support: ${supStr}`);
285
288
  }
286
289
  }
287
290
  }