hedgequantx 2.9.123 → 2.9.125
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/pages/algo/algo-executor.js +55 -61
package/package.json
CHANGED
|
@@ -234,7 +234,9 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
234
234
|
let lastAsk = null;
|
|
235
235
|
let ticksPerSecond = 0;
|
|
236
236
|
let lastTickSecond = Math.floor(Date.now() / 1000);
|
|
237
|
-
let
|
|
237
|
+
let lastBiasLogSecond = 0;
|
|
238
|
+
let lastDebugLogSecond = 0;
|
|
239
|
+
let lastStateLogSecond = 0;
|
|
238
240
|
let buyVolume = 0;
|
|
239
241
|
let sellVolume = 0;
|
|
240
242
|
|
|
@@ -277,80 +279,72 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
277
279
|
else if (price < lastPrice) sellVolume += volume;
|
|
278
280
|
}
|
|
279
281
|
|
|
280
|
-
// Log first tick
|
|
282
|
+
// Log first tick and periodic tick count
|
|
281
283
|
if (tickCount === 1) {
|
|
282
284
|
ui.addLog('connected', `First tick @ ${price?.toFixed(2) || 'N/A'}`);
|
|
283
285
|
}
|
|
284
286
|
|
|
287
|
+
// Log tick count every 10 seconds to confirm data flow
|
|
288
|
+
if (currentSecond - lastDebugLogSecond >= 10) {
|
|
289
|
+
lastDebugLogSecond = currentSecond;
|
|
290
|
+
const state = strategy.getAnalysisState?.(contractId, price);
|
|
291
|
+
const bars = state?.barsProcessed || 0;
|
|
292
|
+
ui.addLog('debug', `Ticks: ${tickCount} | Bars: ${bars} | Price: ${price?.toFixed(2)}`);
|
|
293
|
+
}
|
|
294
|
+
|
|
285
295
|
// === SMART LOGS - REDUCED FREQUENCY ===
|
|
286
|
-
|
|
287
|
-
|
|
296
|
+
// Log bias every 5 seconds
|
|
297
|
+
if (currentSecond - lastBiasLogSecond >= 5 && tickCount > 1) {
|
|
298
|
+
lastBiasLogSecond = currentSecond;
|
|
288
299
|
|
|
289
300
|
const totalVol = buyVolume + sellVolume;
|
|
290
301
|
const buyPressure = totalVol > 0 ? (buyVolume / totalVol) * 100 : 50;
|
|
291
302
|
const delta = buyVolume - sellVolume;
|
|
292
303
|
|
|
293
304
|
let bias = buyPressure > 55 ? 'LONG' : buyPressure < 45 ? 'SHORT' : 'FLAT';
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if (
|
|
324
|
-
else if (!state.nearestSupport && !state.nearestResistance) ui.addLog('risk', 'Zones outside range');
|
|
325
|
-
else if (!state.nearestSupport) ui.addLog('analysis', 'Monitoring R for SHORT sweep');
|
|
326
|
-
else if (!state.nearestResistance) ui.addLog('analysis', 'Monitoring S for LONG sweep');
|
|
327
|
-
else ui.addLog('ready', 'Both zones active - awaiting sweep');
|
|
305
|
+
const biasLog = smartLogs.getMarketBiasLog(bias, delta, buyPressure);
|
|
306
|
+
const biasType = bias === 'LONG' ? 'bullish' : bias === 'SHORT' ? 'bearish' : 'analysis';
|
|
307
|
+
ui.addLog(biasType, `${biasLog.message} ${biasLog.details || ''}`);
|
|
308
|
+
lastBias = bias;
|
|
309
|
+
// Reset volume after logging to avoid accumulation
|
|
310
|
+
buyVolume = 0;
|
|
311
|
+
sellVolume = 0;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Strategy state log every 30 seconds
|
|
315
|
+
if (currentSecond - lastStateLogSecond >= 30 && tickCount > 1) {
|
|
316
|
+
lastStateLogSecond = currentSecond;
|
|
317
|
+
const state = strategy.getAnalysisState?.(contractId, price);
|
|
318
|
+
if (state) {
|
|
319
|
+
const bars = state.barsProcessed || 0;
|
|
320
|
+
sessionLogger.state(state.activeZones || 0, state.swingsDetected || 0, bars, lastBias);
|
|
321
|
+
if (!state.ready) {
|
|
322
|
+
ui.addLog('system', `${state.message} (${bars} bars)`);
|
|
323
|
+
} else {
|
|
324
|
+
const resStr = state.nearestResistance ? state.nearestResistance.toFixed(2) : '--';
|
|
325
|
+
const supStr = state.nearestSupport ? state.nearestSupport.toFixed(2) : '--';
|
|
326
|
+
|
|
327
|
+
ui.addLog('analysis', `Zones: ${state.activeZones} | R: ${resStr} | S: ${supStr} | Swings: ${state.swingsDetected}`);
|
|
328
|
+
if (price && state.nearestResistance) {
|
|
329
|
+
const gapR = state.nearestResistance - price, ticksR = Math.abs(Math.round(gapR / tickSize));
|
|
330
|
+
if (ticksR <= 50) ui.addLog('analysis', `PROX R: ${Math.abs(gapR).toFixed(2)} pts (${ticksR} ticks) | Sweep ABOVE then reject`);
|
|
331
|
+
}
|
|
332
|
+
if (price && state.nearestSupport) {
|
|
333
|
+
const gapS = price - state.nearestSupport, ticksS = Math.abs(Math.round(gapS / tickSize));
|
|
334
|
+
if (ticksS <= 50) ui.addLog('analysis', `PROX S: ${Math.abs(gapS).toFixed(2)} pts (${ticksS} ticks) | Sweep BELOW then reject`);
|
|
328
335
|
}
|
|
336
|
+
if (state.activeZones === 0) ui.addLog('risk', 'Building liquidity map...');
|
|
337
|
+
else if (!state.nearestSupport && !state.nearestResistance) ui.addLog('risk', 'Zones outside range');
|
|
338
|
+
else if (!state.nearestSupport) ui.addLog('analysis', 'Monitoring R for SHORT sweep');
|
|
339
|
+
else if (!state.nearestResistance) ui.addLog('analysis', 'Monitoring S for LONG sweep');
|
|
340
|
+
else ui.addLog('ready', 'Both zones active - awaiting sweep');
|
|
329
341
|
}
|
|
330
342
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
// AI Agents status every 60 seconds
|
|
337
|
-
if (currentSecond % 60 === 0 && supervisionEnabled && supervisionEngine) {
|
|
338
|
-
const status = supervisionEngine.getStatus();
|
|
339
|
-
const agentNames = status.agents.map(a => a.name.split(' ')[0]).join(', ');
|
|
340
|
-
ui.addLog('analysis', `AI Supervision active: ${agentNames} (${status.availableAgents} agents monitoring)`);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
// Strategy health status every 2 minutes (confirms strategy is working)
|
|
344
|
-
if (currentSecond % 120 === 0 && strategy.getHealthStatus) {
|
|
345
|
-
const health = strategy.getHealthStatus(contractId);
|
|
346
|
-
const uptime = Math.floor(health.uptime / 60000);
|
|
347
|
-
const status = health.healthy ? 'OK' : 'WARMING';
|
|
348
|
-
ui.addLog('ready', `HEALTH: ${status} | Bars: ${health.barsTotal} | Zones: ${health.zonesTotal} (R:${health.zonesResistance}/S:${health.zonesSupport}) | Swings: ${health.swingsTotal} | Uptime: ${uptime}m`);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// Reset volume counters
|
|
352
|
-
buyVolume = 0;
|
|
353
|
-
sellVolume = 0;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// AI status every 60s
|
|
346
|
+
if (currentSecond % 60 === 0 && supervisionEnabled && supervisionEngine) {
|
|
347
|
+
ui.addLog('analysis', `AI: ${supervisionEngine.getStatus().agents.map(a => a.name.split(' ')[0]).join(', ')}`);
|
|
354
348
|
}
|
|
355
349
|
|
|
356
350
|
lastPrice = price;
|