hedgequantx 2.6.133 → 2.6.135

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedgequantx",
3
- "version": "2.6.133",
3
+ "version": "2.6.135",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -1683,10 +1683,15 @@ const launchMultiSymbolRithmic = async (service, account, contracts, config) =>
1683
1683
  algoLogger.algoOperational(ui, 'RITHMIC');
1684
1684
  });
1685
1685
 
1686
+ // Smart logs state tracking
1687
+ let lastHeartbeat = Date.now();
1688
+ let tps = 0;
1689
+
1686
1690
  marketFeed.on('tick', (tick) => {
1687
1691
  if (!running) return;
1688
1692
 
1689
1693
  tickCount++;
1694
+ tps++;
1690
1695
  stats.latency = tick.latency || 0;
1691
1696
 
1692
1697
  // Route tick to correct strategy based on symbol
@@ -1743,6 +1748,48 @@ const launchMultiSymbolRithmic = async (service, account, contracts, config) =>
1743
1748
  }
1744
1749
  }
1745
1750
 
1751
+ // ═══════════════════════════════════════════════════════════════════════════
1752
+ // SMART LOGS - Same as single-symbol mode
1753
+ // ═══════════════════════════════════════════════════════════════════════════
1754
+ const now = Date.now();
1755
+ if (now - lastHeartbeat > 1000) {
1756
+ // Get model values from first active symbol's strategy
1757
+ const firstSymbol = Object.keys(strategies)[0];
1758
+ const firstStrategy = strategies[firstSymbol];
1759
+ const modelValues = firstStrategy?.getModelValues?.() || firstStrategy?.getModelValues?.(firstSymbol) || null;
1760
+
1761
+ if (modelValues && modelValues.ofi !== undefined) {
1762
+ const ofi = modelValues.ofi || 0;
1763
+ const delta = modelValues.delta || 0;
1764
+ const zscore = modelValues.zscore || 0;
1765
+ const mom = modelValues.momentum || 0;
1766
+
1767
+ // Check if any symbol has an open position
1768
+ const totalPosition = Object.values(stats.symbolStats).reduce((sum, s) => sum + Math.abs(s.position || 0), 0);
1769
+
1770
+ if (totalPosition === 0) {
1771
+ // Not in position - show market analysis (varied messages)
1772
+ const smartLogs = require('./smart-logs');
1773
+ const stateLog = smartLogs.getMarketStateLog(ofi, zscore, mom, delta);
1774
+ if (stateLog.details) {
1775
+ ui.addLog('analysis', `${stateLog.message} - ${stateLog.details}`);
1776
+ } else {
1777
+ ui.addLog('info', stateLog.message);
1778
+ }
1779
+ }
1780
+ // When IN POSITION: Don't spam logs every second
1781
+ } else {
1782
+ // Waiting for data - log every 5 seconds only
1783
+ if (now - lastHeartbeat > 5000) {
1784
+ const smartLogs = require('./smart-logs');
1785
+ const scanLog = smartLogs.getScanningLog(true);
1786
+ ui.addLog('info', `${scanLog.message} ${tps} ticks/s`);
1787
+ }
1788
+ }
1789
+ lastHeartbeat = now;
1790
+ tps = 0;
1791
+ }
1792
+
1746
1793
  ui.render(stats);
1747
1794
  });
1748
1795
 
@@ -1887,19 +1934,25 @@ const launchMultiSymbolRithmic = async (service, account, contracts, config) =>
1887
1934
  const emergencyStopAll = async () => {
1888
1935
  ui.addLog('warning', '████ EMERGENCY STOP ████');
1889
1936
 
1890
- // Close all positions
1891
- for (const [symbolName, pm] of Object.entries(positionManagers)) {
1892
- try {
1893
- if (pm.hasPosition(symbolName)) {
1894
- pm.closePosition(symbolName);
1895
- ui.addLog('info', `[${symbolName}] Closing position...`);
1937
+ try {
1938
+ // Use Rithmic emergencyStop to flatten all positions
1939
+ if (service && typeof service.emergencyStop === 'function') {
1940
+ await service.emergencyStop(rithmicAccountId);
1941
+ ui.addLog('info', 'Emergency stop executed - all positions flattened');
1942
+ } else if (service && typeof service.flattenAll === 'function') {
1943
+ await service.flattenAll(rithmicAccountId);
1944
+ ui.addLog('info', 'Flatten all executed - all positions closed');
1945
+ } else {
1946
+ // Fallback: cancel all orders
1947
+ if (service && typeof service.cancelAllOrders === 'function') {
1948
+ await service.cancelAllOrders(rithmicAccountId);
1949
+ ui.addLog('info', 'All orders cancelled');
1896
1950
  }
1897
- } catch (e) {
1898
- ui.addLog('error', `[${symbolName}] Close failed: ${e.message}`);
1899
1951
  }
1952
+ } catch (e) {
1953
+ ui.addLog('error', `Emergency stop error: ${e.message}`);
1900
1954
  }
1901
1955
 
1902
- ui.addLog('info', 'All close orders sent');
1903
1956
  ui.render(stats);
1904
1957
  };
1905
1958