hedgequantx 2.9.94 → 2.9.96
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/dist/lib/m/hqx-2b.js +1 -845
- package/dist/lib/m/ultra-scalping.js +1 -705
- package/package.json +1 -1
- package/src/lib/m/hqx-2b.js +6 -2
- package/src/pages/algo/algo-executor.js +9 -23
package/package.json
CHANGED
package/src/lib/m/hqx-2b.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
// Load
|
|
3
|
-
|
|
2
|
+
// Load obfuscated (prod) or private sources (dev)
|
|
3
|
+
try {
|
|
4
|
+
module.exports = require('../../../dist/lib/m/hqx-2b.js');
|
|
5
|
+
} catch (e) {
|
|
6
|
+
module.exports = require('../../../private/strategies/hqx-2b');
|
|
7
|
+
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Algo Executor -
|
|
3
|
-
* Handles market data, signals, orders, and P&L tracking
|
|
4
|
-
* Supports multi-agent AI supervision for signal optimization
|
|
2
|
+
* Algo Executor - Execution engine for algo modes with AI supervision
|
|
5
3
|
*/
|
|
6
|
-
|
|
7
4
|
const readline = require('readline');
|
|
8
5
|
const { AlgoUI, renderSessionSummary } = require('./ui');
|
|
9
6
|
const { loadStrategy } = require('../../lib/m');
|
|
@@ -25,13 +22,11 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
25
22
|
const { contracts, dailyTarget, maxRisk, showName } = config;
|
|
26
23
|
const { supervisionConfig, subtitle } = options;
|
|
27
24
|
|
|
28
|
-
// Load the selected strategy module dynamically
|
|
29
25
|
const strategyId = strategyInfo?.id || 'ultra-scalping';
|
|
30
26
|
const strategyName = strategyInfo?.name || 'HQX Scalping';
|
|
31
27
|
const strategyModule = loadStrategy(strategyId);
|
|
32
28
|
const StrategyClass = strategyModule.M1; // loadStrategy normalizes to M1
|
|
33
29
|
|
|
34
|
-
// Initialize AI Supervision Engine if configured
|
|
35
30
|
const supervisionEnabled = supervisionConfig?.supervisionEnabled && supervisionConfig?.agents?.length > 0;
|
|
36
31
|
const supervisionEngine = supervisionEnabled ? new SupervisionEngine(supervisionConfig) : null;
|
|
37
32
|
|
|
@@ -73,23 +68,18 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
73
68
|
let tickCount = 0;
|
|
74
69
|
let lastBias = 'FLAT';
|
|
75
70
|
|
|
76
|
-
// Context for AI supervision
|
|
77
71
|
const aiContext = { recentTicks: [], recentSignals: [], recentTrades: [], maxTicks: 100 };
|
|
78
72
|
|
|
79
|
-
// Initialize Strategy
|
|
80
73
|
const strategy = new StrategyClass({ tickSize });
|
|
81
74
|
strategy.initialize(contractId, tickSize);
|
|
82
75
|
|
|
83
|
-
// Handle strategy debug logs
|
|
84
76
|
strategy.on('log', (log) => {
|
|
85
77
|
const type = log.type === 'debug' ? 'debug' : log.type === 'info' ? 'analysis' : 'system';
|
|
86
78
|
ui.addLog(type, log.message);
|
|
87
79
|
});
|
|
88
80
|
|
|
89
|
-
// Initialize Market Data Feed (Rithmic TICKER_PLANT)
|
|
90
81
|
const marketFeed = new MarketDataFeed();
|
|
91
82
|
|
|
92
|
-
// Log startup
|
|
93
83
|
ui.addLog('system', `Strategy: ${strategyName}${supervisionEnabled ? ' + AI' : ''}`);
|
|
94
84
|
ui.addLog('system', `Account: ${accountName}`);
|
|
95
85
|
ui.addLog('system', `Symbol: ${symbolName} | Qty: ${contracts}`);
|
|
@@ -100,7 +90,6 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
100
90
|
}
|
|
101
91
|
ui.addLog('system', 'Connecting to market data...');
|
|
102
92
|
|
|
103
|
-
// Handle strategy signals
|
|
104
93
|
strategy.on('signal', async (signal) => {
|
|
105
94
|
const dir = signal.direction?.toUpperCase() || 'UNKNOWN';
|
|
106
95
|
const signalLog = smartLogs.getSignalLog(dir, symbolCode, (signal.confidence || 0) * 100, strategyName);
|
|
@@ -214,7 +203,6 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
214
203
|
pendingOrder = false;
|
|
215
204
|
});
|
|
216
205
|
|
|
217
|
-
// Handle market data ticks
|
|
218
206
|
let lastPrice = null;
|
|
219
207
|
let lastBid = null;
|
|
220
208
|
let lastAsk = null;
|
|
@@ -225,7 +213,6 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
225
213
|
let sellVolume = 0;
|
|
226
214
|
let barCount = 0;
|
|
227
215
|
|
|
228
|
-
// Track tick arrival times for latency estimation
|
|
229
216
|
let lastTickTime = 0;
|
|
230
217
|
let tickLatencies = [];
|
|
231
218
|
|
|
@@ -353,6 +340,14 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
353
340
|
ui.addLog('analysis', `AI Supervision active: ${agentNames} (${status.availableAgents} agents monitoring)`);
|
|
354
341
|
}
|
|
355
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
|
+
|
|
356
351
|
// Reset volume counters
|
|
357
352
|
buyVolume = 0;
|
|
358
353
|
sellVolume = 0;
|
|
@@ -397,12 +392,9 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
397
392
|
ui.addLog('connected', 'Market data connected');
|
|
398
393
|
});
|
|
399
394
|
marketFeed.on('subscribed', (symbol) => ui.addLog('system', `Subscribed: ${symbol}`));
|
|
400
|
-
// Suppress debug logs - not needed in production
|
|
401
|
-
// marketFeed.on('debug', (msg) => ui.addLog('debug', msg));
|
|
402
395
|
marketFeed.on('error', (err) => ui.addLog('error', `Market: ${err.message}`));
|
|
403
396
|
marketFeed.on('disconnected', () => { stats.connected = false; ui.addLog('error', 'Market disconnected'); });
|
|
404
397
|
|
|
405
|
-
// Connect to market data (Rithmic TICKER_PLANT)
|
|
406
398
|
try {
|
|
407
399
|
const rithmicCredentials = service.getRithmicCredentials?.();
|
|
408
400
|
if (!rithmicCredentials) {
|
|
@@ -432,7 +424,6 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
432
424
|
ui.addLog('error', `Failed to connect: ${e.message}`);
|
|
433
425
|
}
|
|
434
426
|
|
|
435
|
-
// Poll P&L
|
|
436
427
|
const pollPnL = async () => {
|
|
437
428
|
try {
|
|
438
429
|
const accountResult = await service.getTradingAccounts();
|
|
@@ -472,12 +463,10 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
472
463
|
} catch (e) { /* silent */ }
|
|
473
464
|
};
|
|
474
465
|
|
|
475
|
-
// Start loops
|
|
476
466
|
const refreshInterval = setInterval(() => { if (running) ui.render(stats); }, 250);
|
|
477
467
|
const pnlInterval = setInterval(() => { if (running) pollPnL(); }, 2000);
|
|
478
468
|
pollPnL();
|
|
479
469
|
|
|
480
|
-
// Keyboard handler for exit (X or Ctrl+C)
|
|
481
470
|
const setupKeyHandler = () => {
|
|
482
471
|
if (!process.stdin.isTTY) return;
|
|
483
472
|
readline.emitKeypressEvents(process.stdin);
|
|
@@ -489,10 +478,8 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
489
478
|
};
|
|
490
479
|
const cleanupKeys = setupKeyHandler();
|
|
491
480
|
|
|
492
|
-
// Wait for stop signal
|
|
493
481
|
await new Promise(resolve => { const check = setInterval(() => { if (!running) { clearInterval(check); resolve(); } }, 100); });
|
|
494
482
|
|
|
495
|
-
// Cleanup
|
|
496
483
|
clearInterval(refreshInterval);
|
|
497
484
|
clearInterval(pnlInterval);
|
|
498
485
|
await marketFeed.disconnect();
|
|
@@ -501,7 +488,6 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
501
488
|
if (process.stdin.isTTY) process.stdin.setRawMode(false);
|
|
502
489
|
process.stdin.resume();
|
|
503
490
|
|
|
504
|
-
// Duration and summary
|
|
505
491
|
const durationMs = Date.now() - stats.startTime;
|
|
506
492
|
const h = Math.floor(durationMs / 3600000), m = Math.floor((durationMs % 3600000) / 60000), s = Math.floor((durationMs % 60000) / 1000);
|
|
507
493
|
stats.duration = h > 0 ? `${h}h ${m}m ${s}s` : m > 0 ? `${m}m ${s}s` : `${s}s`;
|