hedgequantx 2.9.207 → 2.9.208
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-engine.js +26 -27
package/package.json
CHANGED
|
@@ -175,7 +175,7 @@ class SmartLogsEngine {
|
|
|
175
175
|
this.lastState = { ...state };
|
|
176
176
|
|
|
177
177
|
// For QUANT strategy: EVENT-DRIVEN logs based on regime changes
|
|
178
|
-
//
|
|
178
|
+
// Uses the same smart-logs system as HQX-2B for consistency
|
|
179
179
|
if (this.strategyId === 'ultra-scalping') {
|
|
180
180
|
const ticks = state.tickCount || state.bars || 0;
|
|
181
181
|
const absZ = Math.abs(zScore);
|
|
@@ -185,59 +185,58 @@ class SmartLogsEngine {
|
|
|
185
185
|
const zRegime = absZ >= 2.0 ? 'extreme' : absZ >= 1.5 ? 'high' : absZ >= 1.0 ? 'building' : 'neutral';
|
|
186
186
|
const bias = ofi > 0.15 ? 'bullish' : ofi < -0.15 ? 'bearish' : 'neutral';
|
|
187
187
|
|
|
188
|
-
// Build data object for messages
|
|
189
|
-
const zScoreAbs = absZ.toFixed(1);
|
|
190
|
-
const vpinPct = (vpin * 100).toFixed(0);
|
|
191
|
-
const ofiPct = (ofi > 0 ? '+' : '') + (ofi * 100).toFixed(0) + '%';
|
|
192
|
-
const d = {
|
|
193
|
-
sym, price,
|
|
194
|
-
zScore: zScore.toFixed(1),
|
|
195
|
-
zScoreAbs,
|
|
196
|
-
rawZScore: zScore,
|
|
197
|
-
vpin: vpinPct,
|
|
198
|
-
ofi: ofiPct,
|
|
199
|
-
ticks
|
|
200
|
-
};
|
|
201
|
-
|
|
202
188
|
let event = null;
|
|
203
189
|
let logType = 'analysis';
|
|
204
190
|
let message = null;
|
|
205
191
|
|
|
206
|
-
// EVENT 1: Warmup
|
|
192
|
+
// EVENT 1: Warmup complete (only log once at 250 ticks)
|
|
207
193
|
if (ticks >= 250 && !this.warmupLogged) {
|
|
208
194
|
this.warmupLogged = true;
|
|
209
195
|
event = 'warmup_complete';
|
|
210
|
-
message =
|
|
196
|
+
message = `[${sym}] QUANT models ready | ${ticks} ticks processed`;
|
|
211
197
|
logType = 'system';
|
|
212
198
|
}
|
|
213
|
-
// EVENT 2: Z-Score regime change (
|
|
199
|
+
// EVENT 2: Z-Score regime change (significant threshold crossing)
|
|
214
200
|
else if (this.lastZRegime !== null && zRegime !== this.lastZRegime) {
|
|
215
201
|
event = 'z_regime_change';
|
|
202
|
+
// Use smartLogs.getLiveAnalysisLog for varied contextual messages
|
|
203
|
+
const liveState = {
|
|
204
|
+
trend: bias,
|
|
205
|
+
bars: ticks,
|
|
206
|
+
swings: absZ >= 1.0 ? 1 : 0,
|
|
207
|
+
zones: absZ >= 1.5 ? 1 : 0,
|
|
208
|
+
nearZone: absZ >= 1.5,
|
|
209
|
+
setupForming: absZ >= 2.0,
|
|
210
|
+
};
|
|
211
|
+
const baseMsg = smartLogs.getLiveAnalysisLog(liveState);
|
|
212
|
+
|
|
216
213
|
if (zRegime === 'extreme') {
|
|
217
214
|
logType = 'signal';
|
|
218
|
-
|
|
215
|
+
const dir = zScore < 0 ? 'LONG' : 'SHORT';
|
|
216
|
+
message = `[${sym}] ${price} | Z: ${zScore.toFixed(1)}σ | ${dir} edge | ${baseMsg}`;
|
|
219
217
|
} else if (zRegime === 'high') {
|
|
220
218
|
logType = 'signal';
|
|
221
|
-
message =
|
|
219
|
+
message = `[${sym}] ${price} | Z: ${zScore.toFixed(1)}σ | ${baseMsg}`;
|
|
222
220
|
} else if (zRegime === 'building') {
|
|
223
|
-
message =
|
|
221
|
+
message = `[${sym}] ${price} | Z building (${zScore.toFixed(1)}σ) | ${baseMsg}`;
|
|
224
222
|
} else {
|
|
225
|
-
message =
|
|
223
|
+
message = `[${sym}] ${price} | Z normalized | ${baseMsg}`;
|
|
226
224
|
}
|
|
227
225
|
}
|
|
228
|
-
// EVENT 3: Bias flip (bullish ↔ bearish)
|
|
226
|
+
// EVENT 3: Bias flip (bullish ↔ bearish) - significant directional change
|
|
229
227
|
else if (this.lastBias !== null && bias !== this.lastBias && bias !== 'neutral' && this.lastBias !== 'neutral') {
|
|
230
228
|
event = 'bias_flip';
|
|
231
|
-
|
|
229
|
+
const arrow = bias === 'bullish' ? chalk.green('▲') : chalk.red('▼');
|
|
230
|
+
message = `[${sym}] ${arrow} Flow flip: ${this.lastBias} → ${bias} | OFI: ${(ofi * 100).toFixed(0)}%`;
|
|
232
231
|
}
|
|
233
|
-
// EVENT 4: VPIN toxicity
|
|
232
|
+
// EVENT 4: VPIN toxicity threshold crossing
|
|
234
233
|
else if (this.lastVpinToxic !== null && vpinToxic !== this.lastVpinToxic) {
|
|
235
234
|
event = 'vpin_change';
|
|
236
235
|
if (vpinToxic) {
|
|
237
|
-
message = `[${sym}] ${price} | VPIN
|
|
236
|
+
message = `[${sym}] ${price} | VPIN elevated (${(vpin * 100).toFixed(0)}%) - informed flow`;
|
|
238
237
|
logType = 'risk';
|
|
239
238
|
} else {
|
|
240
|
-
message = `[${sym}] ${price} | VPIN normalized (${
|
|
239
|
+
message = `[${sym}] ${price} | VPIN normalized (${(vpin * 100).toFixed(0)}%) - clean flow`;
|
|
241
240
|
}
|
|
242
241
|
}
|
|
243
242
|
|