hedgequantx 2.6.135 → 2.6.137
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/one-account.js +25 -10
package/package.json
CHANGED
|
@@ -1431,6 +1431,9 @@ const launchMultiSymbolRithmic = async (service, account, contracts, config) =>
|
|
|
1431
1431
|
// Calculate total qty across all symbols
|
|
1432
1432
|
const totalQty = contracts.reduce((sum, c) => sum + (c.qty || 1), 0);
|
|
1433
1433
|
|
|
1434
|
+
// Baseline P&L captured at session start (to show only THIS session's P&L)
|
|
1435
|
+
let baselineClosedPnl = null; // Will be set on first pnlUpdate
|
|
1436
|
+
|
|
1434
1437
|
// Shared stats (same structure as launchAlgo)
|
|
1435
1438
|
const stats = {
|
|
1436
1439
|
accountName,
|
|
@@ -1441,8 +1444,8 @@ const launchMultiSymbolRithmic = async (service, account, contracts, config) =>
|
|
|
1441
1444
|
propfirm: account.propfirm || 'Unknown',
|
|
1442
1445
|
platform: 'RITHMIC',
|
|
1443
1446
|
pnl: null,
|
|
1444
|
-
openPnl:
|
|
1445
|
-
closedPnl:
|
|
1447
|
+
openPnl: 0, // Start at 0 for session
|
|
1448
|
+
closedPnl: 0, // Start at 0 for session (will show delta from baseline)
|
|
1446
1449
|
balance: null,
|
|
1447
1450
|
buyingPower: null,
|
|
1448
1451
|
margin: null,
|
|
@@ -1838,26 +1841,29 @@ const launchMultiSymbolRithmic = async (service, account, contracts, config) =>
|
|
|
1838
1841
|
|
|
1839
1842
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
1840
1843
|
// TARGET/RISK CHECK - Stop algo when limits reached
|
|
1844
|
+
// Uses SESSION P&L (trades from this HQX session only) + Open P&L
|
|
1845
|
+
// NOT account-wide closedPnl which includes all trades from today
|
|
1841
1846
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
1842
1847
|
const checkTargetRisk = () => {
|
|
1843
1848
|
if (!running) return;
|
|
1844
1849
|
|
|
1845
|
-
|
|
1850
|
+
// Session P&L = closed trades from THIS session + current open P&L
|
|
1851
|
+
const sessionTotalPnl = (stats.sessionPnl || 0) + (stats.openPnl || 0);
|
|
1846
1852
|
|
|
1847
1853
|
// Daily target reached - STOP with profit
|
|
1848
|
-
if (
|
|
1854
|
+
if (sessionTotalPnl >= dailyTarget) {
|
|
1849
1855
|
stopReason = 'target';
|
|
1850
1856
|
running = false;
|
|
1851
|
-
algoLogger.info(ui, 'TARGET REACHED', `+$${
|
|
1852
|
-
ui.addLog('success', `████ DAILY TARGET REACHED: +$${
|
|
1857
|
+
algoLogger.info(ui, 'TARGET REACHED', `+$${sessionTotalPnl.toFixed(2)} >= $${dailyTarget}`);
|
|
1858
|
+
ui.addLog('success', `████ DAILY TARGET REACHED: +$${sessionTotalPnl.toFixed(2)} ████`);
|
|
1853
1859
|
emergencyStopAll(); // Close all positions
|
|
1854
1860
|
}
|
|
1855
1861
|
// Max risk reached - STOP to protect capital
|
|
1856
|
-
else if (
|
|
1862
|
+
else if (sessionTotalPnl <= -maxRisk) {
|
|
1857
1863
|
stopReason = 'risk';
|
|
1858
1864
|
running = false;
|
|
1859
|
-
algoLogger.info(ui, 'MAX RISK HIT', `-$${Math.abs(
|
|
1860
|
-
ui.addLog('error', `████ MAX RISK REACHED: -$${Math.abs(
|
|
1865
|
+
algoLogger.info(ui, 'MAX RISK HIT', `-$${Math.abs(sessionTotalPnl).toFixed(2)} <= -$${maxRisk}`);
|
|
1866
|
+
ui.addLog('error', `████ MAX RISK REACHED: -$${Math.abs(sessionTotalPnl).toFixed(2)} ████`);
|
|
1861
1867
|
emergencyStopAll(); // Close all positions
|
|
1862
1868
|
}
|
|
1863
1869
|
};
|
|
@@ -1871,7 +1877,16 @@ const launchMultiSymbolRithmic = async (service, account, contracts, config) =>
|
|
|
1871
1877
|
if (pnlData.accountId !== rithmicAccountId) return;
|
|
1872
1878
|
|
|
1873
1879
|
if (pnlData.closedPositionPnl !== undefined) {
|
|
1874
|
-
|
|
1880
|
+
const accountClosedPnl = parseFloat(pnlData.closedPositionPnl);
|
|
1881
|
+
|
|
1882
|
+
// Capture baseline on first update (P&L at session start)
|
|
1883
|
+
if (baselineClosedPnl === null) {
|
|
1884
|
+
baselineClosedPnl = accountClosedPnl;
|
|
1885
|
+
algoLogger.info(ui, 'SESSION START', `Baseline P&L: $${baselineClosedPnl.toFixed(2)}`);
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
// stats.closedPnl shows ONLY this session's closed P&L (delta from baseline)
|
|
1889
|
+
stats.closedPnl = accountClosedPnl - baselineClosedPnl;
|
|
1875
1890
|
}
|
|
1876
1891
|
if (pnlData.accountBalance !== undefined) {
|
|
1877
1892
|
stats.balance = parseFloat(pnlData.accountBalance);
|