hedgequantx 2.9.212 → 2.9.214

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.212",
3
+ "version": "2.9.214",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
package/src/app.js CHANGED
@@ -179,17 +179,23 @@ const run = async () => {
179
179
  // First launch - show banner then try restore session
180
180
  await banner();
181
181
 
182
- const spinner = ora({ text: 'LOADING DASHBOARD...', color: 'yellow' }).start();
182
+ const spinner = ora({ text: 'Restoring session...', color: 'cyan' }).start();
183
183
 
184
184
  const restored = await connections.restoreFromStorage();
185
185
 
186
186
  if (restored) {
187
- currentService = connections.getAll()[0].service;
187
+ const conn = connections.getAll()[0];
188
+ currentService = conn.service;
189
+ const accountCount = currentService.accounts?.length || 0;
190
+ spinner.succeed(`Session restored: ${conn.propfirm} (${accountCount} accounts)`);
191
+ await new Promise(r => setTimeout(r, 500));
192
+
193
+ const spinner2 = ora({ text: 'Loading dashboard...', color: 'yellow' }).start();
188
194
  await refreshStats();
189
- // Store spinner globally - dashboard will stop it when ready to display
190
- global.__hqxSpinner = spinner;
195
+ global.__hqxSpinner = spinner2;
191
196
  } else {
192
- spinner.stop(); // Stop spinner - no session to restore
197
+ spinner.info('No saved session - please login');
198
+ await new Promise(r => setTimeout(r, 500));
193
199
  global.__hqxSpinner = null;
194
200
  }
195
201
 
@@ -266,29 +266,40 @@ const STRATEGY_CONTEXT = {
266
266
  'Microstructure analysis loading',
267
267
  'Tick distribution fitting',
268
268
  ],
269
+ // Dynamic scanning messages - will be combined with real QUANT values
269
270
  scanning: [
270
- 'Scanning for statistical edge',
271
- 'Z-Score within normal bounds',
272
- 'No mean reversion signal',
273
- 'VPIN clean, no toxicity',
274
- 'OFI balanced, no imbalance',
275
- 'Waiting for regime shift',
276
- 'Factor model neutral',
277
- 'Statistical noise, no alpha',
278
- 'Mean at fair value',
279
- 'No exploitable edge detected',
271
+ 'Mean reversion scan active',
272
+ 'Monitoring Z deviation',
273
+ 'VPIN/OFI correlation check',
274
+ 'Statistical edge scan',
275
+ 'Factor alignment check',
276
+ 'Regime detection active',
277
+ 'Microstructure analysis',
278
+ 'Tick flow monitoring',
279
+ 'Volatility regime stable',
280
+ 'Awaiting Z extremity',
281
+ 'OFI flow balanced',
282
+ 'VPIN toxicity normal',
283
+ 'Mean convergence watch',
284
+ 'Distribution tail scan',
285
+ 'Alpha detection active',
286
+ 'Momentum factor check',
287
+ 'Price discovery tracking',
288
+ 'Orderflow imbalance scan',
289
+ 'Statistical noise filter',
290
+ 'Edge detection running',
280
291
  ],
281
292
  signal: [
282
293
  'Statistical edge detected',
283
- 'Z-Score extreme, mean reversion due',
294
+ 'Z-Score extreme - mean reversion',
284
295
  'VPIN/OFI alignment confirmed',
285
296
  'Factor model signal active',
286
- 'Mean reversion setup forming',
287
- 'Statistical alpha opportunity',
288
- 'Regime shift detected',
289
- 'Edge exploitation window',
297
+ 'Mean reversion setup',
298
+ 'Statistical alpha found',
299
+ 'Regime shift confirmed',
300
+ 'Edge exploitation ready',
290
301
  'QUANT signal triggered',
291
- 'Model confidence threshold met',
302
+ 'Model confidence high',
292
303
  ],
293
304
  },
294
305
 
@@ -28,6 +28,8 @@ const CONFIG = {
28
28
  OFI_THRESHOLD: 0.15,
29
29
  VPIN_TOXIC: 0.6,
30
30
  QUANT_WARMUP_TICKS: 250,
31
+ // Heartbeat interval - frequent updates in scanning mode
32
+ HEARTBEAT_MS: 5000, // 5 seconds
31
33
  };
32
34
 
