hedgequantx 2.4.33 → 2.4.34
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/stats.js +18 -5
package/package.json
CHANGED
package/src/pages/stats.js
CHANGED
|
@@ -447,8 +447,14 @@ const showStats = async (service) => {
|
|
|
447
447
|
console.log(chalk.cyan('\u2551') + chalk.white(header) + chalk.cyan('\u2551'));
|
|
448
448
|
console.log(chalk.cyan('\u255F') + chalk.cyan('\u2500'.repeat(innerWidth)) + chalk.cyan('\u2562'));
|
|
449
449
|
|
|
450
|
-
// Show
|
|
451
|
-
|
|
450
|
+
// Show only COMPLETED trades (with P&L), sorted by time (most recent first)
|
|
451
|
+
// Filter out entry fills (P&L = 0 or null) - only show exit fills with real P&L
|
|
452
|
+
const completedTrades = allTrades.filter(t => {
|
|
453
|
+
const pnl = t.profitAndLoss || t.pnl;
|
|
454
|
+
return pnl !== null && pnl !== undefined && pnl !== 0;
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
const sortedTrades = [...completedTrades].sort((a, b) => {
|
|
452
458
|
const timeA = new Date(a.creationTimestamp || a.timestamp || 0).getTime();
|
|
453
459
|
const timeB = new Date(b.creationTimestamp || b.timestamp || 0).getTime();
|
|
454
460
|
return timeB - timeA;
|
|
@@ -461,7 +467,9 @@ const showStats = async (service) => {
|
|
|
461
467
|
const price = (trade.price || 0).toFixed(2);
|
|
462
468
|
const pnl = trade.profitAndLoss || trade.pnl || 0;
|
|
463
469
|
const pnlText = pnl >= 0 ? `+$${pnl.toFixed(0)}` : `-$${Math.abs(pnl).toFixed(0)}`;
|
|
464
|
-
|
|
470
|
+
// For completed trades, show the original direction (opposite of exit side)
|
|
471
|
+
const exitSide = trade.side; // 0=BUY exit means was SHORT, 1=SELL exit means was LONG
|
|
472
|
+
const tradeSide = exitSide === 0 ? 'SHORT' : 'LONG';
|
|
465
473
|
const accountName = (trade.accountName || 'N/A').substring(0, colAccount - 3);
|
|
466
474
|
|
|
467
475
|
// Build row with exact widths
|
|
@@ -469,16 +477,21 @@ const showStats = async (service) => {
|
|
|
469
477
|
const symbolStr = symbol.padEnd(colSymbol);
|
|
470
478
|
const priceStr = price.padEnd(colPrice);
|
|
471
479
|
const pnlStr = pnlText.padEnd(colPnl);
|
|
472
|
-
const sideStr =
|
|
480
|
+
const sideStr = tradeSide.padEnd(colSide);
|
|
473
481
|
const accountStr = accountName.padEnd(colAccount - 2);
|
|
474
482
|
|
|
475
483
|
// Colored versions
|
|
476
484
|
const pnlColored = pnl >= 0 ? chalk.green(pnlStr) : chalk.red(pnlStr);
|
|
477
|
-
const sideColored =
|
|
485
|
+
const sideColored = tradeSide === 'LONG' ? chalk.green(sideStr) : chalk.red(sideStr);
|
|
478
486
|
|
|
479
487
|
const row = ` ${timeStr}| ${symbolStr}| ${priceStr}| ${pnlColored}| ${sideColored}| ${accountStr}`;
|
|
480
488
|
console.log(chalk.cyan('\u2551') + row + chalk.cyan('\u2551'));
|
|
481
489
|
}
|
|
490
|
+
|
|
491
|
+
if (sortedTrades.length === 0) {
|
|
492
|
+
const msg = ' No completed trades yet';
|
|
493
|
+
console.log(chalk.cyan('\u2551') + chalk.gray(msg.padEnd(innerWidth)) + chalk.cyan('\u2551'));
|
|
494
|
+
}
|
|
482
495
|
} else {
|
|
483
496
|
const msg = connectionTypes.rithmic > 0
|
|
484
497
|
? ' No trade history (Rithmic API limitation)'
|