hedgequantx 1.2.90 → 1.2.91
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 +35 -10
package/package.json
CHANGED
package/src/pages/algo.js
CHANGED
|
@@ -470,8 +470,10 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
470
470
|
// Stats
|
|
471
471
|
const pnlColor = stats.pnl >= 0 ? chalk.green : chalk.red;
|
|
472
472
|
const pnlStr = (stats.pnl >= 0 ? '+$' : '-$') + Math.abs(stats.pnl).toFixed(2);
|
|
473
|
-
|
|
474
|
-
const
|
|
473
|
+
// Always show latency in ms format
|
|
474
|
+
const latencyMs = latency > 0 ? latency : 0;
|
|
475
|
+
const latencyStr = `${latencyMs}ms`;
|
|
476
|
+
const latencyColor = latencyMs < 100 ? chalk.green : (latencyMs < 300 ? chalk.yellow : chalk.red);
|
|
475
477
|
const serverStatus = hqxConnected ? 'ON' : 'OFF';
|
|
476
478
|
const serverColor = hqxConnected ? chalk.green : chalk.red;
|
|
477
479
|
|
|
@@ -540,6 +542,25 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
540
542
|
return { text, plain, padded: text + safePad(width - plain.length) };
|
|
541
543
|
};
|
|
542
544
|
|
|
545
|
+
// Row 1: Account | Symbol + Qty
|
|
546
|
+
// Row 2: Target | Risk
|
|
547
|
+
// Row 3: P&L | Server
|
|
548
|
+
// Row 4: Trades + W/L | Latency
|
|
549
|
+
const VS = '\u2502'; // Vertical separator (thin)
|
|
550
|
+
|
|
551
|
+
// 2 columns: 48 + 47 + 1 separator = 96
|
|
552
|
+
const colL = 48, colR = 47;
|
|
553
|
+
|
|
554
|
+
// Safe padding function
|
|
555
|
+
const safePad = (len) => ' '.repeat(Math.max(0, len));
|
|
556
|
+
|
|
557
|
+
// Build cell helper
|
|
558
|
+
const buildCell = (label, value, valueColor, width) => {
|
|
559
|
+
const text = ` ${label}: ${valueColor(value)}`;
|
|
560
|
+
const plain = ` ${label}: ${value}`;
|
|
561
|
+
return { text, plain, padded: text + safePad(width - plain.length) };
|
|
562
|
+
};
|
|
563
|
+
|
|
543
564
|
// Row 1: Account | Symbol + Qty
|
|
544
565
|
const accVal = accountName.length > 35 ? accountName.substring(0, 35) : accountName;
|
|
545
566
|
const symVal = symbolName.length > 12 ? symbolName.substring(0, 12) : symbolName;
|
|
@@ -552,13 +573,15 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
552
573
|
const r2c1 = buildCell('Target', '$' + dailyTarget.toFixed(2), chalk.green, colL);
|
|
553
574
|
const r2c2 = buildCell('Risk', '$' + maxRisk.toFixed(2), chalk.red, colR);
|
|
554
575
|
|
|
555
|
-
// Row 3: P&L |
|
|
556
|
-
const
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
const
|
|
561
|
-
const
|
|
576
|
+
// Row 3: P&L | Server
|
|
577
|
+
const r3c1 = buildCell('P&L', pnlStr, pnlColor, colL);
|
|
578
|
+
const r3c2 = buildCell('Server', serverStatus, serverColor, colR);
|
|
579
|
+
|
|
580
|
+
// Row 4: Trades + W/L | Latency
|
|
581
|
+
const r4c1text = ` Trades: ${chalk.cyan(stats.trades)} W/L: ${chalk.green(stats.wins)}/${chalk.red(stats.losses)}`;
|
|
582
|
+
const r4c1plain = ` Trades: ${stats.trades} W/L: ${stats.wins}/${stats.losses}`;
|
|
583
|
+
const r4c1 = r4c1text + safePad(colL - r4c1plain.length);
|
|
584
|
+
const r4c2 = buildCell('Latency', latencyStr, latencyColor, colR);
|
|
562
585
|
|
|
563
586
|
// Grid separators
|
|
564
587
|
const GRID_TOP = '\u2560' + '\u2550'.repeat(colL) + '\u2564' + '\u2550'.repeat(colR) + '\u2563';
|
|
@@ -571,7 +594,9 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
571
594
|
console.log(chalk.cyan(GRID_MID));
|
|
572
595
|
console.log(chalk.cyan(V) + r2c1.padded + chalk.cyan(VS) + r2c2.padded + chalk.cyan(V));
|
|
573
596
|
console.log(chalk.cyan(GRID_MID));
|
|
574
|
-
console.log(chalk.cyan(V) + r3c1 + chalk.cyan(VS) + r3c2 + chalk.cyan(V));
|
|
597
|
+
console.log(chalk.cyan(V) + r3c1.padded + chalk.cyan(VS) + r3c2.padded + chalk.cyan(V));
|
|
598
|
+
console.log(chalk.cyan(GRID_MID));
|
|
599
|
+
console.log(chalk.cyan(V) + r4c1 + chalk.cyan(VS) + r4c2.padded + chalk.cyan(V));
|
|
575
600
|
console.log(chalk.cyan(GRID_BOT));
|
|
576
601
|
|
|
577
602
|
// Activity log header with spinner and centered date
|