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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedgequantx",
3
- "version": "2.9.202",
3
+ "version": "2.9.204",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -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 messages with Z-score, VPIN, OFI
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
- // Use rich QUANT messages with actual metrics
180
- const zStr = zScore.toFixed(2);
181
- const vpinStr = (vpin * 100).toFixed(0);
182
- const ofiStr = (ofi * 100).toFixed(0);
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
- // Choose message based on z-score level
185
- let message;
186
- if (Math.abs(zScore) >= 1.5) {
187
- // Near signal threshold - use zones message
188
- message = T.zones({
189
- sym, price, zScore: zStr, vpin: vpinStr, ofi: ofiStr,
190
- ticks: state.tickCount || state.bars
191
- });
192
- } else if (Math.abs(zScore) >= 0.8) {
193
- // Building - use building message
194
- message = T.building({ sym, ticks: state.tickCount || state.bars });
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
- // Neutral - use simpler analysis
197
- message = T.priceMove({ sym, price, dir: zScore > 0 ? 'up' : 'down', ticks: Math.abs(zScore).toFixed(1) });
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 { type: 'analysis', message, logToSession: this.counter % CONFIG.SESSION_LOG_INTERVAL === 0 };
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
  }