hedgequantx 2.6.135 → 2.6.136
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
|
@@ -1838,26 +1838,29 @@ const launchMultiSymbolRithmic = async (service, account, contracts, config) =>
|
|
|
1838
1838
|
|
|
1839
1839
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
1840
1840
|
// TARGET/RISK CHECK - Stop algo when limits reached
|
|
1841
|
+
// Uses SESSION P&L (trades from this HQX session only) + Open P&L
|
|
1842
|
+
// NOT account-wide closedPnl which includes all trades from today
|
|
1841
1843
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
1842
1844
|
const checkTargetRisk = () => {
|
|
1843
1845
|
if (!running) return;
|
|
1844
1846
|
|
|
1845
|
-
|
|
1847
|
+
// Session P&L = closed trades from THIS session + current open P&L
|
|
1848
|
+
const sessionTotalPnl = (stats.sessionPnl || 0) + (stats.openPnl || 0);
|
|
1846
1849
|
|
|
1847
1850
|
// Daily target reached - STOP with profit
|
|
1848
|
-
if (
|
|
1851
|
+
if (sessionTotalPnl >= dailyTarget) {
|
|
1849
1852
|
stopReason = 'target';
|
|
1850
1853
|
running = false;
|
|
1851
|
-
algoLogger.info(ui, 'TARGET REACHED', `+$${
|
|
1852
|
-
ui.addLog('success', `████ DAILY TARGET REACHED: +$${
|
|
1854
|
+
algoLogger.info(ui, 'TARGET REACHED', `+$${sessionTotalPnl.toFixed(2)} >= $${dailyTarget}`);
|
|
1855
|
+
ui.addLog('success', `████ DAILY TARGET REACHED: +$${sessionTotalPnl.toFixed(2)} ████`);
|
|
1853
1856
|
emergencyStopAll(); // Close all positions
|
|
1854
1857
|
}
|
|
1855
1858
|
// Max risk reached - STOP to protect capital
|
|
1856
|
-
else if (
|
|
1859
|
+
else if (sessionTotalPnl <= -maxRisk) {
|
|
1857
1860
|
stopReason = 'risk';
|
|
1858
1861
|
running = false;
|
|
1859
|
-
algoLogger.info(ui, 'MAX RISK HIT', `-$${Math.abs(
|
|
1860
|
-
ui.addLog('error', `████ MAX RISK REACHED: -$${Math.abs(
|
|
1862
|
+
algoLogger.info(ui, 'MAX RISK HIT', `-$${Math.abs(sessionTotalPnl).toFixed(2)} <= -$${maxRisk}`);
|
|
1863
|
+
ui.addLog('error', `████ MAX RISK REACHED: -$${Math.abs(sessionTotalPnl).toFixed(2)} ████`);
|
|
1861
1864
|
emergencyStopAll(); // Close all positions
|
|
1862
1865
|
}
|
|
1863
1866
|
};
|