hedgequantx 2.9.212 → 2.9.213
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/lib/smart-logs-context.js +27 -16
- package/src/lib/smart-logs-engine.js +62 -10
package/package.json
CHANGED
|
@@ -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
|
-
'
|
|
271
|
-
'Z
|
|
272
|
-
'
|
|
273
|
-
'
|
|
274
|
-
'
|
|
275
|
-
'
|
|
276
|
-
'
|
|
277
|
-
'
|
|
278
|
-
'
|
|
279
|
-
'
|
|
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
|
|
294
|
+
'Z-Score extreme - mean reversion',
|
|
284
295
|
'VPIN/OFI alignment confirmed',
|
|
285
296
|
'Factor model signal active',
|
|
286
|
-
'Mean reversion setup
|
|
287
|
-
'Statistical alpha
|
|
288
|
-
'Regime shift
|
|
289
|
-
'Edge exploitation
|
|
297
|
+
'Mean reversion setup',
|
|
298
|
+
'Statistical alpha found',
|
|
299
|
+
'Regime shift confirmed',
|
|
300
|
+
'Edge exploitation ready',
|
|
290
301
|
'QUANT signal triggered',
|
|
291
|
-
'Model confidence
|
|
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.
|
|
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.
|
|
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
|
-
//
|
|
245
|
+
// REAL-TIME LOGS: Every second, show meaningful market activity
|
|
237
246
|
const now = Date.now();
|
|
238
|
-
if (this.warmupLogged && now - this.
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
const
|
|
242
|
-
const
|
|
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: ${
|
|
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.
|
|
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
|
|