hedgequantx 1.2.62 → 1.2.65
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.js +60 -19
package/package.json
CHANGED
package/src/pages/algo.js
CHANGED
|
@@ -318,6 +318,10 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
318
318
|
winRate: '0.0'
|
|
319
319
|
};
|
|
320
320
|
|
|
321
|
+
// Logs buffer (newest first)
|
|
322
|
+
const logs = [];
|
|
323
|
+
const MAX_LOGS = 20;
|
|
324
|
+
|
|
321
325
|
// Log colors
|
|
322
326
|
const typeColors = {
|
|
323
327
|
info: chalk.cyan,
|
|
@@ -338,12 +342,17 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
338
342
|
}
|
|
339
343
|
};
|
|
340
344
|
|
|
341
|
-
//
|
|
342
|
-
const
|
|
345
|
+
// Add log (oldest first, newest at bottom)
|
|
346
|
+
const addLog = (type, message) => {
|
|
343
347
|
const timestamp = new Date().toLocaleTimeString();
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
348
|
+
logs.push({ timestamp, type, message }); // Add at end
|
|
349
|
+
if (logs.length > MAX_LOGS) logs.shift(); // Remove oldest from top
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
// Print log and refresh display
|
|
353
|
+
const printLog = (type, message) => {
|
|
354
|
+
addLog(type, message);
|
|
355
|
+
displayUI();
|
|
347
356
|
};
|
|
348
357
|
|
|
349
358
|
// Check market hours
|
|
@@ -367,23 +376,55 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
367
376
|
return { isOpen: true, message: 'Market OPEN' };
|
|
368
377
|
};
|
|
369
378
|
|
|
370
|
-
// Display
|
|
371
|
-
const
|
|
379
|
+
// Display full UI with logs (newest first)
|
|
380
|
+
const displayUI = () => {
|
|
372
381
|
console.clear();
|
|
373
382
|
const marketStatus = checkMarketStatus();
|
|
383
|
+
|
|
384
|
+
// Logo
|
|
385
|
+
const logo = [
|
|
386
|
+
'██╗ ██╗ ██████╗ ██╗ ██╗',
|
|
387
|
+
'██║ ██║██╔═══██╗╚██╗██╔╝',
|
|
388
|
+
'███████║██║ ██║ ╚███╔╝ ',
|
|
389
|
+
'██╔══██║██║▄▄ ██║ ██╔██╗ ',
|
|
390
|
+
'██║ ██║╚██████╔╝██╔╝ ██╗',
|
|
391
|
+
'╚═╝ ╚═╝ ╚══▀▀═╝ ╚═╝ ╚═╝'
|
|
392
|
+
];
|
|
393
|
+
|
|
374
394
|
console.log();
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
console.log(chalk.
|
|
379
|
-
console.log(chalk.white(` Symbol: ${chalk.cyan(symbolName)}`));
|
|
380
|
-
console.log(chalk.white(` Contracts: ${chalk.cyan(numContracts)}`));
|
|
381
|
-
console.log(chalk.white(` Target: ${chalk.green('$' + dailyTarget.toFixed(2))} | Risk: ${chalk.red('$' + maxRisk.toFixed(2))}`));
|
|
382
|
-
console.log(chalk.white(` Market: ${marketStatus.isOpen ? chalk.green(marketStatus.message) : chalk.red(marketStatus.message)}`));
|
|
383
|
-
console.log(chalk.gray(getSeparator()));
|
|
384
|
-
console.log(chalk.yellow(' Press X to stop algo...'));
|
|
385
|
-
console.log(chalk.gray(getSeparator()));
|
|
395
|
+
logo.forEach(line => {
|
|
396
|
+
console.log(chalk.cyan(' ' + line));
|
|
397
|
+
});
|
|
398
|
+
console.log(chalk.gray(' Ultra-Scalping Algorithm'));
|
|
386
399
|
console.log();
|
|
400
|
+
|
|
401
|
+
// Info Box
|
|
402
|
+
console.log(chalk.cyan(' ╔════════════════════════════════════════════════════════════════════╗'));
|
|
403
|
+
console.log(chalk.cyan(' ║') + chalk.white(` Account: ${chalk.cyan(accountName.padEnd(25))} Symbol: ${chalk.yellow(symbolName.padEnd(10))} Qty: ${chalk.cyan(numContracts.toString().padEnd(3))}`) + chalk.cyan('║'));
|
|
404
|
+
console.log(chalk.cyan(' ║') + chalk.white(` Target: ${chalk.green(('$' + dailyTarget.toFixed(2)).padEnd(12))} Risk: ${chalk.red(('$' + maxRisk.toFixed(2)).padEnd(12))} Server: ${hqxConnected ? chalk.green('ON ') : chalk.red('OFF')} `) + chalk.cyan('║'));
|
|
405
|
+
|
|
406
|
+
// Stats line
|
|
407
|
+
const pnlColor = stats.pnl >= 0 ? chalk.green : chalk.red;
|
|
408
|
+
const pnlStr = (stats.pnl >= 0 ? '+$' : '-$') + Math.abs(stats.pnl).toFixed(2);
|
|
409
|
+
console.log(chalk.cyan(' ║') + chalk.white(` P&L: ${pnlColor(pnlStr.padEnd(12))} Trades: ${chalk.cyan(stats.trades.toString().padEnd(4))} W: ${chalk.green(stats.wins.toString().padEnd(3))} L: ${chalk.red(stats.losses.toString().padEnd(3))} `) + chalk.cyan('║'));
|
|
410
|
+
console.log(chalk.cyan(' ╠════════════════════════════════════════════════════════════════════╣'));
|
|
411
|
+
console.log(chalk.cyan(' ║') + chalk.white(' Activity Log ') + chalk.yellow('Press X to stop') + chalk.cyan(' ║'));
|
|
412
|
+
console.log(chalk.cyan(' ╠════════════════════════════════════════════════════════════════════╣'));
|
|
413
|
+
|
|
414
|
+
// Logs (newest first - already in correct order)
|
|
415
|
+
if (logs.length === 0) {
|
|
416
|
+
console.log(chalk.cyan(' ║') + chalk.gray(' Waiting for activity...'.padEnd(68)) + chalk.cyan('║'));
|
|
417
|
+
} else {
|
|
418
|
+
logs.forEach(log => {
|
|
419
|
+
const color = typeColors[log.type] || chalk.white;
|
|
420
|
+
const icon = getIcon(log.type);
|
|
421
|
+
const logLine = `[${log.timestamp}] ${icon} ${log.message}`;
|
|
422
|
+
const truncated = logLine.length > 66 ? logLine.substring(0, 63) + '...' : logLine;
|
|
423
|
+
console.log(chalk.cyan(' ║') + ' ' + color(truncated.padEnd(67)) + chalk.cyan('║'));
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
console.log(chalk.cyan(' ╚════════════════════════════════════════════════════════════════════╝'));
|
|
387
428
|
};
|
|
388
429
|
|
|
389
430
|
// Connect to HQX Server
|
|
@@ -488,7 +529,7 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
488
529
|
});
|
|
489
530
|
|
|
490
531
|
// Display header once
|
|
491
|
-
|
|
532
|
+
displayUI();
|
|
492
533
|
|
|
493
534
|
// Start algo
|
|
494
535
|
if (hqxConnected) {
|