hedgequantx 2.9.202 → 2.9.204
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 +52 -19
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
const chalk = require('chalk');
|
|
10
10
|
const HQX2B = require('./smart-logs-hqx2b');
|
|
11
11
|
const QUANT = require('./smart-logs-quant');
|
|
12
|
+
const smartLogs = require('./smart-logs');
|
|
12
13
|
|
|
13
14
|
const CONFIG = {
|
|
14
15
|
SESSION_LOG_INTERVAL: 10,
|
|
@@ -168,7 +169,7 @@ class SmartLogsEngine {
|
|
|
168
169
|
const events = this._detectEvents(state, this.lastState);
|
|
169
170
|
this.lastState = { ...state };
|
|
170
171
|
|
|
171
|
-
// For QUANT strategy: use rich
|
|
172
|
+
// For QUANT strategy: use rich QUANT-specific smart-logs
|
|
172
173
|
if (this.strategyId === 'ultra-scalping' && state.bars >= 5) {
|
|
173
174
|
const timeSinceLastLog = now - this.lastLogTime;
|
|
174
175
|
|
|
@@ -176,28 +177,60 @@ class SmartLogsEngine {
|
|
|
176
177
|
if (timeSinceLastLog >= CONFIG.LOG_INTERVAL_SECONDS * 1000) {
|
|
177
178
|
this.lastLogTime = now;
|
|
178
179
|
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
// Determine market context from QUANT metrics
|
|
181
|
+
// zScore: mean reversion indicator (-3 to +3)
|
|
182
|
+
// vpin: toxicity 0-1 (higher = more informed trading)
|
|
183
|
+
// ofi: order flow imbalance -1 to +1 (positive = buying pressure)
|
|
184
|
+
const absZ = Math.abs(zScore);
|
|
185
|
+
const ofiAbs = Math.abs(ofi);
|
|
183
186
|
|
|
184
|
-
|
|
185
|
-
let
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
187
|
+
let contextMessage;
|
|
188
|
+
let logType = 'analysis';
|
|
189
|
+
|
|
190
|
+
if (absZ >= 2.0) {
|
|
191
|
+
// Strong mean reversion signal zone
|
|
192
|
+
const dir = zScore < 0 ? 'LONG' : 'SHORT';
|
|
193
|
+
const ofiConfirms = (zScore < 0 && ofi > 0.1) || (zScore > 0 && ofi < -0.1);
|
|
194
|
+
contextMessage = ofiConfirms
|
|
195
|
+
? `Z-Score extreme (${zScore.toFixed(1)}σ) + OFI confirms ${dir} setup forming`
|
|
196
|
+
: `Z-Score extreme (${zScore.toFixed(1)}σ) - awaiting OFI confirmation`;
|
|
197
|
+
logType = 'signal';
|
|
198
|
+
} else if (absZ >= 1.5) {
|
|
199
|
+
// Approaching signal threshold
|
|
200
|
+
contextMessage = zScore > 0
|
|
201
|
+
? `Price extended above mean (+${zScore.toFixed(1)}σ) - watching for SHORT setup`
|
|
202
|
+
: `Price below mean (${zScore.toFixed(1)}σ) - watching for LONG setup`;
|
|
203
|
+
logType = 'signal';
|
|
204
|
+
} else if (absZ >= 1.0) {
|
|
205
|
+
// Building deviation
|
|
206
|
+
const vpinStatus = vpin > 0.6 ? 'high toxicity' : vpin > 0.4 ? 'moderate flow' : 'clean flow';
|
|
207
|
+
contextMessage = `Z-Score building (${zScore.toFixed(1)}σ) | VPIN: ${vpinStatus} | OFI: ${ofi > 0 ? '+' : ''}${(ofi * 100).toFixed(0)}%`;
|
|
208
|
+
} else if (ofiAbs >= 0.3) {
|
|
209
|
+
// Strong orderflow imbalance
|
|
210
|
+
contextMessage = ofi > 0
|
|
211
|
+
? `Strong buying pressure (OFI: +${(ofi * 100).toFixed(0)}%) - bulls in control`
|
|
212
|
+
: `Strong selling pressure (OFI: ${(ofi * 100).toFixed(0)}%) - bears in control`;
|
|
213
|
+
} else if (vpin > 0.6) {
|
|
214
|
+
// High toxicity warning
|
|
215
|
+
contextMessage = `VPIN elevated (${(vpin * 100).toFixed(0)}%) - informed trading detected, caution`;
|
|
195
216
|
} else {
|
|
196
|
-
//
|
|
197
|
-
|
|
217
|
+
// Normal market - use trend from OFI
|
|
218
|
+
const trend = ofi > 0.1 ? 'bullish' : ofi < -0.1 ? 'bearish' : 'neutral';
|
|
219
|
+
contextMessage = smartLogs.getLiveAnalysisLog({
|
|
220
|
+
trend,
|
|
221
|
+
bars: state.bars || 0,
|
|
222
|
+
swings: 0,
|
|
223
|
+
zones: absZ >= 1.0 ? 1 : 0,
|
|
224
|
+
nearZone: absZ >= 1.5,
|
|
225
|
+
setupForming: absZ >= 2.0,
|
|
226
|
+
});
|
|
198
227
|
}
|
|
199
228
|
|
|
200
|
-
return {
|
|
229
|
+
return {
|
|
230
|
+
type: logType,
|
|
231
|
+
message: `[${sym}] ${contextMessage}`,
|
|
232
|
+
logToSession: this.counter % CONFIG.SESSION_LOG_INTERVAL === 0
|
|
233
|
+
};
|
|
201
234
|
}
|
|
202
235
|
return null;
|
|
203
236
|
}
|