hedgequantx 2.9.62 → 2.9.64

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.62",
3
+ "version": "2.9.64",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -71,6 +71,7 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
71
71
  let currentPosition = 0;
72
72
  let pendingOrder = false;
73
73
  let tickCount = 0;
74
+ let lastBias = 'FLAT';
74
75
 
75
76
  // Context for AI supervision
76
77
  const aiContext = { recentTicks: [], recentSignals: [], recentTrades: [], maxTicks: 100 };
@@ -83,36 +84,36 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
83
84
  const marketFeed = new MarketDataFeed();
84
85
 
85
86
  // Log startup
86
- ui.addLog('info', `Strategy: ${strategyName}${supervisionEnabled ? ' + AI' : ''}`);
87
- ui.addLog('info', `Account: ${accountName}`);
88
- ui.addLog('info', `Symbol: ${symbolName} | Qty: ${contracts}`);
89
- ui.addLog('info', `Target: $${dailyTarget} | Risk: $${maxRisk}`);
87
+ ui.addLog('system', `Strategy: ${strategyName}${supervisionEnabled ? ' + AI' : ''}`);
88
+ ui.addLog('system', `Account: ${accountName}`);
89
+ ui.addLog('system', `Symbol: ${symbolName} | Qty: ${contracts}`);
90
+ ui.addLog('risk', `Target: $${dailyTarget} | Risk: $${maxRisk}`);
90
91
  if (supervisionEnabled) {
91
92
  const agentCount = supervisionEngine.getActiveCount();
92
- ui.addLog('info', `AI Agents: ${agentCount} active`);
93
+ ui.addLog('analysis', `AI Agents: ${agentCount} active`);
93
94
  }
94
- ui.addLog('info', 'Connecting to market data...');
95
+ ui.addLog('system', 'Connecting to market data...');
95
96
 
96
97
  // Handle strategy signals
97
98
  strategy.on('signal', async (signal) => {
98
99
  const dir = signal.direction?.toUpperCase() || 'UNKNOWN';
99
100
  const signalLog = smartLogs.getSignalLog(dir, symbolCode, (signal.confidence || 0) * 100, strategyName);
100
- ui.addLog('info', `${signalLog.message}`);
101
- ui.addLog('info', signalLog.details);
101
+ ui.addLog('signal', `${signalLog.message}`);
102
+ ui.addLog('signal', signalLog.details);
102
103
 
103
104
  if (!running) {
104
105
  const riskLog = smartLogs.getRiskCheckLog(false, 'Algo stopped');
105
- ui.addLog('info', riskLog.message);
106
+ ui.addLog('risk', riskLog.message);
106
107
  return;
107
108
  }
108
109
  if (pendingOrder) {
109
110
  const riskLog = smartLogs.getRiskCheckLog(false, 'Order pending');
110
- ui.addLog('info', riskLog.message);
111
+ ui.addLog('risk', riskLog.message);
111
112
  return;
112
113
  }
113
114
  if (currentPosition !== 0) {
114
115
  const riskLog = smartLogs.getRiskCheckLog(false, `Position open (${currentPosition})`);
115
- ui.addLog('info', riskLog.message);
116
+ ui.addLog('risk', riskLog.message);
116
117
  return;
117
118
  }
118
119
 
@@ -123,11 +124,11 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
123
124
  if (aiContext.recentSignals.length > 10) aiContext.recentSignals.shift();
124
125
 
125
126
  const riskLog = smartLogs.getRiskCheckLog(true, `${direction.toUpperCase()} @ ${entry.toFixed(2)}`);
126
- ui.addLog('info', `${riskLog.message} - ${riskLog.details}`);
127
+ ui.addLog('risk', `${riskLog.message} - ${riskLog.details}`);
127
128
 
128
129
  // Multi-Agent AI Supervision
129
130
  if (supervisionEnabled && supervisionEngine) {
130
- ui.addLog('info', 'AI analyzing signal...');
131
+ ui.addLog('analysis', 'AI analyzing signal...');
131
132
 
132
133
  const supervisionResult = await supervisionEngine.supervise({
133
134
  symbolId: symbolName,
@@ -140,9 +141,9 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
140
141
  });
141
142
 
142
143
  if (!supervisionResult.success) {
143
- ui.addLog('info', `AI: ${supervisionResult.reason || 'Error'}`);
144
+ ui.addLog('error', `AI: ${supervisionResult.reason || 'Error'}`);
144
145
  } else if (supervisionResult.decision === 'reject') {
145
- ui.addLog('info', `AI rejected (${supervisionResult.confidence}%): ${supervisionResult.reason}`);
146
+ ui.addLog('reject', `AI rejected (${supervisionResult.confidence}%): ${supervisionResult.reason}`);
146
147
  return;
147
148
  } else {
148
149
  // Apply optimizations
@@ -154,14 +155,14 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
154
155
  if (opt.size && opt.size !== contracts) orderSize = opt.size;
155
156
  }
156
157
  const action = supervisionResult.decision === 'modify' ? 'optimized' : 'approved';
157
- ui.addLog('info', `AI ${action} (${supervisionResult.confidence}%): ${supervisionResult.reason}`);
158
+ ui.addLog('ready', `AI ${action} (${supervisionResult.confidence}%): ${supervisionResult.reason}`);
158
159
 
159
160
  // Check timing
160
161
  if (opt.aiTiming === 'wait') {
161
- ui.addLog('info', 'AI: Wait for better entry');
162
+ ui.addLog('analysis', 'AI: Wait for better entry');
162
163
  return;
163
164
  } else if (opt.aiTiming === 'cancel') {
164
- ui.addLog('info', 'AI: Signal cancelled');
165
+ ui.addLog('reject', 'AI: Signal cancelled');
165
166
  return;
166
167
  }
167
168
  }
@@ -184,7 +185,7 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
184
185
  stats.trades++;
185
186
  const entryLog = smartLogs.getEntryLog(direction.toUpperCase(), symbolCode, orderSize, entry);
186
187
  ui.addLog('fill_' + (direction === 'long' ? 'buy' : 'sell'), entryLog.message);
187
- ui.addLog('info', entryLog.details);
188
+ ui.addLog('trade', entryLog.details);
188
189
 
189
190
  // Bracket orders
190
191
  if (stopLoss && takeProfit) {
@@ -196,7 +197,7 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
196
197
  accountId: account.accountId, contractId, type: 1,
197
198
  side: direction === 'long' ? 1 : 0, size: orderSize, limitPrice: takeProfit
198
199
  });
199
- ui.addLog('info', `SL: ${stopLoss.toFixed(2)} | TP: ${takeProfit.toFixed(2)}`);
200
+ ui.addLog('trade', `SL: ${stopLoss.toFixed(2)} | TP: ${takeProfit.toFixed(2)}`);
200
201
  }