33
35
  const SYMBOLS = {
@@ -52,7 +54,7 @@ class SmartLogsEngine {
52
54
  this.symbolCode = symbol;
53
55
  this.counter = 0;
54
56
  this.lastState = null;
55
- this.lastHeartbeat = 0;
57
+ this.lastLogTime = 0;
56
58
 
57
59
  // State tracking for event detection (both strategies)
58
60
  this.lastBias = null;
@@ -67,6 +69,10 @@ class SmartLogsEngine {
67
69
  // QUANT specific
68
70
  this.lastZRegime = null;
69
71
  this.lastVpinToxic = false;
72
+ this.lastPrice = 0;
73
+ this.lastLoggedZ = null;
74
+ this.lastLoggedOfi = null;
75
+ this.recentMessages = [];
70
76
  }
71
77
 
72
78
  setSymbol(s) { this.symbolCode = s; }
@@ -229,20 +235,62 @@ class SmartLogsEngine {
229
235
  this.lastVpinToxic = vpinToxic;
230
236
 
231
237
  if (event && message) {
232
- this.lastHeartbeat = Date.now();
238
+ this.lastLogTime = Date.now();
239
+ this.lastPrice = state.price;
240
+ this.lastLoggedZ = zScore;
241
+ this.lastLoggedOfi = ofi;
233
242
  return { type: logType, message, logToSession: event === 'z_regime' || event === 'bias_flip' };
234
243
  }
235
244
 
236
- // HEARTBEAT: Show status every 30s when no events (proves strategy is active)
245
+ // REAL-TIME LOGS: Every second, show meaningful market activity
237
246
  const now = Date.now();
238
- if (this.warmupLogged && now - this.lastHeartbeat >= 30000) {
239
- this.lastHeartbeat = now;
240
- // Use instrument + strategy contextual message
241
- const marketCtx = bias === 'bullish' ? 'bullish' : bias === 'bearish' ? 'bearish' : 'neutral';
242
- const ctxMsg = getContextualMessage(this.symbolCode, this.strategyId, marketCtx);
247
+ if (this.warmupLogged && now - this.lastLogTime >= 1000) {
248
+ const price = state.price || 0;
249
+ const priceChange = this.lastPrice ? price - this.lastPrice : 0;
250
+ const zChange = this.lastLoggedZ !== null ? zScore - this.lastLoggedZ : 0;
251
+ const ofiChange = this.lastLoggedOfi !== null ? ofi - this.lastLoggedOfi : 0;
252
+
253
+ this.lastLogTime = now;
254
+ this.lastPrice = price;
255
+ this.lastLoggedZ = zScore;
256
+ this.lastLoggedOfi = ofi;
257
+
258
+ // Build contextual message based on what's actually happening
259
+ const zStr = zScore >= 0 ? `+${zScore.toFixed(1)}` : zScore.toFixed(1);
260
+ const ofiPct = (ofi * 100).toFixed(0);
261
+ const vpinPct = (vpin * 100).toFixed(0);
262
+
263
+ // Determine what's notable RIGHT NOW
264
+ let context;
265
+ if (Math.abs(priceChange) >= 0.5) {
266
+ // Price moved significantly
267
+ const dir = priceChange > 0 ? 'uptick' : 'downtick';
268
+ const ticks = Math.abs(priceChange / 0.25).toFixed(0);
269
+ context = `${dir} ${ticks}t`;
270
+ } else if (Math.abs(zChange) >= 0.3) {
271
+ // Z-Score shifting
272
+ context = zChange > 0 ? 'Z expanding' : 'Z contracting';
273
+ } else if (Math.abs(ofiChange) >= 0.05) {
274
+ // OFI shifting
275
+ context = ofiChange > 0 ? 'buying pressure' : 'selling pressure';
276
+ } else if (absZ >= 1.5) {
277
+ // In signal zone
278
+ const dir = zScore < 0 ? 'LONG zone' : 'SHORT zone';
279
+ context = dir;
280
+ } else if (Math.abs(ofi) >= 0.15) {
281
+ // Strong flow
282
+ context = ofi > 0 ? 'bid strength' : 'offer strength';
283
+ } else if (vpin > 0.4) {
284
+ // Elevated VPIN
285
+ context = 'elevated toxicity';
286
+ } else {
287
+ // Get instrument-specific neutral message
288
+ context = getContextualMessage(this.symbolCode, this.strategyId, 'neutral');
289
+ }
290
+
243
291
  return {
244
292
  type: 'analysis',
245
- message: `[${sym}] ${price} | Z: ${zScore.toFixed(1)}σ | OFI: ${(ofi * 100).toFixed(0)}% | ${ctxMsg}`,
293
+ message: `[${sym}] ${price.toFixed(2)} | Z: ${zStr}σ | OFI: ${ofiPct}% | ${context}`,
246
294
  logToSession: false
247
295
  };
248
296
  }
@@ -255,7 +303,7 @@ class SmartLogsEngine {
255
303
  this.counter = 0;
256
304
  this.lastBias = null;
257
305
  this.warmupLogged = false;
258
- this.lastHeartbeat = 0;
306
+ this.lastLogTime = 0;
259
307
  // HQX-2B
260
308
  this.lastBars = 0;
261
309
  this.lastSwings = 0;
@@ -264,6 +312,10 @@ class SmartLogsEngine {
264
312
  // QUANT
265
313
  this.lastZRegime = null;
266
314
  this.lastVpinToxic = false;
315
+ this.lastPrice = 0;
316
+ this.lastLoggedZ = null;
317
+ this.lastLoggedOfi = null;
318
+ this.recentMessages = [];
267
319
  }
268
320
  }
269
321