hedgequantx 1.2.62 → 1.2.63
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 +40 -16
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 (newest first)
|
|
346
|
+
const addLog = (type, message) => {
|
|
343
347
|
const timestamp = new Date().toLocaleTimeString();
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
348
|
+
logs.unshift({ timestamp, type, message }); // Add at beginning
|
|
349
|
+
if (logs.length > MAX_LOGS) logs.pop(); // Remove oldest
|
|
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,38 @@ 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
|
+
// Header
|
|
374
385
|
console.log();
|
|
375
386
|
console.log(chalk.gray(getSeparator()));
|
|
376
|
-
console.log(chalk.cyan.bold(' HQX Ultra-Scalping Algo'));
|
|
387
|
+
console.log(chalk.cyan.bold(' HQX Ultra-Scalping Algo') + chalk.gray(' | ') + chalk.yellow('Press X to stop'));
|
|
377
388
|
console.log(chalk.gray(getSeparator()));
|
|
378
|
-
console.log(chalk.white(` Account:
|
|
379
|
-
console.log(chalk.white(`
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
389
|
+
console.log(chalk.white(` Account: ${chalk.cyan(accountName)} | Symbol: ${chalk.cyan(symbolName)} | Qty: ${chalk.cyan(numContracts)}`));
|
|
390
|
+
console.log(chalk.white(` Target: ${chalk.green('$' + dailyTarget.toFixed(2))} | Risk: ${chalk.red('$' + maxRisk.toFixed(2))} | Server: ${hqxConnected ? chalk.green('ON') : chalk.red('OFF')}`));
|
|
391
|
+
|
|
392
|
+
// Stats line
|
|
393
|
+
const pnlColor = stats.pnl >= 0 ? chalk.green : chalk.red;
|
|
394
|
+
const pnlStr = stats.pnl >= 0 ? '+$' + stats.pnl.toFixed(2) : '-$' + Math.abs(stats.pnl).toFixed(2);
|
|
395
|
+
console.log(chalk.white(` P&L: ${pnlColor(pnlStr)} | Trades: ${chalk.cyan(stats.trades)} | Wins: ${chalk.green(stats.wins)} | Losses: ${chalk.red(stats.losses)}`));
|
|
396
|
+
|
|
383
397
|
console.log(chalk.gray(getSeparator()));
|
|
384
|
-
|
|
398
|
+
|
|
399
|
+
// Logs (newest first - already in correct order)
|
|
400
|
+
if (logs.length === 0) {
|
|
401
|
+
console.log(chalk.gray(' Waiting for activity...'));
|
|
402
|
+
} else {
|
|
403
|
+
logs.forEach(log => {
|
|
404
|
+
const color = typeColors[log.type] || chalk.white;
|
|
405
|
+
const icon = getIcon(log.type);
|
|
406
|
+
console.log(chalk.gray(` [${log.timestamp}]`) + ' ' + color(`${icon} ${log.message}`));
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
|
|
385
410
|
console.log(chalk.gray(getSeparator()));
|
|
386
|
-
console.log();
|
|
387
411
|
};
|
|
388
412
|
|
|
389
413
|
// Connect to HQX Server
|
|
@@ -488,7 +512,7 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
488
512
|
});
|
|
489
513
|
|
|
490
514
|
// Display header once
|
|
491
|
-
|
|
515
|
+
displayUI();
|
|
492
516
|
|
|
493
517
|
// Start algo
|
|
494
518
|
if (hqxConnected) {
|