201
202
  } else {
202
203
  ui.addLog('error', `Order failed: ${orderResult.error}`);
@@ -252,7 +253,7 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
252
253
  ui.addLog('connected', `First tick @ ${price?.toFixed(2) || 'N/A'}`);
253
254
  }
254
255
 
255
- // === SMART LOGS EVERY SECOND ===
256
+ // === SMART LOGS - REDUCED FREQUENCY ===
256
257
  if (currentSecond !== lastLogSecond && tickCount > 1) {
257
258
  lastLogSecond = currentSecond;
258
259
 
@@ -265,33 +266,36 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
265
266
  if (buyPressure > 55) bias = 'LONG';
266
267
  else if (buyPressure < 45) bias = 'SHORT';
267
268
 
268
- // Get smart log for market bias
269
- const biasLog = smartLogs.getMarketBiasLog(bias, delta, buyPressure);
270
- ui.addLog('info', `${biasLog.message} ${biasLog.details || ''}`);
269
+ // Log bias only when it changes or every 10 seconds
270
+ if (bias !== lastBias || currentSecond % 10 === 0) {
271
+ const biasLog = smartLogs.getMarketBiasLog(bias, delta, buyPressure);
272
+ const biasType = bias === 'LONG' ? 'bullish' : bias === 'SHORT' ? 'bearish' : 'analysis';
273
+ ui.addLog(biasType, `${biasLog.message} ${biasLog.details || ''}`);
274
+ lastBias = bias;
275
+ }
271
276
 
272
- // Get model values if available
273
- const modelValues = strategy.getModelValues?.(contractId);
274
- if (modelValues) {
275
- barCount = modelValues.bars || barCount;
276
- if (barCount >= 50) {
277
- const modelLog = smartLogs.getModelAnalysisLog(modelValues);
278
- ui.addLog('info', `${modelLog.message} ${modelLog.details || ''}`);
279
- } else {
280
- const barLog = smartLogs.getBuildingBarsLog(barCount);
281
- ui.addLog('info', `${barLog.message} (${barLog.details})`);
277
+ // Model analysis every 5 seconds
278
+ if (currentSecond % 5 === 0) {
279
+ const modelValues = strategy.getModelValues?.(contractId);
280
+ if (modelValues) {
281
+ barCount = modelValues.bars || barCount;
282
+ if (barCount >= 50) {
283
+ const modelLog = smartLogs.getModelAnalysisLog(modelValues);
284
+ ui.addLog('analysis', `${modelLog.message} ${modelLog.details || ''}`);
285
+ }
282
286
  }
283
287
  }
284
288
 
285
- // Scanning log every 3 seconds
286
- if (currentSecond % 3 === 0 && currentPosition === 0) {
289
+ // Scanning log every 7 seconds (when no position)
290
+ if (currentSecond % 7 === 0 && currentPosition === 0) {
287
291
  const scanLog = smartLogs.getScanningLog(true);
288
- ui.addLog('info', scanLog.message);
292
+ ui.addLog('system', scanLog.message);
289
293
  }
290
294
 
291
- // Tick flow log every 5 seconds
292
- if (currentSecond % 5 === 0) {
295
+ // Tick flow log every 15 seconds
296
+ if (currentSecond % 15 === 0) {
293
297
  const tickLog = smartLogs.getTickFlowLog(tickCount, ticksPerSecond);
294
- ui.addLog('info', `${tickLog.message} ${tickLog.details}`);
298
+ ui.addLog('debug', `${tickLog.message} ${tickLog.details}`);
295
299
  }
296
300
 
297
301
  // Reset volume counters
@@ -35,7 +35,10 @@ const LOG_COLORS = {
35
35
  analysis: chalk.blue,
36
36
  risk: chalk.yellow,
37
37
  system: chalk.blue,
38
- debug: chalk.gray
38
+ debug: chalk.gray,
39
+ // Market bias
40
+ bullish: chalk.cyan.bold,
41
+ bearish: chalk.magenta.bold
39
42
  };
40
43
 
41
44
  // Log type icons - compact HF style
@@ -54,7 +57,9 @@ const LOG_ICONS = {
54
57
  analysis: 'ANLZ ',
55
58
  risk: 'RISK ',
56
59
  system: 'SYS ',
57
- debug: 'DBG '
60
+ debug: 'DBG ',
61
+ bullish: 'BULL ',
62
+ bearish: 'BEAR '
58
63
  };
59
64
 
60
65
  /**