hedgequantx 1.2.80 → 1.2.82
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 -73
package/package.json
CHANGED
package/src/pages/algo.js
CHANGED
|
@@ -436,97 +436,64 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
436
436
|
// Centered subtitle
|
|
437
437
|
const title2 = 'HQX Ultra-Scalping Algorithm';
|
|
438
438
|
console.log(chalk.cyan(V) + chalk.yellow(center(title2, W)) + chalk.cyan(V));
|
|
439
|
-
console.log(chalk.cyan(MID));
|
|
440
439
|
|
|
441
|
-
// Grid layout for metrics -
|
|
442
|
-
// Row 1: Account | Symbol
|
|
443
|
-
// Row 2: Target | Risk
|
|
440
|
+
// Grid layout for metrics - 2 columns per row, 3 rows
|
|
441
|
+
// Row 1: Account | Symbol
|
|
442
|
+
// Row 2: Target | Risk
|
|
443
|
+
// Row 3: P&L | Trades | Server | WS
|
|
444
444
|
const VS = '\u2502'; // Vertical separator (thin)
|
|
445
445
|
|
|
446
|
-
//
|
|
447
|
-
const
|
|
448
|
-
const accVal = accountName.length > 26 ? accountName.substring(0, 26) : accountName;
|
|
449
|
-
const symLabel = 'Symbol';
|
|
450
|
-
const symVal = symbolName.length > 10 ? symbolName.substring(0, 10) : symbolName;
|
|
451
|
-
const qtyLabel = 'Qty';
|
|
452
|
-
const qtyVal = numContracts.toString();
|
|
453
|
-
const srvLabel = 'Server';
|
|
454
|
-
const srvVal = serverStatus;
|
|
455
|
-
const latLabel = 'WS';
|
|
456
|
-
const latVal = latencyStr;
|
|
457
|
-
|
|
458
|
-
// Row 1 cells: widths = 36 + 17 + 9 + 13 + 13 = 88 + 4 separators + 4 spaces = 96
|
|
459
|
-
const c1w = 36, c2w = 17, c3w = 9, c4w = 13, c5w = 17;
|
|
446
|
+
// 2 columns: 48 + 47 + 1 separator = 96
|
|
447
|
+
const colL = 48, colR = 47;
|
|
460
448
|
|
|
461
449
|
// Safe padding function
|
|
462
450
|
const safePad = (len) => ' '.repeat(Math.max(0, len));
|
|
463
451
|
|
|
464
|
-
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
const cell4 = ` ${srvLabel}: ${serverColor(srvVal)}`;
|
|
471
|
-
const cell4plain = ` ${srvLabel}: ${srvVal}`;
|
|
472
|
-
const cell5 = ` ${latLabel}: ${latencyColor(latVal)}`;
|
|
473
|
-
const cell5plain = ` ${latLabel}: ${latVal}`;
|
|
474
|
-
|
|
475
|
-
const row1 = cell1 + safePad(c1w - cell1plain.length) + chalk.cyan(VS) +
|
|
476
|
-
cell2 + safePad(c2w - cell2plain.length) + chalk.cyan(VS) +
|
|
477
|
-
cell3 + safePad(c3w - cell3plain.length) + chalk.cyan(VS) +
|
|
478
|
-
cell4 + safePad(c4w - cell4plain.length) + chalk.cyan(VS) +
|
|
479
|
-
cell5 + safePad(c5w - cell5plain.length);
|
|
480
|
-
|
|
481
|
-
// Top separator for grid (after HQX Ultra-Scalping)
|
|
482
|
-
const GRID_TOP = '\u2560' + '\u2550'.repeat(c1w) + '\u2564' + '\u2550'.repeat(c2w) + '\u2564' + '\u2550'.repeat(c3w) + '\u2564' + '\u2550'.repeat(c4w) + '\u2564' + '\u2550'.repeat(c5w) + '\u2563';
|
|
483
|
-
console.log(chalk.cyan(GRID_TOP));
|
|
484
|
-
|
|
485
|
-
console.log(chalk.cyan(V) + row1 + chalk.cyan(V));
|
|
452
|
+
// Build cell helper
|
|
453
|
+
const buildCell = (label, value, valueColor, width) => {
|
|
454
|
+
const text = ` ${label}: ${valueColor(value)}`;
|
|
455
|
+
const plain = ` ${label}: ${value}`;
|
|
456
|
+
return { text, plain, padded: text + safePad(width - plain.length) };
|
|
457
|
+
};
|
|
486
458
|
|
|
487
|
-
//
|
|
488
|
-
const
|
|
459
|
+
// Row 1: Account | Symbol + Qty
|
|
460
|
+
const accVal = accountName.length > 35 ? accountName.substring(0, 35) : accountName;
|
|
461
|
+
const symVal = symbolName.length > 12 ? symbolName.substring(0, 12) : symbolName;
|
|
462
|
+
const r1c1 = buildCell('Account', accVal, chalk.cyan, colL);
|
|
463
|
+
const r1c2text = ` Symbol: ${chalk.yellow(symVal)} Qty: ${chalk.cyan(numContracts)}`;
|
|
464
|
+
const r1c2plain = ` Symbol: ${symVal} Qty: ${numContracts}`;
|
|
465
|
+
const r1c2 = r1c2text + safePad(colR - r1c2plain.length);
|
|
489
466
|
|
|
490
|
-
// Row 2: Target | Risk
|
|
491
|
-
const
|
|
492
|
-
const
|
|
493
|
-
const rskLabel = 'Risk';
|
|
494
|
-
const rskVal = '$' + maxRisk.toFixed(2);
|
|
495
|
-
const pnlLabel = 'P&L';
|
|
496
|
-
const pnlVal = pnlStr;
|
|
497
|
-
const trdLabel = 'Trades';
|
|
498
|
-
const trdVal = stats.trades.toString();
|
|
499
|
-
const wlLabel = 'W/L';
|
|
500
|
-
const wlVal = `${stats.wins}/${stats.losses}`;
|
|
467
|
+
// Row 2: Target | Risk
|
|
468
|
+
const r2c1 = buildCell('Target', '$' + dailyTarget.toFixed(2), chalk.green, colL);
|
|
469
|
+
const r2c2 = buildCell('Risk', '$' + maxRisk.toFixed(2), chalk.red, colR);
|
|
501
470
|
|
|
502
|
-
|
|
503
|
-
const
|
|
504
|
-
const
|
|
505
|
-
const
|
|
506
|
-
const
|
|
507
|
-
const
|
|
508
|
-
const
|
|
509
|
-
const cell9plain = ` ${trdLabel}: ${trdVal}`;
|
|
510
|
-
const cell10 = ` ${wlLabel}: ${chalk.green(stats.wins.toString())}/${chalk.red(stats.losses.toString())}`;
|
|
511
|
-
const cell10plain = ` ${wlLabel}: ${wlVal}`;
|
|
471
|
+
// Row 3: P&L | Trades | Server | WS (4 items in 2 columns)
|
|
472
|
+
const r3c1text = ` P&L: ${pnlColor(pnlStr)} Trades: ${chalk.cyan(stats.trades)} W/L: ${chalk.green(stats.wins)}/${chalk.red(stats.losses)}`;
|
|
473
|
+
const r3c1plain = ` P&L: ${pnlStr} Trades: ${stats.trades} W/L: ${stats.wins}/${stats.losses}`;
|
|
474
|
+
const r3c1 = r3c1text + safePad(colL - r3c1plain.length);
|
|
475
|
+
const r3c2text = ` Server: ${serverColor(serverStatus)} WS: ${latencyColor(latencyStr)}`;
|
|
476
|
+
const r3c2plain = ` Server: ${serverStatus} WS: ${latencyStr}`;
|
|
477
|
+
const r3c2 = r3c2text + safePad(colR - r3c2plain.length);
|
|
512
478
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
cell10 + safePad(c5w - cell10plain.length);
|
|
479
|
+
// Grid separators
|
|
480
|
+
const GRID_TOP = '\u2560' + '\u2550'.repeat(colL) + '\u2564' + '\u2550'.repeat(colR) + '\u2563';
|
|
481
|
+
const GRID_MID = '\u2560' + '\u2550'.repeat(colL) + '\u256A' + '\u2550'.repeat(colR) + '\u2563';
|
|
482
|
+
const GRID_BOT = '\u2560' + '\u2550'.repeat(colL) + '\u2567' + '\u2550'.repeat(colR) + '\u2563';
|
|
518
483
|
|
|
484
|
+
// Print grid
|
|
485
|
+
console.log(chalk.cyan(GRID_TOP));
|
|
486
|
+
console.log(chalk.cyan(V) + r1c1.padded + chalk.cyan(VS) + r1c2 + chalk.cyan(V));
|
|
519
487
|
console.log(chalk.cyan(GRID_MID));
|
|
520
|
-
console.log(chalk.cyan(V) +
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
const GRID_BOT = '\u2560' + '\u2550'.repeat(c1w) + '\u2567' + '\u2550'.repeat(c2w) + '\u2567' + '\u2550'.repeat(c3w) + '\u2567' + '\u2550'.repeat(c4w) + '\u2567' + '\u2550'.repeat(c5w) + '\u2563';
|
|
488
|
+
console.log(chalk.cyan(V) + r2c1.padded + chalk.cyan(VS) + r2c2.padded + chalk.cyan(V));
|
|
489
|
+
console.log(chalk.cyan(GRID_MID));
|
|
490
|
+
console.log(chalk.cyan(V) + r3c1 + chalk.cyan(VS) + r3c2 + chalk.cyan(V));
|
|
524
491
|
console.log(chalk.cyan(GRID_BOT));
|
|
525
492
|
|
|
526
493
|
// Activity log header with spinner and centered date
|
|
527
494
|
spinnerFrame = (spinnerFrame + 1) % spinnerChars.length;
|
|
528
495
|
const spinnerChar = spinnerChars[spinnerFrame];
|
|
529
|
-
const actLeft = ` Activity Log ${chalk.
|
|
496
|
+
const actLeft = ` Activity Log ${chalk.yellow(spinnerChar)}`;
|
|
530
497
|
const actLeftPlain = ` Activity Log ${spinnerChar}`;
|
|
531
498
|
const actRight = 'Press X to stop ';
|
|
532
499
|
const dateCentered = `- ${dateStr} -`;
|