hedgequantx 2.6.137 → 2.6.138
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 +27 -11
package/package.json
CHANGED
|
@@ -1842,29 +1842,45 @@ const launchMultiSymbolRithmic = async (service, account, contracts, config) =>
|
|
|
1842
1842
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
1843
1843
|
// TARGET/RISK CHECK - Stop algo when limits reached
|
|
1844
1844
|
// Uses SESSION P&L (trades from this HQX session only) + Open P&L
|
|
1845
|
-
//
|
|
1845
|
+
// Risk triggers if: closedPnl hits risk OR openPnl hits risk OR total hits risk
|
|
1846
1846
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
1847
1847
|
const checkTargetRisk = () => {
|
|
1848
1848
|
if (!running) return;
|
|
1849
1849
|
|
|
1850
|
-
|
|
1851
|
-
const
|
|
1850
|
+
const closedPnl = stats.closedPnl || 0; // Session closed P&L
|
|
1851
|
+
const openPnl = stats.openPnl || 0; // Current open P&L
|
|
1852
|
+
const totalPnl = closedPnl + openPnl; // Total session P&L
|
|
1852
1853
|
|
|
1853
1854
|
// Daily target reached - STOP with profit
|
|
1854
|
-
if (
|
|
1855
|
+
if (totalPnl >= dailyTarget) {
|
|
1855
1856
|
stopReason = 'target';
|
|
1856
1857
|
running = false;
|
|
1857
|
-
algoLogger.info(ui, 'TARGET REACHED', `+$${
|
|
1858
|
-
ui.addLog('success', `████ DAILY TARGET REACHED: +$${
|
|
1859
|
-
emergencyStopAll();
|
|
1858
|
+
algoLogger.info(ui, 'TARGET REACHED', `+$${totalPnl.toFixed(2)} >= $${dailyTarget}`);
|
|
1859
|
+
ui.addLog('success', `████ DAILY TARGET REACHED: +$${totalPnl.toFixed(2)} ████`);
|
|
1860
|
+
emergencyStopAll();
|
|
1861
|
+
return;
|
|
1860
1862
|
}
|
|
1863
|
+
|
|
1861
1864
|
// Max risk reached - STOP to protect capital
|
|
1862
|
-
|
|
1865
|
+
// Trigger if: closed P&L hits risk OR open P&L hits risk OR total hits risk
|
|
1866
|
+
if (closedPnl <= -maxRisk) {
|
|
1867
|
+
stopReason = 'risk';
|
|
1868
|
+
running = false;
|
|
1869
|
+
algoLogger.info(ui, 'CLOSED P&L RISK', `Closed: -$${Math.abs(closedPnl).toFixed(2)} <= -$${maxRisk}`);
|
|
1870
|
+
ui.addLog('error', `████ MAX RISK (CLOSED): -$${Math.abs(closedPnl).toFixed(2)} ████`);
|
|
1871
|
+
emergencyStopAll();
|
|
1872
|
+
} else if (openPnl <= -maxRisk) {
|
|
1873
|
+
stopReason = 'risk';
|
|
1874
|
+
running = false;
|
|
1875
|
+
algoLogger.info(ui, 'OPEN P&L RISK', `Open: -$${Math.abs(openPnl).toFixed(2)} <= -$${maxRisk}`);
|
|
1876
|
+
ui.addLog('error', `████ MAX RISK (OPEN): -$${Math.abs(openPnl).toFixed(2)} ████`);
|
|
1877
|
+
emergencyStopAll();
|
|
1878
|
+
} else if (totalPnl <= -maxRisk) {
|
|
1863
1879
|
stopReason = 'risk';
|
|
1864
1880
|
running = false;
|
|
1865
|
-
algoLogger.info(ui, '
|
|
1866
|
-
ui.addLog('error', `████ MAX RISK
|
|
1867
|
-
emergencyStopAll();
|
|
1881
|
+
algoLogger.info(ui, 'TOTAL P&L RISK', `Total: -$${Math.abs(totalPnl).toFixed(2)} <= -$${maxRisk}`);
|
|
1882
|
+
ui.addLog('error', `████ MAX RISK (TOTAL): -$${Math.abs(totalPnl).toFixed(2)} ████`);
|
|
1883
|
+
emergencyStopAll();
|
|
1868
1884
|
}
|
|
1869
1885
|
};
|
|
1870
1886
|
|