hedgequantx 2.6.85 → 2.6.87
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
CHANGED
package/src/pages/algo/ui.js
CHANGED
|
@@ -15,7 +15,7 @@ const BOX = {
|
|
|
15
15
|
// Spinner characters
|
|
16
16
|
const SPINNER = ['\u280B', '\u2819', '\u2839', '\u2838', '\u283C', '\u2834', '\u2826', '\u2827', '\u2807', '\u280F'];
|
|
17
17
|
|
|
18
|
-
// Log type colors - HF grade BOLD
|
|
18
|
+
// Log type colors - HF grade BOLD (FIXED colors - no variation)
|
|
19
19
|
const LOG_COLORS = {
|
|
20
20
|
fill_buy: chalk.green,
|
|
21
21
|
fill_sell: chalk.red,
|
|
@@ -30,7 +30,7 @@ const LOG_COLORS = {
|
|
|
30
30
|
ready: chalk.green,
|
|
31
31
|
error: chalk.red,
|
|
32
32
|
reject: chalk.red,
|
|
33
|
-
info: chalk.white
|
|
33
|
+
info: chalk.gray, // FIXED: gray (not white) - stable color
|
|
34
34
|
system: chalk.magenta,
|
|
35
35
|
signal: chalk.yellow,
|
|
36
36
|
trade: chalk.green,
|
|
@@ -371,16 +371,24 @@ const handleInstrumentPnLUpdate = (service, data) => {
|
|
|
371
371
|
|
|
372
372
|
// Build position data - ALWAYS emit, even when FLAT (netQty === 0)
|
|
373
373
|
// This ensures Open P&L resets to 0 when position closes (like R Trader)
|
|
374
|
+
//
|
|
375
|
+
// OPEN PNL PRIORITY (real-time unrealized P&L):
|
|
376
|
+
// 1. dayOpenPnl (double) - most reliable from INSTRUMENT_PNL_UPDATE
|
|
377
|
+
// 2. openPositionPnl (string) - fallback
|
|
378
|
+
// 3. Calculate from price if available
|
|
379
|
+
const rawOpenPnl = pos.dayOpenPnl ?? pos.openPositionPnl;
|
|
380
|
+
const rawClosedPnl = pos.dayClosedPnl ?? pos.closedPositionPnl;
|
|
381
|
+
|
|
374
382
|
const positionData = {
|
|
375
383
|
accountId: pos.accountId,
|
|
376
384
|
symbol: pos.symbol,
|
|
377
385
|
exchange: pos.exchange || 'CME',
|
|
378
386
|
quantity: netQty,
|
|
379
387
|
averagePrice: netQty !== 0 ? (pos.avgOpenFillPrice || 0) : 0,
|
|
380
|
-
// Open P&L
|
|
381
|
-
openPnl: parseFloat(
|
|
382
|
-
closedPnl: parseFloat(
|
|
383
|
-
dayPnl: parseFloat(pos.dayPnl || 0),
|
|
388
|
+
// Open P&L - parse as float, handle both double and string formats
|
|
389
|
+
openPnl: typeof rawOpenPnl === 'number' ? rawOpenPnl : parseFloat(rawOpenPnl || 0),
|
|
390
|
+
closedPnl: typeof rawClosedPnl === 'number' ? rawClosedPnl : parseFloat(rawClosedPnl || 0),
|
|
391
|
+
dayPnl: typeof pos.dayPnl === 'number' ? pos.dayPnl : parseFloat(pos.dayPnl || 0),
|
|
384
392
|
isSnapshot: pos.isSnapshot || false,
|
|
385
393
|
};
|
|
386
394
|
|
|
@@ -344,13 +344,34 @@ function decodeInstrumentPnL(buffer) {
|
|
|
344
344
|
[result.closedPositionPnl, offset] = readLengthDelimited(buffer, offset);
|
|
345
345
|
break;
|
|
346
346
|
case INSTRUMENT_PNL_FIELDS.DAY_PNL:
|
|
347
|
-
|
|
347
|
+
// DAY_PNL is a double (wireType 1 = 64-bit fixed)
|
|
348
|
+
if (wireType === 1) {
|
|
349
|
+
result.dayPnl = buffer.readDoubleLE(offset);
|
|
350
|
+
offset += 8;
|
|
351
|
+
} else {
|
|
352
|
+
// Fallback: try string
|
|
353
|
+
[result.dayPnl, offset] = readLengthDelimited(buffer, offset);
|
|
354
|
+
}
|
|
348
355
|
break;
|
|
349
356
|
case INSTRUMENT_PNL_FIELDS.DAY_OPEN_PNL:
|
|
350
|
-
|
|
357
|
+
// DAY_OPEN_PNL is a double (wireType 1 = 64-bit fixed)
|
|
358
|
+
if (wireType === 1) {
|
|
359
|
+
result.dayOpenPnl = buffer.readDoubleLE(offset);
|
|
360
|
+
offset += 8;
|
|
361
|
+
} else {
|
|
362
|
+
// Fallback: try string
|
|
363
|
+
[result.dayOpenPnl, offset] = readLengthDelimited(buffer, offset);
|
|
364
|
+
}
|
|
351
365
|
break;
|
|
352
366
|
case INSTRUMENT_PNL_FIELDS.DAY_CLOSED_PNL:
|
|
353
|
-
|
|
367
|
+
// DAY_CLOSED_PNL is a double (wireType 1 = 64-bit fixed)
|
|
368
|
+
if (wireType === 1) {
|
|
369
|
+
result.dayClosedPnl = buffer.readDoubleLE(offset);
|
|
370
|
+
offset += 8;
|
|
371
|
+
} else {
|
|
372
|
+
// Fallback: try string
|
|
373
|
+
[result.dayClosedPnl, offset] = readLengthDelimited(buffer, offset);
|
|
374
|
+
}
|
|
354
375
|
break;
|
|
355
376
|
case INSTRUMENT_PNL_FIELDS.SSBOE:
|
|
356
377
|
[result.ssboe, offset] = readVarint(buffer, offset);
|